Traddles Posted February 20, 2007 Share Posted February 20, 2007 Hi, I have a program which sets a hotkey... well let me just show you an example of what I want to do: HotKeySet("^!r", "MyFunction") while (true) sleep(100) ; do nothing wend func MyFunction() if (WinActive("Notepad") then ; do some nifty stuff else ; can I just pass on the "^!r" to whatever window DOES have focus? endif endFunc I've tried just putting "Send("^!r")" in the else statement but that does NOT work. it just sets up a recursive loop that drives my cpu up to 100% very quickly. So, do you guys know of anyway to pass on a hotkey if I change my mind about captureing it like this? Link to comment Share on other sites More sharing options...
FiNAlzFiNAle Posted February 20, 2007 Share Posted February 20, 2007 I think what you want is this : CODEWhile 1 If WinActive ("Notepad") Then HotKeySet ("^!r", "NotepadFunction") ; set the HotKey for NotepadFunction Else HotKeySet ("^!r") ; release the HotKey EndIf WEnd Func NotepadFunction() ; do your nifty stuff here EndFunc Link to comment Share on other sites More sharing options...
Shevilie Posted February 20, 2007 Share Posted February 20, 2007 (edited) This should do the trick.. You have to unset the hotkey before Send or else it will launch the function again in an endless loop HotKeySet("^!r", "MyFunction") while (true) sleep(100) ; do nothing wend func MyFunction() if (WinActive("Notepad") then ; do some nifty stuff else HotKeySet("^!r") Send("^!r") HotKeySet("^!r", "MyFunction") endif endFunc Edited February 20, 2007 by Shevilie Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit 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