Jump to content

Help with a loop please!


huldu
 Share

Recommended Posts

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!!!"

Link to comment
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!!!"

Link to comment
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 :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...