Suppose a program "spins on" in a loop.
When the spacebar is pressed, the program is toggle from run to pause and
next time the spacebar is pressed, the program is toggle from pause to run and so on.
Is the only way to use SetTimer?
How?
toggle Pause - possible? Topic is solved
Re: toggle Pause - possible?
Describe what you would like to happen, step by step, including an example.
Re: toggle Pause - possible?
Maybe this can be a test program?
The first time the spacebar is pressed, the loop is paused
Next time the spacebar is pressed, the program (the loop) is run again.
(and so on)
Code: Select all
#SingleInstance force
Loop 30
{ Sleep 1000
ToolTip % " " A_Index "`n`nPress spacebar`nto stop / start"
}
MsgBox Ready!
ExitApp
ESC::ExitApp
Next time the spacebar is pressed, the program (the loop) is run again.
(and so on)
Re: toggle Pause - possible?
I see no such hotkey in your script.
Re: toggle Pause - possible?
No - (is hotkey a problem?)
Re: toggle Pause - possible?
I do not know whether AHK is a problem, because you have not provided a step-by-step description of what should happen. Are you just trying to create a toggle for a loop?
Code: Select all
n := 0
Space::
SetTimer, Go, % (on := !on) ? 1000 : "Off"
SoundBeep, 1000 + 500 * on
Return
Go:
ToolTip, xyz
If (++n < 30)
Return
MsgBox Ready!
ExitApp
-
- Posts: 4412
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: toggle Pause - possible? Topic is solved
Code: Select all
#SingleInstance force
Loop 30
{ Sleep 1000
ToolTip % " " A_Index "`n`nPress spacebar`nto stop / start"
}
MsgBox Ready!
ExitApp
Space::Pause
Re: toggle Pause - possible?
That's much easier!
Re: toggle Pause - possible?
Yes!
Thank you!
Thank you!
Re: toggle Pause - possible?
I try to do something like this
The program is paused but cannot be restarted with the spacebar
edit .: And I like the Beep (by @mikeyww above)
Code: Select all
Space::
GuiControl 1:, PauseTxt, (spacebar = run again)
Pause Toggle
Return
edit .: And I like the Beep (by @mikeyww above)
-
- Posts: 4412
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: toggle Pause - possible?
Code: Select all
Space::
Pause,, 1
SoundBeep
Return
Re: toggle Pause - possible?
It became a combination of both solutions...
First I tried to use A_IsPaused to select different tones when the program is stopped or started (but did not succeed)
First I tried to use A_IsPaused to select different tones when the program is stopped or started (but did not succeed)
Code: Select all
Loop 30
{ Sleep 1000
ToolTip % "Running .: " A_Index "`nA_IsPaused .: " A_IsPaused "`n" on
}
Space::
Pause,, 1
(on := !on) ? 1000 : "Off"
SoundBeep, 1000 + 500 * on
ToolTip % "A_IsPaused .: " A_IsPaused "`n" on
Return
-
- Posts: 4412
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: toggle Pause - possible?
Code: Select all
Loop 30
{ Sleep 1000
ToolTip % "Running .: " A_Index "`nA_IsPaused .: " A_IsPaused
}
Space::
Pause,, 1
SoundBeep, 1000 + 500 * A_IsPaused
ToolTip % "A_IsPaused .: " A_IsPaused
Return
Re: toggle Pause - possible?
Thanks!
Who is online
Users browsing this forum: Google [Bot], Kintaro-OEx, Marium0505, Trunks298 and 169 guests