| View previous topic :: View next topic |
| Author |
Message |
playfullscientist
Joined: 20 Apr 2005 Posts: 22 Location: Princeton NJ USA
|
Posted: Tue Apr 26, 2005 6:19 pm Post subject: Pause On/Off |
|
|
Hi...Suppose you have set Pause On. How can you set Pause Off by clicking the Enter key (or some other key)? I assume no code can run during Pause On. Am I correct? Thanks. Playfullscientist _________________ I am a playful scientist |
|
| Back to top |
|
 |
TeknoMusicMan
Joined: 14 Apr 2005 Posts: 188 Location: Wisconsin, USA
|
Posted: Tue Apr 26, 2005 6:24 pm Post subject: |
|
|
| Code: | Pause::Pause, on
{Enter}:: Pause, off
p::Pause, toggle |
I think if I am remembering correctly if the hotkey is executing the pause command while the script is pause ahk will still let it run.
Check the Pause Command |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Tue Apr 26, 2005 6:36 pm Post subject: |
|
|
As stated in the documentation, "New hotkeys can still be launched while the script is paused." This means that the currently running thread will be paused, as well as any threads waiting to run after it, but new threads can still be launched by the user. For instance, this script will show the first msgbox, then once you close it, it will pause until you press Space, at which time it will show the second one.
| Code: | msgbox,MsgBox 1
pause,on
msgbox,MsgBox 2
exitapp
~space::pause,off |
And this one will allow you to delay the coming off each msgbox; they will follow each other instantly unless you close one with Space. Press space again to unpause and continue execution.
| Code: | msgbox,MsgBox 1
msgbox,MsgBox 2
msgbox,MsgBox 3
msgbox,MsgBox 4
msgbox,MsgBox 5
msgbox,MsgBox 6
exitapp
~space::pause |
Experiment with it on your own, you never know what you might learn. |
|
| Back to top |
|
 |
playfullscientist
Joined: 20 Apr 2005 Posts: 22 Location: Princeton NJ USA
|
Posted: Tue Apr 26, 2005 6:40 pm Post subject: Pause On/Off |
|
|
Hi...I tried this script:
Pause On
Enter::Pause Off
It seems to work fine. However, when I place it in two different point in the same script, the program fails to compile. Do I have to write this pair of lines in a subroutine? Thanks. Playfullscientist _________________ I am a playful scientist |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Tue Apr 26, 2005 7:43 pm Post subject: |
|
|
| Could you post the script, please? |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5390 Location: /b/
|
Posted: Tue Apr 26, 2005 7:50 pm Post subject: Re: Pause On/Off |
|
|
| playfullscientist wrote: | Pause On
Enter::Pause Off
It seems to work fine. However, when I place it in two different point in the same script, the program fails to compile. Do I have to write this pair of lines in a subroutine? Thanks. Playfullscientist |
That's strange, I never known scripts to work when they don't if compiled. Maybe you'll find the following useful: #Persistent, #UseHook, #InstallKeybdHook. _________________
 |
|
| Back to top |
|
 |
playfullscientist
Joined: 20 Apr 2005 Posts: 22 Location: Princeton NJ USA
|
Posted: Tue Apr 26, 2005 7:55 pm Post subject: Pause On/Off |
|
|
Hi...Let me explain more carefully. If I use the lines
Pause On
Enter::Pause Off
only once in the script, then it works fine. If
I use the same two lines a second time elsewhere
in the program, it fails to compile (Error Message).
Thanks. Playfullscientist _________________ I am a playful scientist |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5390 Location: /b/
|
Posted: Tue Apr 26, 2005 7:58 pm Post subject: Re: Pause On/Off |
|
|
You'll obviously get an error message if you assign a routine to the same hotkey more than once. You could use #Persistent, the hotkey once anywhere in the script and the Pause command itself wherever. _________________
 |
|
| Back to top |
|
 |
|