Sign in to follow this  
Followers 0
Will66

How to select all text

7 posts in this topic

How to select all text in an edit box:

$textBox=GUICtrlCreateEdit("hello",100,150,300,200)

..

..

GUICtrlSetState($textBox, $GUI_FOCUS)

-> How to select all text in the $textBox?

Share this post


Link to post
Share on other sites



Set the focus and send the keys "ctrl + a"

If you want to get the text entered in the edit, then

$textFromAnEditBox = GUICtrlRead($myEditBox)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

does'nt work if i do it with the keyboard, yet to try it programmatically.

edit:tried

GUICtrlSetState($textBox, $GUI_FOCUS)

Send("^a")

doesn't work.

Select all is available in the context menu

Edited by Will66

Share this post


Link to post
Share on other sites

does'nt work if i do it with the keyboard, yet to try it programmatically.

edit:tried

GUICtrlSetState($textBox, $GUI_FOCUS)

Send("^a")

doesn't work.

Select all is available in the context menu

Any particular reason why you need to select all the the text? I think JRowe's suggestion with GUICtrlRead() is so that you can get all the data that the edit has if that is your goal.

If it's something else... then you need to open up your help file that has the UDFs in them and look for: _GUICtrlEdit_SetSel()


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Any particular reason why you need to select all the the text? I think JRowe's suggestion with GUICtrlRead() is so that you can get all the data that the edit has if that is your goal.

If it's something else... then you need to open up your help file that has the UDFs in them and look for: _GUICtrlEdit_SetSel()

My son is Autistic, its a bit much for him to select all before he begins typing.

He can type his name and a few other things, but each time i want the text highlighted so he can easily overtype it

#include <GUIConstants.au3>
GUICreate("Speech",600,450)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
Dim $oSp = ObjCreate("SAPI.SpVoice")

$okButton=GUICtrlCreateButton("Say it!",100,50,100,50)
        GUICtrlSetOnEvent(-1, "okButton_Clicked")


GUICtrlCreateButton("ADAM  Jones!",100,50,100,50)
        GUICtrlSetOnEvent(-1, "adam_Clicked")
        
ConsoleWrite(ClipGet())     
$textBox=GUICtrlCreateEdit("hello",100,150,300,200)
GUISetState ()
GUICtrlSetState($textBox, $GUI_FOCUS) 

;$Text = InputBox("Text", "Type text to say", "")


 
 while(1)
     Sleep(100)
 wend
 
  Func adam_Clicked()
        $oSp.Speak("ADAM  Jones!")
     
    EndFunc
 
 Func okButton_Clicked()
     $Text=GUICtrlRead($textBox)
    $oSp.Speak($Text)
     GUICtrlSetState($textBox, $GUI_FOCUS) 
;Send("^a")  doesn't work

;;select all text here
    EndFunc
 
 Func CLOSEClicked()
      Exit   
EndFunc

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <EditConstants.au3>
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

Dim $fWait = True
Dim $hGUI = GUICreate("Speech",600,450)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

Dim $oSp = ObjCreate("SAPI.SpVoice")
ObjEvent($oSp, 'Speech_')
Dim $okButton=GUICtrlCreateButton("Say it!",100,50,100,50)
        GUICtrlSetOnEvent(-1, "okButton_Clicked")


GUICtrlCreateButton("ADAM  Jones!",100,50,100,50)
        GUICtrlSetOnEvent(-1, "adam_Clicked")
        
Dim $textBox=GUICtrlCreateEdit("hello",100,150,300,200)
Dim $htextbox = GUICtrlGetHandle(-1)
GUISetState ()
GUICtrlSetState($textBox, $GUI_FOCUS)

;$Text = InputBox("Text", "Type text to say", "")



while(1)
     Sleep(100)
wend

Func adam_Clicked()
    $oSp.Speak("ADAM  Jones!")
EndFunc

Func okButton_Clicked()
    $Text=GUICtrlRead($textBox)
    $oSp.Speak($Text)
    While $fWait
        Sleep(50)
    WEnd
    
    GUICtrlSetState($textBox, $GUI_FOCUS)
    DllCall('user32.dll', 'long', 'SendMessage', 'hwnd', $htextbox, 'uint', $EM_SETSEL, _
        'int', 0, 'int', -1)
    $fWait = True
EndFunc

Func CLOSEClicked()
      Exit  
EndFunc

Func Speech_EndStream($iStreamNumber, $iStreamPosition)
    $fWait = False
EndFunc

Share this post


Link to post
Share on other sites

Thanks Authenticity, I appreciate your code, it works well :D

Before your post i went with this:

Func okButton_Clicked()
    $Text=GUICtrlRead($textBox)
    $c = StringLen($Text)
    $oSp.Speak($Text)
     GUICtrlSetState($textBox, $GUI_FOCUS)
    _GUICtrlEdit_SetSel($textBox,0,$c);;select all text here
EndFunc

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