Guest goflyapig Posted October 17, 2004 Share Posted October 17, 2004 (edited) I'm trying to set a hotkey that only does something in a certain program, and ignores it in other programs, but I couldn't figure it out (is it possible?). I tried doing something like this: HotKeySet("^c", "someFunc") While 1 Sleep(100) WEnd Func someFunc() If NOT WinActive("Foo") Then Send("^c") Return EndIf ToolTip("You pressed Ctrl+C in Foo", 0, 0) EndFunc What I wanted was for Ctrl+C put up a tooltip if the window was named Foo, and otherwise sent Ctrl+C back to the program to do the usual. What I got was a Stack Overflow, because sending Ctrl+C just caused triggered the hotkey again. Is there a way to do this? Edited October 17, 2004 by goflyapig Link to comment Share on other sites More sharing options...
Guest goflyapig Posted October 17, 2004 Share Posted October 17, 2004 Arggh. I figured it out. Nevermind. Link to comment Share on other sites More sharing options...
CyberSlug Posted October 17, 2004 Share Posted October 17, 2004 See the HotKeySet Remarks...There are two techniques:One:While 1 If WinActive("Foo") Then HotKeySet("^c", "someFunc") Else HotKeySet("^c");un-register hotkey EndFunc WendTwo:Func someFunc() If NOT WinActive("Foo") Then HotKeySet("^c") ;unregister Send("^c") HotKeySet("^c", "someFunc") ;re-register EndIfEndFunc Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
ezzetabi Posted October 17, 2004 Share Posted October 17, 2004 (edited) To avoid useless activations and deactivations I advice you tring something like: Global $bHook = 0 AdlibEnable('_keyhooking',250) Func _keyhooking() Select Case WinActive("Foo") AND $bHook = 0 $bHook = 1 HotKeySet("^c", "someFunc") Case Not WinActive("Foo") AND $bHook = 1 $bHook = 0 HotKeySet("^c",) EndSelect EndFunc Edited October 17, 2004 by ezzetabi 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