FireChrome Posted December 17, 2012 Share Posted December 17, 2012 Hey all! This is probably the most simple request in the forum that will make most of the experienced users go "DUH!" Being a total noobie I'm still trying to figure things out. Basically wanted to create a hotkey that will launch a program, then run an infinite loop within the program until the hotkey is pressed again. So far I've made this...and while it launches notepad, it won't enter the A, B, C text. Any tips? Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Dim $Hotkey HotKeySet("{F9}","Start") Func Start() $Hotkey = NOT $Hotkey If $Hotkey Then ToolTip('Hotkey was pressed',0,0) While $Hotkey Send("{A}") Send("{B}") Send("{C}") WEnd ToolTip("") EndFunc Link to comment Share on other sites More sharing options...
bogQ Posted December 17, 2012 Share Posted December 17, 2012 (edited) you need some empty loop to keep the script alive or the script will exit as soon as its done waiting for windowso below HotKeySet add another empty while 1 loop to keep it aliveand instead Send("{A}") you can use Send("A") or Send("ABC") Edited December 17, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
FireChrome Posted December 17, 2012 Author Share Posted December 17, 2012 (edited) Thanks! the program launches and the text repeats...but pressing the hotkey again doesn't stop the loop, I think I'm missing a condition to exitloop? Edited December 17, 2012 by FireChrome Link to comment Share on other sites More sharing options...
bogQ Posted December 18, 2012 Share Posted December 18, 2012 (edited) some ideas about your code can be declare some var on top of the script to be 0 on every hotkey press set it to change betwean switch var case 0 var = 1 and case 1 var = 0 and add code according to it and you can do empty loop as func and afer var is set return it to the empty loop Edited December 18, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. 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