 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Tue Jul 08, 2008 4:41 am Post subject: Pause and Continue Code |
|
|
I'm just an idiot looking for a way to press F2 to stop the script until F2 is pressed again.
So, Right now, (for example)its sending, "Hello my name is %NAME1%, And I like blahblahblah", but if I press F2 While its at "Hello", the script pauses. I press F2 again, and it continues to type "my name is.. ect"
I'm quite sure there is a simple way to do this, but my creativity hasn't gotten me pass this test of 1337ness. =P
Thanks guys.
And F2 is just an example button. |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 211 Location: Minnesota, USA
|
Posted: Tue Jul 08, 2008 4:46 am Post subject: |
|
|
|
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jul 08, 2008 4:55 am Post subject: |
|
|
Hmm.
But it pauses at first, I like that, but once you hit F2 to un-pause it the script doesnt work anymore. |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 211 Location: Minnesota, USA
|
Posted: Fri Jul 11, 2008 3:46 am Post subject: |
|
|
really? It seems to work for me. Tested it with | Code: | Loop {
MsgBox ZOMG!!
sleep 500
}
F2::Pause |
_________________ Unless otherwise stated, all code is untested
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
OrelseIamfired
Joined: 13 Mar 2006 Posts: 60 Location: Ottawa, Canada
|
Posted: Fri Jul 11, 2008 11:03 pm Post subject: |
|
|
Hi,
I have a similar requirement, but I need a hotkey routine more complicated than the simple F2:: example given in this thread. I have an If/Else statement in my hotkey routine, and pressing F2 twice does not unpause the script. I give the example below for discussion.
| Code: | Loop
{
SplashTextOn, 200,100,Timer status, Timed out (%A_Index%).
Sleep, 1000
SplashTextOff
Sleep, 1000
}
ExitApp
F2::
If True
Pause
Return
|
If I remove the If statement, then it works as in Slanter's code. Does anyone know how to make this work with the If statement?
/ Louis |
|
| Back to top |
|
 |
OrelseIamfired
Joined: 13 Mar 2006 Posts: 60 Location: Ottawa, Canada
|
Posted: Fri Jul 11, 2008 11:37 pm Post subject: |
|
|
Never mind, I got my script to work using some of the Pause command's parameters. This is the my sketch script.
| Code: | Loop
{
SplashTextOn, 200,100,Timer status, Timed out (%A_Index%).
Sleep, 1000
SplashTextOff
Sleep, 1000
}
ExitApp
F2::
If True
Pause, Toggle, 1
Return
|
/ Louis |
|
| Back to top |
|
 |
phfjeld
Joined: 05 Nov 2006 Posts: 47 Location: Norway
|
Posted: Fri Jul 11, 2008 11:47 pm Post subject: |
|
|
[Moderator: Removed top-post]
Well, "True" is always true, and therefore you'll need a control variable.
What do you want to do by the way?
I can't really see why you want a if/else-sentence where you're saying. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2525 Location: Australia, Qld
|
Posted: Sun Jul 13, 2008 8:45 am Post subject: |
|
|
If you pause from a hotkey, the hotkey thread itself is paused. Normally each hotkey can run only one thread at a time, but AutoHotkey makes an exception for hotkeys beginning with the Pause command.
Try adding the following before the hotkey:
| Code: | | #MaxThreadsPerHotkey 2 |
|
|
| Back to top |
|
 |
OrelseIamfired
Joined: 13 Mar 2006 Posts: 60 Location: Ottawa, Canada
|
Posted: Mon Jul 14, 2008 7:18 pm Post subject: |
|
|
Hi phfjeld,
The script that I included in my message was there only for discussion. I removed all irrelevant detail from my working script, and left the fundamental parts necessary for asking my question and having my problem resolved. The control variable for the if statement was not pertinent to my question, only the if statement was.
Because you asked, I present the following as a better skeleton, a mock-up, of my working script, but still with much detail excluded.
| Code: | paused := False
Loop
{
SplashTextOn, 200,100,Timer status, Timed out (%A_Index%).
Sleep, 1000
SplashTextOff
Sleep, 1000
If done
break
}
ExitApp
Pause::
If paused
{ ; Release the script.
WriteMsgToLog("The user released the script.") ; at such and such a time.
Gui, Destroy ; Clear the message to the user.
If timerIsRunning ; Resume the timer if it was running.
SetTimer, Connected, On
paused := False
Pause, Toggle, 1
}
Else
{ ; Pause the script.
SetTimer, Connected, Off ; Stop the timer.
WriteMsgToLog("The user paused the script.") ; at such and such a time.
paused := True
; Display a message to the user.
Gui, -SysMenu
Gui, Add, Text, x20 y15 w420 h120
, Press Pause to resume the Monitor
. `nAppuyez sur la touche Pause pour reprendre le Moniteur.
Gui, Show, x269 y286 h80 w450, Monitor / Moniteur
Pause, Toggle, 1
}
Return
|
As you can see, the if-else statement is important to my working script. However, as I mentioned in my previous message, I no longer need help because I have a solution for my problem.
/ Louis |
|
| Back to top |
|
 |
OrelseIamfired
Joined: 13 Mar 2006 Posts: 60 Location: Ottawa, Canada
|
Posted: Mon Jul 14, 2008 7:34 pm Post subject: |
|
|
Hi Lexikos,
Thank you for telling me about #MaxThreadsPerHotkey. I like that better than what I did.
/ Louis |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|