Moderators Melba23 Posted November 2, 2011 Moderators Share Posted November 2, 2011 Zedna, I have been puzzling over how to do that! 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 That's better, but the problem is that it breaks the "CTRL+A" functionality for the other inputs, that is initially working. 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 dv6,What "other inputs"? This works for all "Edit"-class controls in the GUI. Post an example GUI where it does not work for you and we will try and debug it. 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...
Zedna Posted November 2, 2011 Share Posted November 2, 2011 That's better, but the problem is that it breaks the "CTRL+A" functionality for the other inputs, that is initially working. I don't understand.For me it's working fine without any negative effects. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
dv8 Posted November 2, 2011 Share Posted November 2, 2011 (edited) You are absolutely right! I'm really sorry! I spoke before I tested it properly. The previous solution was working fine for the EDIT fields but messed up the CTRL+A functionality for the INPUT fields. This one is actually working without these side effects. I apologize again! Thank you Zedna! If you ever plan a trip to Plovdiv, Bulgaria, send me a PM and I'll be glad to meet and buy you a lunch or dinner! Edited November 2, 2011 by dv8 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 Thank you Zedna! If you ever plan a trip to Plovdiv, Bulgaria, send me a PM and I'll be glad to meet and buy you a lunch or dinner! Thank you for such offer :-)I have never been to Bulgaria but you never know ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Affe Posted October 24, 2012 Share Posted October 24, 2012 (edited) I was just working with this in another program, and noticed I had posted a solution here earlier that I ended up using without noticing I posted it! Anyhoo, I found another way to use hotkeys without having to use accelerators to still make Ctrl+A work in all windows (only relevant code shown, code for GUI and everything else omitted): expandcollapse popup#Include <Misc.au3> #Include <SendMessage.au3> #include <WinAPI.au3> Global $hotkeyset = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case ;yada yada yada Case ;yada yada yada EndSwitch ;check for select all hotkey so it doesnt disable other windows If _WinAPI_GetForegroundWindow() == WinGetHandle($Parent_GUI) Or _WinAPI_GetForegroundWindow() == WinGetHandle($Child_GUI) Then If $hotkeyset = False Then _sethotkeys(True) Else If $hotkeyset = True Then _sethotkeys(False) EndIf WEnd Func _sethotkeys($toggle = True) If $toggle Then HotKeySet("^a", "_selectall") Else HotKeySet("^a") EndIf $hotkeyset = $toggle EndFunc Func _selectall() $hWnd = _WinAPI_GetFocus() $class = _WinAPI_GetClassName($hWnd) _SendMessage($hWnd, $EM_SETSEL, 0, -1) EndFunc ;==>_selectall Essentially, in the main While loop, you have the program check if your GUI is the foreground window. If it isn't, the hotkeys are disabled, and if it is, they are re-enabled. I used two GUI's in this example to show a parent and a child, though you can have as many or as few as you like of course. Edited October 24, 2012 by Affe [center][/center] Link to comment Share on other sites More sharing options...
Kyan Posted March 21, 2013 Share Posted March 21, 2013 (edited) without external libraries for doing the work: #include <GUIConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> Global $input_left, $input_right, $hleft, $hright, $Flag = 1, $Flag2 = 1 GUICreate("Test", 430, 210) $input_left = GUICtrlCreateInput("here is some text on the left", 10, 10, 200, 19) $input_right = GUICtrlCreateInput("here is some text on the right", 220, 30, 200, 19) $hleft = GUICtrlGetHandle($input_left) $hright = GUICtrlGetHandle($input_right) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN $aCurPos = GUIGetCursorInfo() If $aCurPos <> 0 Then If $aCurPos[4] = $input_left And $Flag = 1 Then GUICtrlSetState($input_left,$GUI_FOCUS) GUICtrlSendMsg($hleft,0xB1,0,-1) ;$EM_SETSEL = 0xB1 $Flag = 0 ElseIf $aCurPos[4] <> $input_left And $Flag = 0 Then $Flag = 1 EndIf If $aCurPos[4] = $input_right And $Flag2 = 1 Then GUICtrlSetState($input_right,$GUI_FOCUS) GUICtrlSendMsg($hright,0xB1,0,-1) ;$EM_SETSEL = 0xB1 $Flag2 = 0 ElseIf $aCurPos[4] <> $input_right And $Flag2 = 0 Then $Flag2 = 1 EndIf EndIf EndSwitchWEnd For EditCtrls this way won't work, may the parameter $EM_SETSEL (0xB1) need to be changed... PS: I used a gui posted here and I don't know tidy this for this forum :/ Edited March 21, 2013 by DiOgO Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Elias Posted January 25, 2016 Share Posted January 25, 2016 (edited) Any Edit Class = Edit e InputBox The problem is basically implement Ctrl+a to the Edit Control to Select AllThis worked well using GUIGetMsg () but when working with GUIOnEventMode this does not workBelow implementation to intercept Ctrl+a and Enter keys Create dummy for accelerator key to activate $cSelAll = GUICtrlCreateDummy() $cEnter = GUICtrlCreateDummy() ; Set accelerator for Ctrl+a , This intercepts all controls including InputBox Dim $aAccelKeys[][]=[["^a", $cSelAll],["{enter}", $cEnter]] GUISetAccelerators($aAccelKeys) The program below allows you to change the GUIGetMsg() Mode <=> GUIOnEventMode simply changing the CheckBox 26/01/2016PROBLEM SOLVED, GUICtrlGetHande($id) returns 0 for Dummy Controls and a Was not seting the event expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: Elias Assad Neto Script Function: Teste Ctrl+a To Select All text in Edit Control Problem: DOESN'T work in GUIOnEvent #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Global $EventMode = False ; Start Mode If $EventMode Then Opt("GUIOnEventMode", 1) #Region GUI #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### Form= $hGUI = GUICreate("Ctrl+a Select All Test", 502, 502, 192, 125) $idCBGUIOnEvent = GUICtrlCreateCheckbox("GUIOnEvent Test", 8, 10, 105, 17) $idLabelInput = GUICtrlCreateLabel("Input Box", 136, 12, 49, 17) $idLabelEdit = GUICtrlCreateLabel("Edit Control", 12, 32, 58, 17) $idInput = GUICtrlCreateInput("Ctrl+a Stop Workin with OnEvent", 192, 10, 289, 21) $idEdit1 = GUICtrlCreateEdit("", 10, 50, 480, 440) GUICtrlSetData(-1, "here is some text, Ctrl+a Only Whorks if Not in GUIOnEventMode Mode") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; Create dummy for accelerator key to activate $cSelAll = GUICtrlCreateDummy() $cEnter = GUICtrlCreateDummy() ; Set accelerator for Ctrl+a , This intercepts all controls including InputBox Dim $aAccelKeys[][]=[["^a", $cSelAll],["{enter}", $cEnter]] GUISetAccelerators($aAccelKeys) If 1 Then ; Crate Events for All Controls It Works in Not GUIOnEventMode too For $id=-13 To -3 ; $GUI_EVENT_DROPPED(-13) to $GUI_EVENT_CLOSE(-3) GUISetOnEvent($id, "GUIEvent") Next $id = 3 ; Controls Start at id = 3 $k = 0 ; Limit Couter Do $h = GUICtrlGetHandle($id) ; test if control exist If $h <> 0 Then ; Is Control GUICtrlSetOnEvent($id, "GUIEvent") ; Id Has Contro Set Event Else $k +=1 ; Id has no control this can hapen if control is deleted EndIf $id +=1 Until $k > 20 ; No more Controls EndIf If $EventMode Then _CheckBox($idCBGUIOnEvent,1) #Region Program LOOP =============================================================================================== While 1 If $EventMode Then Sleep(100) Else GUI_Msg(GUIGetMsg()) EndIf WEnd Func GUIEvent() ; Event Parser GUI_Msg(@GUI_CtrlId) EndFunc #EndRegion Program LOOP =============================================================================================== #Region GUI Process messages/Event Func GUI_Msg($GUI_CtrlId) ; Process GUI Message or Event If $GUI_CtrlId = 0 Then Return If $EventMode Then Local $GUI_WinHandle = @GUI_WinHandle, $GUI_CtrlHandle = @GUI_CtrlHandle Else Local $GUI_WinHandle = $hGUI, $GUI_CtrlHandle = GUICtrlGetHandle($GUI_CtrlId) EndIf If $GUI_CtrlId > 0 Then ConsoleWrite(StringFormat("> $GUI_CtrlId: %3d, @GUI_WinHandle: 0x%08X, @GUI_CtrlHandle: 0x%08X\n",$GUI_CtrlId, $GUI_WinHandle, $GUI_CtrlHandle)) Switch $GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $cSelAll _SelAll() Case $cEnter _EnterKey() Case $idCBGUIOnEvent $EventMode = _CheckBox($idCBGUIOnEvent) If $EventMode Then Opt("GUIOnEventMode", 1) ; Switch to GUIOnEvent Else Opt("GUIOnEventMode", 0) ; Switch to GUIGetMsg EndIf EndSwitch EndFunc #Region GUI Process messages/Event #Region GUI Aux Funcs Func _CheckBox($idControlID, $State = -1) ; (-1)-Read, (0)-Uncheck CheckBox (1)-Check ; Return State If $State = 0 Then GUICtrlSetState($idControlID, $GUI_UNCHECKED) If $State = 1 Then GUICtrlSetState($idControlID, $GUI_CHECKED) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_CheckBox Func _SelAll() ; Select All, used for Inbox and Edit controls Intercept Ctrl+a Local $hFocus = _WinAPI_GetFocus() Local $sClass = _WinAPI_GetClassName($hFocus) ConsoleWrite(StringFormat("- Class: %-12s $hFocus: 0x%08X\n", $sClass, $hFocus)) If $sClass = "Edit" Then _GUICtrlEdit_SetSel($hFocus, 0, -1) EndFunc ;==>_SelAll Func _EnterKey() ; Shows the control's text by pressing Enter on Edit or Inbox Control Local $hFocus = _WinAPI_GetFocus() Local $sClass = _WinAPI_GetClassName($hFocus) ConsoleWrite(StringFormat("- Class: %-12s $hFocus: 0x%08X\n", $sClass, $hFocus)) If $sClass = "Edit" Then MsgBox(0,"Enter pressed",_GUICtrlEdit_GetText($hFocus)) EndFunc ;==>_SelAll #EndRegion GUI Aux Funcs Edited January 26, 2016 by Elias 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