Armand Posted January 17, 2009 Share Posted January 17, 2009 hi, is there a fast and ez way to set the entire GUI to respond to these windows normal hotkeys [Ctrl+a = select all, Ctrl+c = copy etc] ?? My Edit/Input boxes are ugly without it! [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
Immensee Posted January 17, 2009 Share Posted January 17, 2009 (edited) hi, is there a fast and ez way to set the entire GUI to respond to these windows normal hotkeys [Ctrl+a = select all, Ctrl+c = copy etc] ?? My Edit/Input boxes are ugly without it! Hey hey, i don't know what you mean what you said above, but is this something what you want? $x = 0 Do ;;Check the SEND() in help file (F1) for more keys. HotKeySet("^a", "myFunc") HotKeySet("^x", "myFunc") HotKeySet("^c", "myFunc") HotKeySet("^v", "myFunc") ;;variable x on 234 will stop the program Until $x = 234 Exit Func myFunc() ;;Your command what to do when CTRL + A is pressed. MsgBox(0, "", "Test text that shows up when pressing CTRL + A,X,C,V") ;;Extra variable to keep the program running. $x = 234 EndFunc Edited January 17, 2009 by Immensee Link to comment Share on other sites More sharing options...
Armand Posted January 17, 2009 Author Share Posted January 17, 2009 (edited) well thanks a lot for trying to help but this is not what i meant... i was looking for a property... any "normal" input field or edit box in windows environment respond to the following hot-keys: Ctrl + A -> Selects all. Ctrl + C -> Copies to clipboard. Ctrl + V -> Pastes from clipboard. Ctrl + X -> Cuts. And so on.... i was asking if there is a property / WM_Command msg i can send to these controls [input/edit/rest] so that they will react like "Normal" windows environment controls.... >>> THAT IS-> without having a function for each and every hot-key / control i have. Edited January 17, 2009 by Armand [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
-Ultima- Posted January 17, 2009 Share Posted January 17, 2009 (edited) Edit: No, there is no such option. The AutoIt edit controls already do behave like "normal" Win32 edit controls. Ctrl+C, Ctrl+V, Ctrl+X, Ctrl+Z come for free with edit/input boxes. Other things like Ctrl+A are implemented at the application level, and aren't "standard" or "normal" behavior. Need an example? Try pressing Ctrl+A in the standard Windows file property's filename inputbox -- it doesn't select all.At any rate, Ctrl+A can be done like so:expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIEdit.au3> Opt("GUIOnEventMode", 1) Global $iWidth = 500 Global $iHeight = 400 ; --- Setup --- Global $hWindow = GUICreate("Test", $iWidth, $iHeight) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp", $hWindow) Global $hEdit1 = GUICtrlCreateEdit("Press Ctrl+A to select all", 5, 5, $iWidth - 10, $iHeight/2 - 7) Global $hEdit2 = GUICtrlCreateEdit("Press Ctrl+A to select all", 5, $iHeight/2 + 4, $iWidth - 10, $iHeight/2 - 7) ; --- Accelerator --- Global $avAccelerators[1][2] = [ _ ["^a", _GUICtrlSetOnEvent(GUICtrlCreateDummy(), "SelectAll")] _ ] GUISetAccelerators($avAccelerators, $hWindow) ; --- Show --- GUISetState(@SW_SHOW, $hWindow) While 1 Sleep(1000) WEnd ; --- Functions --- Func SelectAll() _GUICtrlEdit_SetSel(ControlGetHandle($hWindow, "", ControlGetFocus($hWindow)), 0, -1) EndFunc Func ExitApp() Exit EndFunc Func _GUICtrlSetOnEvent($nCtrlID, $sFunction) If GUICtrlSetOnEvent($nCtrlID, $sFunction) Then Return $nCtrlID Return 0 EndFuncThe code is a little sloppy/lazy in that it doesn't bother to verify the control handle being passed into _GUICtrlEdit_SetSel(), but it gets the point across. You can be more specific about how you want it to behave with something like:Func SelectAll() Switch ControlGetHandle($hWindow, "", ControlGetFocus($hWindow)) Case GUICtrlGetHandle($hEdit1) _GUICtrlEdit_SetSel($hEdit1, 0, -1) Case GUICtrlGetHandle($hEdit2) _GUICtrlEdit_SetSel($hEdit2, 0, -1) EndSwitch EndFunc Edited January 17, 2009 by -Ultima- [ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ] Link to comment Share on other sites More sharing options...
NerdFencer Posted January 17, 2009 Share Posted January 17, 2009 Here is the easiest way that I can think of... #Include <GuiEdit.au3> #include <WindowsConstants.au3> HotKeySet("^a", "SelectAll") $Gui = GUICreate ("Window",300,150) $TextBox = GUICtrlCreateEdit("Some Text",5,5,290,140,BitOR($ES_WANTRETURN, $WS_VSCROLL)) GUISetState(@SW_SHOW) While Not(GUIGetMsg()==-3) Sleep(10) WEnd Func SelectAll() _GUICtrlEdit_SetSel($TextBox, 0, StringLen(GUICtrlRead($TextBox))) EndFunc _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
-Ultima- Posted January 17, 2009 Share Posted January 17, 2009 (edited) Indeed, HotKeySet() by itself does shorten the code length slightly, but it comes with ugly behavior when you need to switch application focus. That is, if you were to switch to some other application after HotKeySet(), Ctrl+A (a very common Windows application hotkey) would no longer work. There are, of course, ways to "hack" around that by releasing the hotkey when the window loses focus, and re-registering the hotkey when it regains focus, but it's rather ugly (I've tried/done it before). GUISetAccelerators() is a lifesaver in that respect (and is the more correct tool for the job). Edited January 17, 2009 by -Ultima- [ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ] Link to comment Share on other sites More sharing options...
Robjong Posted January 17, 2009 Share Posted January 17, 2009 (edited) hey, This is also works, but it might be the 'hack' you were talking about.... Global Const $WM_ACTIVATEAPP = 0x001C Global $hGUI = GUICreate("HotKey Active") GUISetState() _HotKeyActive() ; call the func to set the hotkeys GUIRegisterMsg($WM_ACTIVATEAPP, "_HotKeyActive") ; register our func to get called whenever app goes active or inactive While 1 If GUIGetMsg() == -3 Then Exit ; $GUI_EVENT_CLOSE Sleep(25) WEnd Func _HotKeyActive() ; this func get called when the app goes active or inactive If WinActive($hGUI) Then ; if the window is active, set hotkeys HotKeySet("a","_A");Set Else ; if the window is not active, unset hotkeys HotKeySet("a");Unset EndIf EndFunc Func _A() MsgBox(64, 'HotKey', "Hotkeys are cool.") EndFunc Edited January 17, 2009 by Robjong Link to comment Share on other sites More sharing options...
Armand Posted January 17, 2009 Author Share Posted January 17, 2009 (edited) @Robjong yeps... that's exactly what he meant.... i've also done it with several other scripts... but was wandering if there is a better way around it ... now that we know there isn't ... Laters Thanks to anyone who has read it / replied! Edited January 17, 2009 by Armand [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! 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