Jump to content
Sign in to follow this  
alanzarb

How to pause this script

Recommended Posts

alanzarb

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

Share this post


Link to post
Share on other sites
JLogan3o13

@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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
alanzarb

Thanks, and I'm sorry, I do not know how to read in English.!

Share this post


Link to post
Share on other sites
JLogan3o13

Use Google Translate if you need, but help us help you by providing more information.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
seandisanti

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

  • Like 1

Share this post


Link to post
Share on other sites
Bilgus
Posted (edited)
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
  • Like 1

Share this post


Link to post
Share on other sites
alanzarb

Thank you Seandisanti is even more Bilgus! (:

Share this post


Link to post
Share on other sites
seandisanti

No problem, glad to help. 

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  

×