Sign in to follow this  
Followers 0
Eigensheep

Retrieving the selection from a GUICtrlCreateInput

3 posts in this topic

I have a GUI with a multi-line input control (GUICtrlCreateInput) and when the user clicks a button, I'd like to know what they've selected within it. I got as far as ControlFocus but then what? GUICtrlRead just gives me the whole text in the box (as you'd expect).

I'm probably missing something really simple but any help would be great.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have a GUI with a multi-line input control (GUICtrlCreateInput) and when the user clicks a button, I'd like to know what they've selected within it. I got as far as ControlFocus but then what? GUICtrlRead just gives me the whole text in the box (as you'd expect).

I'm probably missing something really simple but any help would be great.

Look up _GUICtrlEdit_GetSel, I think that will do what you want. It returns the starting and ending character positions of the selected text, so I assume you do this

$StartEnd = _GUICtrlEdit_GetSel(GuiCtrlGetHandle($edit))
$Selected = StringMid(GuiCtrlRead($Edit),$StartEnd[0] + 1,$StartEnd[1] - $StartEnd[0])

EDIT: ?? How do you get a multiline input using GUICtrlCreateInput? Do you mean GuiCtrlCreateEdit?

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I used GUICtrlCreateInput("",81,272,480,141,0x00201044).

Sorry for the bad syle reference. While we're on the topic though, I put the style in manually to combine more than one style as I couldn't get it to work with BitAnd() BitOr() And() or Or(). Is there a way of doing this using constants?

[Edit]

Sorry, found that it will work if I use BitOr(). In that case the syntax becomes:

GUICtrlCreateInput("",81,272,480,141,BitOr($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_MULTILINE, $ES_WANTRETURN)).

Thanks for the help.

Edited by NumberDaemon

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0