Jump to content
Sign in to follow this  
E1M1

How to get selected text from edit control

Recommended Posts

E1M1

How do I get selected text from edit control?I have GUI with edit control, and I select some some text there. Now I want get that selected text, how could I do it?

I have gui that is similar to window's notepad, but I cant find code for "copy" button only code I invent was send("^c") , but I need other than send.


edited

Share this post


Link to post
Share on other sites
monoceres

_GUICtrlEdit_GetSel().


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
E1M1

_GUICtrlEdit_GetSel().

Return Value

Success: Array in the following format:

[0] - Starting position

[1] - Ending position

It return position but I want get text, then I still need function to get all char(s) from $pos[0] to $pos[1]

edited

Share this post


Link to post
Share on other sites
martin

It return position but I want get text, then I still need function to get all char(s) from $pos[0] to $pos[1]

If you know the first position and the last then there's not muchmore to figure out.

$range = _GUICtrlEdit_GetSel(GUICtrlGetHandle($Edit1))
If $range[0] <> $range[1] Then
  $SelectedText = StringMid(GUICtrlRead($Edit1), $range[0] + 1, $range[1] - $range[0]))
EndIf

Or something pretty close to that.


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
E1M1

thanks! It was easy and working solution


edited

Share this post


Link to post
Share on other sites
myspacee

Hello,

sorry for take back this post. I used MVPs code:

$range = _GUICtrlEdit_GetSel(GUICtrlGetHandle($Edit1))
 

$range = _GUICtrlEdit_GetSel(GUICtrlGetHandle($Edit1))
If $range[0] <> $range[1] Then
  $SelectedText = StringMid(GUICtrlRead($Edit1), $range[0] + 1, $range[1] - $range[0]))
EndIf

this works perfectly to obtain selected text. Now, how replace text in same position ?

eg:

- i select letter Y form : New York

- recover selection with above code

- replace selection in that point with different letter : New Zork

 

thank you,

m.

Share this post


Link to post
Share on other sites
MikahS

This is a 6 year old topic, my suggestion would have been to start a new topic.

But, just use the function :

_GUICtrlEdit_ReplaceSel(GUIctrlGetHandle($Edit1), "Z")

instead.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
myspacee

Thank you,

it wore perfectly, sorry for retake post.

m.

Share this post


Link to post
Share on other sites
MikahS

Glad it helped. 

For next time. ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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  

×