Bert Posted October 26, 2005 Posted October 26, 2005 I'm trying to figure out if there is a way to have a hotkey work only while a window is active. Does anyone have a snippit of code that does this? I currently use hotkeyset using a ctrl + # to run my shortcuts. I wanted to use the function keys, but only while the window that I want to work with is the one that has focus. The Vollatran project My blog: http://www.vollysinterestingshit.com/
Valuater Posted October 26, 2005 Posted October 26, 2005 (edited) heres an idea Dim $runner = 0 HotKeySet("{F8}", "runner") While 1 If $runner = 1 And Not WinExists(" my program") Then HotKeySet("{F8}", "runner") $runner = 0 EndIf Sleep(3000) WEnd Func runner() Run(" My program.exe") HotKeySet("{F8}", "do something else") $runner = 1 EndFunc 8) EDIT made it so that it doesn't continually set hot key Edited October 26, 2005 by Valuater
LxP Posted October 31, 2005 Posted October 31, 2005 You might also be able to do it this way if I understand you correctly: Opt('WinWaitDelay', 0) Local $Win = 'My window title' Local $Hotkey = '{F6}' ; Ensure that the window exists before continuing WinWait($Win) While WinExists($Win) WinWaitActive($Win) HotkeySet($Hotkey, 'ProcessHotkey') WinWaitNotActive($Win) HotkeySet($Hotkey) WEnd Func ProcessHotkey() ; ... 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