DarkBoost Posted June 28, 2009 Share Posted June 28, 2009 (edited) Is there a simple way to setup the CTRL+A Hotkey which will select everything in the selected Edit or Input Box? Not sure how to tackle this without sending a double-mouse click to a specified Edit/Input box which doesn't help as I have multiple Edit/Input boxes. Quick Example: #include <GUIConstantsEx.au3> Opt("MustDeclareVars", 1) Global $input_left, $input_right HotKeySet("^a", "_selectall") GUICreate("", 430, 210) $input_left = GUICtrlCreateEdit("here is some text on the left", 10, 10, 200, 190) $input_right = GUICtrlCreateEdit("here is some text on the right", 220, 10, 200, 190) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _selectall() ;add working code here? EndFunc Edited June 28, 2009 by DarkBoost Link to comment Share on other sites More sharing options...
picea892 Posted June 28, 2009 Share Posted June 28, 2009 try this If it's not an autoit window ControlFocus("[CLASS:Notepad]", "", "Edit1") send("^a") otherwise GUICtrlSetState("?HANDLE?", $GUI_FOCUS) send("^a") Link to comment Share on other sites More sharing options...
DarkBoost Posted June 28, 2009 Author Share Posted June 28, 2009 By default CTRL + A is not a working hotkey with AutoIT Edit/Input boxes so send("^a") will do nothing in an AutoIT GUI. I am trying to recreate the commonly used CTRL + A hotkey with AutoIT to select all the text in the Edit or Input box which is in Focus. There are multiple Edit/Input boxes so I would like the CTRL + A to select the box in focus not just 1 box etc... Hope this is making sense ? Link to comment Share on other sites More sharing options...
BugFix Posted June 28, 2009 Share Posted June 28, 2009 Why you want to select all in edit/input in your self created form? Use GuiCtrlRead($ctrl) to get all in this. Best Regards BugFix Link to comment Share on other sites More sharing options...
Authenticity Posted June 28, 2009 Share Posted June 28, 2009 expandcollapse popup#include <Constants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Dim $hGUI Dim $Edit, $hEdit Dim $hFunc, $pFunc, $hWndProc $hGUI = GUICreate('Test', 200, 200) $Edit = GUICtrlCreateEdit('123' & @CRLF & '456' & @CRLF & '789', 0, 0, 200, 200) $hEdit = GUICtrlGetHandle(-1) $hFunc = DllCallbackRegister('_EditHandler', 'lresult', 'hwnd;uint;wparam;lparam') $pFunc = DllCallbackGetPtr($hFunc) $hWndProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $pFunc) GUISetState() Do Until GUIGetMsg() = -3 GUIDelete() DllCallbackFree($hFunc) Exit Func _EditHandler($hWnd, $iMsg, $iwParam, $ilParam) Switch $iMsg Case $WM_CHAR ConsoleWrite('WM_CHAR: ' & $iwParam & @LF) If $iwParam = 1 Then _SendMessage($hWnd, $EM_SETSEL, 0, -1) Case $WM_KEYDOWN ConsoleWrite('WM_KEYDOWN: ' & $iwParam & @LF) Case $WM_KEYUP ConsoleWrite('WM_KEYUP: ' & $iwParam & @LF) Case $WM_SYSKEYDOWN ConsoleWrite('WM_SYSKEYDOWN: ' & $iwParam & @LF) Case $WM_SYSKEYUP ConsoleWrite('WM_SYSKEYUP: ' & $iwParam & @LF) Case $WM_SYSCHAR ConsoleWrite('WM_SYSCHAR: ' & $iwParam & @LF) EndSwitch Return _WinAPI_CallWindowProc($hWndProc, $hWnd, $iMsg, $iwParam, $ilParam) EndFunc Link to comment Share on other sites More sharing options...
DarkBoost Posted June 28, 2009 Author Share Posted June 28, 2009 (edited) @Authenticity: Perfect thank you kindly!!! I have again failed to provide enough information as people are not understanding what I am trying to achieve If you open ANYTHING (excluding an AutoIT GUI) which has an input field eg. Notepad, Word, Excel, Email, Internet Explorer Field etc... you can do CTRL + A to select everything in that selected field. You can then do things like CUT, COPY, DELETE etc.As this feature is not (by default) included when creating GUICtrlCreateEdit or GUICtrlCreateInput in AutoIT I am trying to simply create this as a HotKeySet("^a".... and am not sure how to achieve this. If there is a simple thing I have missed eg. #include <DefaultHotKeySet.au3> I have not been able to find this in the Helpfile or the Forum and wondering if this does exist or how one would recreate this manually if need be. Edited June 28, 2009 by DarkBoost Link to comment Share on other sites More sharing options...
martin Posted June 28, 2009 Share Posted June 28, 2009 @Authenticity: Perfect thank you kindly!!! I have again failed to provide enough information as people are not understanding what I am trying to achieve If you open ANYTHING (excluding an AutoIT GUI) which has an input field eg. Notepad, Word, Excel, Email, Internet Explorer Field etc... you can do CTRL + A to select everything in that selected field. You can then do things like CUT, COPY, DELETE etc. As this feature is not (by default) included when creating GUICtrlCreateEdit or GUICtrlCreateInput in AutoIT I am trying to simply create this as a HotKeySet("^a".... and am not sure how to achieve this. If there is a simple thing I have missed eg. #include <DefaultHotKeySet.au3> I have not been able to find this in the Helpfile or the Forum and wondering if this does exist or how one would recreate this manually if need be.Is this the sort of thing you mean? expandcollapse popup#include <GUIConstantsEx.au3> #include <guiEdit.au3> #include <editconstants.au3> #include <windowsconstants.au3> Opt("MustDeclareVars", 1) Global $input_left, $input_right, $Gui, $method, $focusedID HotKeySet("^a", "_selectall") $Gui = GUICreate("", 430, 210) $input_left = GUICtrlCreateEdit("here is some text on the left", 10, 10, 200, 190) $input_right = GUICtrlCreateEdit("here is some text on the right", 220, 10, 200, 190) GUIRegisterMsg($WM_COMMAND, "MWCOMMAND");before setstate so we know which edit has focus to start with GUISetState(@SW_SHOW) $method = 1 Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _selectall() Switch $method Case 1 ConsoleWrite("using method 1" & @CRLF) Send("^{HOME}+^{END}") Case 0 Switch $focusedID Case $input_left, $input_right ConsoleWrite("using method 2" & @CRLF) _GUICtrlEdit_SetSel(ControlGetHandle($Gui, "", $focusedID), 0, StringLen(GUICtrlRead($focusedID))) EndSwitch EndSwitch $method = not $method EndFunc ;==>_selectall Func MWCOMMAND($h, $m, $W, $l) Local $ID, $iN $iN = BitAND($W, 0xffff0000) / 0x10000 If $iN = $EN_KILLFOCUS Then $focusedID = 0 $iN = BitAND($W, 0xffff0000) / 0x10000 If $iN = $EN_SETFOCUS Then $focusedID = BitAND($W, 0xffff) Return $GUI_RUNDEFMSG EndFunc ;==>MWCOMMAND 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. Link to comment Share on other sites More sharing options...
Yashied Posted June 28, 2009 Share Posted June 28, 2009 @martin 1. You may write a more simple: _GUICtrlEdit_SetSel($focusedID, 0, -1) 2. I think here MWCOMMAND() handler is unnecessary. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
martin Posted June 28, 2009 Share Posted June 28, 2009 @martin1. You may write a more simple: _GUICtrlEdit_SetSel($focusedID, 0, -1)2. I think here MWCOMMAND() handler is unnecessary.Yes thanks Yashied. I forgot about -1 for the whole text, and it's true I need not have passed the handle, but why is WMCOMMAND not needed? Without that I don'y know the value of $focussedID. 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. Link to comment Share on other sites More sharing options...
Yashied Posted June 28, 2009 Share Posted June 28, 2009 (edited) Yes thanks Yashied. I forgot about -1 for the whole text, and it's true I need not have passed the handle, but why is WMCOMMAND not needed? Without that I don'y know the value of $focussedID.#include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $input_left, $input_right, $hleft, $hright HotKeySet("^a", "_selectall") GUICreate("", 430, 210) $input_left = GUICtrlCreateEdit("here is some text on the left", 10, 10, 200, 190) $input_right = GUICtrlCreateEdit("here is some text on the right", 220, 10, 200, 190) $hleft = GUICtrlGetHandle($input_left) $hright = GUICtrlGetHandle($input_right) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _selectall() Local $hWnd = _WinAPI_GetFocus() Switch $hWnd Case 0 Case $hleft, $hright _GUICtrlEdit_SetSel($hWnd, 0, -1) Return EndSwitch HotKeySet("^a") Send("^a") HotKeySet("^a", "_selectall") EndFunc ;==>_selectall Edited June 28, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
martin Posted June 28, 2009 Share Posted June 28, 2009 #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $input_left, $input_right, $hleft, $hright HotKeySet("^a", "_selectall") GUICreate("", 430, 210) $input_left = GUICtrlCreateEdit("here is some text on the left", 10, 10, 200, 190) $input_right = GUICtrlCreateEdit("here is some text on the right", 220, 10, 200, 190) $hleft = GUICtrlGetHandle($input_left) $hright = GUICtrlGetHandle($input_right) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _selectall() Local $hWnd = _WinAPI_GetFocus() Switch $hWnd Case 0 Case $hleft, $hright _GUICtrlEdit_SetSel($hWnd, 0, -1) Return EndSwitch HotKeySet("^a") Send("^a") HotKeySet("^a", "_selectall") EndFunc ;==>_selectallOK, I'm not having a ggod day Thanks again. 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. Link to comment Share on other sites More sharing options...
Malkey Posted June 29, 2009 Share Posted June 29, 2009 Using Authenticity's method to select all but activated with the hot keys "Ctrl + A", there is this. ; #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WinAPI.au3> Opt("MustDeclareVars", 1) Global $input_left, $input_right HotKeySet("^a", "_selectall") GUICreate("", 430, 250) $input_left = GUICtrlCreateEdit("here is some text on the left", 10, 10, 200, 190) $input_right = GUICtrlCreateEdit("here is some text on the right", 220, 10, 200, 190) GUICtrlCreateInput("Input data", 10, 210, 150, 25) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _selectall() _SendMessage(ControlGetHandle("", "", ""), $EM_SETSEL, 0, -1) EndFunc ;==>_selectall ; Link to comment Share on other sites More sharing options...
DarkBoost Posted June 29, 2009 Author Share Posted June 29, 2009 wow so many ways to accomplish this, thank you all for your input it has helped alot! Link to comment Share on other sites More sharing options...
Affe Posted April 21, 2011 Share Posted April 21, 2011 (edited) I know this is a bit of an old thread, but I found it useful and wanted to toss in a bit of extra info: Used the HotKey and _selectall() method. With other windows forms, there's another default ability to select all when you left-click on an input/edit while holding the control (CTRL) button down. I added this into the While Loop for the GUI itself when using GUIGetMsg(): While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN ;Left Mouse Button is pressed, need to check if we are selecting all! If _IsPressed(11) Then _selectall() ;"11" is the CTRL button EndSwitch WEnd Func _selectall() _SendMessage(ControlGetHandle("", "", ""), $EM_SETSEL, 0, -1) EndFunc ;==>_selectall Figured someone might find it useful Edited April 21, 2011 by Affe [center][/center] Link to comment Share on other sites More sharing options...
dv8 Posted November 2, 2011 Share Posted November 2, 2011 Has anyone noticed that with all these methods the "CTRL+A" combination stops working in all the other windows while this AutoIt script is running?There has got to be another way to make "CTRL+A" working in the Edit and Input controls. Free Remote Desktop Software For Windows Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2011 Moderators Share Posted November 2, 2011 dv8, the "CTRL+A" combination stops working in all the other windowsThat is because a HotKey has a Global effect so it works all the time. What you need is an Accelerator key - then it will only work when your script is active. Take a look at this to see how to do it: #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WinAPI.au3> Global $hInput_Handle $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateEdit("here is some text", 10, 10, 480, 480) $hInput_Handle = GUICtrlGetHandle(-1) ; Create dummy for accelerator key to activate $hSelAll = GUICtrlCreateDummy() GUISetState() ; Set accelerators for Ctrl+a Dim $AccelKeys[1][2]=[["^a", $hSelAll]] GUISetAccelerators($AccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hSelAll _SelAll() EndSwitch WEnd Func _SelAll() Switch _WinAPI_GetFocus() Case $hInput_Handle _GUICtrlEdit_SetSel($hInput_Handle, 0, -1) Return EndSwitch EndFunc ;==>_SelAll All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dv8 Posted November 2, 2011 Share Posted November 2, 2011 Hmm, this looks better than the previous suggestions, but still... If I have 10 GUIs with 20 input boxes and 10 Edit boxes each, it will be a PITA to write the _SelAll() function for all of the controls. And I'll have to remember to update this function every time I make a change to the GUI. The question is why CTRL+C and CTRL+V and CTRL+Z etc. are working fine in the inputs and edits but the CTRL+A is not? Is this a bug? Free Remote Desktop Software For Windows Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2011 Moderators Share Posted November 2, 2011 dv8,Is this a bug?Yes, but with Windows Edit controls, not with AutoIt. Google it to find out more. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dv8 Posted November 2, 2011 Share Posted November 2, 2011 Thanks for your fast replies Melba23. I appreciate it. Free Remote Desktop Software For Windows Link to comment Share on other sites More sharing options...
Zedna Posted November 2, 2011 Share Posted November 2, 2011 (edited) Hmm, this looks better than the previous suggestions, but still... If I have 10 GUIs with 20 input boxes and 10 Edit boxes each, it will be a PITA to write the _SelAll() function for all of the controls. And I'll have to remember to update this function every time I make a change to the GUI. Here is efect universal solution for all edit controls in GUI #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WinAPI.au3> $hGUI = GUICreate("Test", 500, 500) $hInput1 = GUICtrlCreateEdit("here is some text 1", 10, 10, 480, 240) $hInput2 = GUICtrlCreateEdit("here is some text 2", 10, 250, 480, 240) ; Create dummy for accelerator key to activate $hSelAll = GUICtrlCreateDummy() GUISetState() ; Set accelerators for Ctrl+a Dim $AccelKeys[1][2]=[["^a", $hSelAll]] GUISetAccelerators($AccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hSelAll _SelAll() EndSwitch WEnd Func _SelAll() $hWnd = _WinAPI_GetFocus() $class = _WinAPI_GetClassName($hWnd) If $class = 'Edit' Then _GUICtrlEdit_SetSel($hWnd, 0, -1) EndFunc ;==>_SelAll Edited November 2, 2011 by Zedna Mosoo, J2TeaM and Awwe 3 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
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