Jump to content

Pausing a script ???


Recommended Posts

Hello,

I am wondering if there is a way to pause a script but have it finish the current loop then pause instead of just pausing right away. I am using the

Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip("Paused", 1, 1)
WEnd
ToolTip("")
EndFunc

function to pause right now. The problem I am having is I have a script that uses alot of pixelsearch functions and sometimes when I press pause I get the $array has no variable error because the script is being paused right before the pixel search is able to check @error and return the array. Thanks in Advance for help.;)

Link to comment
Share on other sites

Thanks Guys took the advice and came up with

Global $Paused
HotKeySet("{F7}", "TogglePause")
Func TogglePause()
    If @error < 2 Then
    $Paused = Not $Paused
    While $Paused
        Sleep(1)
        ToolTip('', 691, 325)
    WEnd
    ToolTip("")
    EndIf
EndFunc   ;==>TogglePause
Not a big change but it pauses it after the @error array is returned ;) no more no array virable error Thanks Again
Link to comment
Share on other sites

Thanks Guys took the advice and came up with

Global $Paused
HotKeySet("{F7}", "TogglePause")
Func TogglePause()
    If @error < 2 Then
    $Paused = Not $Paused
    While $Paused
        Sleep(1)
        ToolTip('', 691, 325)
    WEnd
    ToolTip("")
    EndIf
EndFunc   ;==>TogglePause
Not a big change but it pauses it after the @error array is returned ;) no more no array virable error Thanks Again

This should work:

HotKeySet("{PAUSE}", "_Pause")
HotKeySet("{ESC}", "_Exit")

Global $Pause = False

While Sleep(25)
WEnd

Func _Pause()
    $Pause = Not $Pause

    While $Pause
        ToolTip("Paused", 0, 0)
        Sleep(25)
    WEnd
    ToolTip("")
EndFunc

Func _Exit()
    Exit
EndFunc
Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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