Sign in to follow this  
Followers 0
jmoney

Pausing a Script with a Button

3 posts in this topic

#1 ·  Posted (edited)

So I have written a small script, but I would like to add the ability to pause it when I press a particular key. Then Unpause it when i press the key again. Here is the script so far.

While 1
    Sleep(300)
    $var = PixelGetColor( 637, 446 )
    If $var = 0x55291B Then Send("{4}")
    If $var = 0x3B0C08 Then Send("{2}")
    If $var = 0x967928 Then Send("{9}")
    If $var = 0x7B0000 Then Send("{d}")
    If $var = 0x1C0500 Then Send("{5}")
    If $var = 0xF1CC7B Then Send("{0}")
    If $var = 0x4A292C Then Send("{a}")
    If $var = 0xCD5113 Then Send("{3}")
    If $var = 0xB597DA Then Send("{F3}")
    WEnd

TIA

Edited by jmoney

Share this post


Link to post
Share on other sites



So I have written a small script, but I would like to add the ability to pause it when I press a particular key. Then Unpause it when i press the key again. Here is the script so far.

While 1
    Sleep(300)
    $var = PixelGetColor( 637, 446 )
    If $var = 0x55291B Then Send("{4}")
    If $var = 0x3B0C08 Then Send("{2}")
    If $var = 0x967928 Then Send("{9}")
    If $var = 0x7B0000 Then Send("{d}")
    If $var = 0x1C0500 Then Send("{5}")
    If $var = 0xF1CC7B Then Send("{0}")
    If $var = 0x4A292C Then Send("{a}")
    If $var = 0xCD5113 Then Send("{3}")
    If $var = 0xB597DA Then Send("{F3}")
    WEnd

TIA

Try this:

Global $boolPause = True
HotKeySet("{PAUSE}" , "SetPause"
While 1
    Sleep(300)
    If $boolPause Then
        $var = PixelGetColor( 637, 446 )
        If $var = 0x55291B Then Send("{4}")
        If $var = 0x3B0C08 Then Send("{2}")
        If $var = 0x967928 Then Send("{9}")
        If $var = 0x7B0000 Then Send("{d}")
        If $var = 0x1C0500 Then Send("{5}")
        If $var = 0xF1CC7B Then Send("{0}")
        If $var = 0x4A292C Then Send("{a}")
        If $var = 0xCD5113 Then Send("{3}")
        If $var = 0xB597DA Then Send("{F3}")
    EndIf
WEnd
Func SetPause()
    $boolPause = Not $boolPause
EndFunc

[size="2"] "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian Kernighan[/size]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Taken from HotKeySet example in docs

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")

;;;; Body of program would go here ;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc
<br>Change the key to whatever suits your need<br> Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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