Jump to content

How to pause this script


Recommended Posts

HotKeySet ("{ENTER}", "Start")
HotKeySet ("{ESC}", "_Paused")

While 1
         Sleep(250)
WEnd

Func Start()
         While 1
                  $pxs = PixelSearch(0,0,1919.1078,959.541,0x01FF00)
                  If isArray($pxs) then
                         MouseMove($pxs[0],$pxs[1], 0)
                         MouseClick("Left")
                  EndIf
         WEnd
EndFunc

Func  _Paused()
         Paused

EndFunc

 

Obrigado desde já!!!

Link to comment
Share on other sites

  • Moderators

@alanzarb I have moved your thread to the proper forum; please pay attention to where you post in the future. Each forum tells you what it is for at the top.

Per your question, can you explain more about what app you're trying to automate? There is doubtless a better way to do this.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

just have a control variable in your loop, and have your hotkey function (pause) toggle that value.

HotKeySet ("{ENTER}", "Start")
HotKeySet ("{ESC}", "_Paused")
    While 1
         Sleep(250)
WEnd
    Func Start()
              $notPaused = true
         While 1
                  $pxs = PixelSearch(0,0,1919.1078,959.541,0x01FF00)
                  If isArray($pxs) and $notPaused then
                         MouseMove($pxs[0],$pxs[1], 0)
                         MouseClick("Left")
                  EndIf
         WEnd
EndFunc
    Func  _Paused()
         $notPaused = !$notPaused
    EndFunc

syntax may be wrong, but that's what you're going for. I haven't kept up with this language in a while, so i'm not sure if you can do !$notPaused like that, but if not you can just do an if $notPaused then $notPaused = false else $notPaused = true endif or whatever

Link to comment
Share on other sites

1 hour ago, seandisanti said:

just have a control variable in your loop, and have your hotkey function (pause) toggle that value.

 

HotKeySet ("{ENTER}", "Start")
HotKeySet ("{ESC}", "_Paused")
    While 1
         Sleep(250)
WEnd
    Func Start()
              $notPaused = true
         While 1
                  $pxs = PixelSearch(0,0,1919.1078,959.541,0x01FF00)
                  If isArray($pxs) and $notPaused then
                         MouseMove($pxs[0],$pxs[1], 0)
                         MouseClick("Left")
                  EndIf
         WEnd
EndFunc
    Func  _Paused()
         $notPaused = !$notPaused
    EndFunc

 

syntax may be wrong, but that's what you're going for. I haven't kept up with this language in a while, so i'm not sure if you can do !$notPaused like that, but if not you can just do an if $notPaused then $notPaused = false else $notPaused = true endif or whatever

Where is the functionality for once notPaused = true??

Edit: Ah nevermind I see where you made it not update Mouse Move..

Something like this..

Global Enum $iState_None = 0, $iState_Paused = 1, $iState_Running = 2
Global $iState = $iState_None

Global $sDots = "."

HotKeySet("{ENTER}", _Start)
HotKeySet("{ESC}", _Pause)

While True ;Endless loop
    Sleep(250)
WEnd

Func _Start()
    If $iState = $iState_None Then ;Keeps start from being called multiple times

        $iState = $iState_Running
        While True ;Endless loop

            While $iState = $iState_Running ;Loop for running state
                $pxs = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFFFFFF)
                If IsArray($pxs) And $iState = $iState_Running Then
                    MouseMove($pxs[0], $pxs[1], 0)
                    ;MouseClick("Left")

                EndIf
            WEnd

            While $iState = $iState_Paused ;Sit in a loop for paused state
                $sDots &= "."
                If StringLen($sDots) > 10 Then $sDots = "."
                ToolTip("Paused" & $sDots) ;Tooltip @ cursor position
                Sleep(250)
            WEnd
            ToolTip("") ;Erases tooltip
        WEnd
    ElseIf $iState = $iState_Paused Then
        _Pause() ;Could toggle the state here as well
    EndIf

EndFunc

Func _Pause()
    If $iState <> $iState_None Then ;Not running yet disable Pause...
        If $iState = $iState_Paused Then
            $iState = $iState_Running
            ToolTip("Running") ;Tooltip @ cursor position
        Else
            $iState = $iState_Paused
        EndIf
    EndIf
EndFunc

 

Edited by Bilgus
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...