Will66 Posted April 10, 2009 Posted April 10, 2009 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?
JRowe Posted April 10, 2009 Posted April 10, 2009 Set the focus and send the keys "ctrl + a" If you want to get the text entered in the edit, then $textFromAnEditBox = GUICtrlRead($myEditBox) [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center]
Will66 Posted April 10, 2009 Author Posted April 10, 2009 (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 April 10, 2009 by Will66
Moderators SmOke_N Posted April 10, 2009 Moderators Posted April 10, 2009 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 menuAny 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.
Will66 Posted April 10, 2009 Author Posted April 10, 2009 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 expandcollapse popup#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
Authenticity Posted April 10, 2009 Posted April 10, 2009 expandcollapse popup#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
Will66 Posted April 10, 2009 Author Posted April 10, 2009 Thanks Authenticity, I appreciate your code, it works well 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now