ponchato Posted May 15, 2009 Share Posted May 15, 2009 (edited) I'm pretty new to scripting, especially with Autoit. The point of this script (other than to get experience and because writing scripts is actually kind of fun) is to send tab, then send down (repeatedly) until I press a key on the keyboard. I've made... little progress, to say the least. HotKeySet("{PAUSE}", "Paused") Do Send("{TAB}") Send("{DOWN}") Until Func Paused Func Paused() While Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd EndFunc As you can see, I'm missing some stuff. Now, the questions. 1) How do I make it perform a 'do...until' loop until the 'Paused' function is... uh, complete? That is, how do I make it loop until I press the 'Pause' key? 2) Can 'until' use a function to stop the loop in the first place? If not, I'm going at this whole script incorrectly. 3) Can I run the script, pause it, go to the window I need it run in, then start it again? 4) Instead of looping until I tell it to stop, is there a way to have it loop, say, 30 times then stop? Sorry if I made mistakes that make you cringe because of their simplicity. I'm new to scripting, so cut me some slack. Edited May 15, 2009 by ponchato Link to comment Share on other sites More sharing options...
aggixx Posted May 15, 2009 Share Posted May 15, 2009 (edited) I'm pretty new to scripting, especially with Autoit. The point of this script (other than to get experience and because writing scripts is actually kind of fun) is to send tab, then send down (repeatedly) until I press a key on the keyboard. I've made... little progress, to say the least. HotKeySet("{PAUSE}", "Paused") Do Send("{TAB}") Send("{DOWN}") Until Func Paused Func Paused() While Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd EndFunc As you can see, I'm missing some stuff. Now, the questions. 1) How do I make it perform a 'do...until' loop until the 'Paused' function is... uh, complete? That is, how do I make it loop until I press the 'Pause' key? 2) Can 'until' use a function to stop the loop in the first place? If not, I'm going at this whole script incorrectly. 3) Can I run the script, pause it, go to the window I need it run in, then start it again? 4) Instead of looping until I tell it to stop, is there a way to have it loop, say, 30 times then stop? Sorry if I made mistakes that make you cringe because of their simplicity. I'm new to scripting, so cut me some slack. I have no idea what that Do Until stuff is about, but here is how I would do it: HotKeySet("{SPACE}", "Pause") HotKeySet("{ENTER}", "Resume") Func Pause() $run = false EndFunc Func Resume() $run = true EndFunc $run = true While 1 If $run = true Then Send("{TAB}") Send("{DOWN}") EndIf WEnd Edited May 15, 2009 by aggixx Link to comment Share on other sites More sharing options...
TurionAltec Posted May 15, 2009 Share Posted May 15, 2009 (edited) Until Func Paused While Paused Uh these two logic checks don't make any sense In the first case, even though "Func Paused" doesn't make sense as a logic check, once the "Until" 's check is satisfied it will start executing stuff after the do until loop, which in this case is nothing and the program will terminate. In the While Paused, in addition to "Paused" not being a valid expression, there's nothing that would allow the expression to be false and thus exit the loop. 4) Instead of looping until I tell it to stop, is there a way to have it loop, say, 30 times then stop? For-next loop. It's it's most basic form: For $i = 1 to 30 Send("{TAB}") Send("{DOWN}") Next I would make one small modification to aggixx's code: HotKeySet("{SPACE}", "Pause") HotKeySet("{ENTER}", "Resume") Func Pause() $run = false EndFunc Func Resume() $run = true EndFunc $run = true While 1 If $run = true Then Send("{TAB}") Send("{DOWN}") Else sleep(10) EndIf WEnd I added a sleep in the "else" case to keep the script from chewing up CPU time. Edited May 15, 2009 by TurionAltec Link to comment Share on other sites More sharing options...
Minikori Posted May 15, 2009 Share Posted May 15, 2009 Your guys' pause stuff is weird. Try this for you script: Global $Paused HotKeySet("{PAUSE}", "Pause") While 1 Send("{TAB}") Send("{DOWN}") WEnd Func Pause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip("Script is paused.") WEnd EndFunc For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com Link to comment Share on other sites More sharing options...
ponchato Posted May 15, 2009 Author Share Posted May 15, 2009 Woah, thanks everyone. While $Paused Sleep(100) ToolTip("Script is paused.") WEnd Just to clarify, the Sleep(100) means that, when it's paused, it stays off for a tenth of a second, runs through to the beginning of 'While' and repeats the 100 millisecond sleep until the script is started again, right? It's hard to describe a script in plain English. Link to comment Share on other sites More sharing options...
stampy Posted May 15, 2009 Share Posted May 15, 2009 yes. The sleep(100) will just allow a little down time to keep the script from consuming the CPU. 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