Sign in to follow this  
Followers 0
huldu

Help with a loop please!

5 posts in this topic

Ive made a simple program that starts when the user clicks pause/break, it works perfectly. However im trying to figure out how to do a switch. When you click on pause/break the program starts, if you click it again it would stop, if you click it again it would start and so on.

It got quite confusing and i just cant get it right no matter what i do atm... :)


"I'm paper, rock is fine, nerf scissors!!!"

Share this post


Link to post
Share on other sites



Do a search for "pause script" or "unpause script" - this issue was discussed countless times and I'm sure you will get plenty of results.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Ill search for that, thanks :)

I did come up with something tho, but is it a good way to do this on/off thing?

HotKeySet("{PAUSE}", "Start")

$a = 1
$b = 0
$c = 0
While 1
    $a = 1
    
    Do
        ToolTip("Started - Loops: " & $b,0,0)
        $b = $b + 1
        Sleep(100)
        $c = 0
    Until $a = 0
    
    $a = 1
    
    Do
        ToolTip("Stopped - Loops: " & $c,0,0)
        $c = $c + 1
        $b = 0
        Sleep(100)
    Until $a = 0
WEnd


Func Start()
    $a = 0
EndFunc

"I'm paper, rock is fine, nerf scissors!!!"

Share this post


Link to post
Share on other sites

It might work but there is a more efficient way ... got it straight from "pause" search

Global $Paused = False

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "_Quit")

While 1
    If $Paused Then
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    Else
        ToolTip("")
    EndIf
WEnd

Func TogglePause()
    $Paused = Not $Paused
EndFunc   ;==>TogglePause

Func _Quit()
    Exit
EndFunc

... CREDITS PsaltyDS ...

post: http://www.autoitscript.com/forum/index.ph...64&hl=pause


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

It might work but there is a more efficient way ... got it straight from "pause" search

Func TogglePause()

$Paused = Not $Paused

EndFunc ;==>TogglePause

OK,That's what he needed.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0