| View previous topic :: View next topic |
| Author |
Message |
aDot Guest
|
Posted: Mon Jun 28, 2004 3:21 pm Post subject: looking for an on/off toggle |
|
|
Hi,
I have little programming experience and stumbled over the following problem that I cannot resolve myself:
I would like to write a script that can be started with one of the function keys, that is looping a certain command with a specific sleep time. So far no problem, but here is my challenge:
The loop should stop if the user presses another function key, else it should continue to loop endless.
Is that possible? If yes, could you give me a hint on that?
Thanks from a very beginner.
aDot |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Mon Jun 28, 2004 3:30 pm Post subject: |
|
|
E.g the F12 key:
|
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Mon Jun 28, 2004 3:33 pm Post subject: |
|
|
shouldn't abort the script at all, correct ?!
~F12::break |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Mon Jun 28, 2004 3:41 pm Post subject: |
|
|
Well, seems to be complete nonsense what I've written above
Sorry.  |
|
| Back to top |
|
 |
aDot Guest
|
Posted: Mon Jun 28, 2004 3:41 pm Post subject: Thank you |
|
|
| Thanks a lot for the quick help - will try it tonight. |
|
| Back to top |
|
 |
beardboy
Joined: 02 Mar 2004 Posts: 444 Location: SLC, Utah
|
Posted: Mon Jun 28, 2004 3:44 pm Post subject: |
|
|
To not kill the script, just the running loop you could do something like this:
| Code: | F1::
loopkill = 0 ; Reset variable to kill loop
Loop
{
; Have normal commands for loop.
Sleep, 1000
if loopkill = 1
break
}
return
F2::
loopkill = 1
return |
thanks,
beardboy |
|
| Back to top |
|
 |
silentblood
Joined: 19 Jun 2004 Posts: 36
|
Posted: Fri Jul 02, 2004 7:59 pm Post subject: |
|
|
| If I am reading this right will it only stop once it reaches the if command in the script so it would only pause once it got to that if command? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Jul 02, 2004 8:20 pm Post subject: |
|
|
| That's right, but you can repeat the same IF statement in multiple places throughout the body of the loop -- notably after any operation that takes a long time -- if you need the stop key to be more immediate. |
|
| Back to top |
|
 |
|