yxrkt Posted March 20, 2007 Posted March 20, 2007 when im running several scripts with the same hotkeys, i cant get them to respond only when the gui is active. im posting 2 scipts im working on . can someone figure out what im doing wrong ? yep ive tried this code. Func catchguikey() Local $opt = Opt("WinTitleMatchMode", 4) If WinGetHandle("active") = $gui Then If @HotKeyPressed = "{ENTER}" Then ;Do something here ToolTip("Key Pressed") Sleep(1000) ToolTip("") EndIf Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "catchguikey") EndIf Opt("WinTitleMatchMode", $opt) EndFunc ~yxrkt
therks Posted March 20, 2007 Posted March 20, 2007 This is the problem with not being able to set GUI specific hotkeys (accelerators). Even though this method works fine in some instances, as soon as you try and use the same hotkey somewhere else (or that hotkey is taken by another application even), then you run into problems, because you can't use the same hotkey twice (which should be obvious). For example, try running this script twice: If HotKeySet('{ESC}', 'exitMe') Then While 1 Sleep(100) WEnd Else MsgBox(16, 'Error', 'Cannot set hotkey. Already in use.') Exit EndIf Func exitMe() Exit EndFunc HotKeySet returns 0 if the key is unable to be set. I think I'm going to go find that topic that Valik started and bump it. Who knows that someone might do something with it finally. My AutoIt Stuff | My Github
yxrkt Posted March 20, 2007 Author Posted March 20, 2007 thanks! i thought i could unbind the hotkey and send it to next script. but ill use this GUI specific hotkey from now. ~yxrkt #include <Misc.au3> Opt("WinTitleMatchMode", 3) Opt("GUICloseOnESC", 0) func _HellOfaLotBetterGUISpecificHotKeySet($a,$B) If _IsPressed($a, $dll) and WinActive($random) Then sleep(200) call($B) else EndIf endfunc dim $lada[6666] const $random = random(1,666,1) $lada[$random] = GUICreate($random) GUISetState () Func exitMe() DllClose($dll) exit 0 EndFunc func back() msgbox(0,'you pressed','backspace') EndFunc $dll = DllOpen("user32.dll") While 1 _HellOfaLotBetterGUISpecificHotKeySet("1B","exitMe") _HellOfaLotBetterGUISpecificHotKeySet("08","back") Sleep ( 10 ) WEnd
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