Jump to content

Recommended Posts

Posted

I'm pretty amateur at scripting and programming, at least I definitely don't do it professionally. I've hit a bit of a head and would appreciate some advice. I apologize if this is a frequent question, but the sheer volume of posts has made the Search function rather useless.

So I have quite a few functions going on, and a PauseTime in between pretty much all of them - I assume this is rather standard for most scripts I can fathom. Problem is, I want a button to skip a Pause should I want to, the End key. I'm having a hard time seeing why the following code doesn't work. I don't get any errors, it just simply continues on its own, ignoring my attempts to skip the step. Is this because the variable $pausetime is declared and used only within the Func Pausetime?

I'll add some pretty colors to make it more readable :)

HotKeySet("{END}" , "SetPause0")

A()

PauseTime(" Pausing 60 seconds between A and B " , 60)

B()

Func SetPause0()

$pausetime = 0

EndFunc

Func PauseTime($pausename, $pausetime)

$tpause = TimerInit()

$diffpause = 0

While $diffpause < 1000 * $pausetime

$diffpause = TimerDiff($tpause)

$totalsecpause = $pausetime - Int($diffpause/1000)

$minpause = Int($totalsecpause/60)

$secpause = $totalsecpause - ($minpause*60)

ToolTip("[ " & $scripttitle & " ] " & $pausename & " " & $minpause & " mins & " & $secpause & " sec ...", 400, 3)

Sleep(1000)

WEnd

$diffpause = 0

$tpause = 0

ToolTip("")

EndFunc

Posted

You answered yourself...

HotKeySet("{END}", "SetPause0")
Global $paused;Added by Nahuel
;~ A()
PauseTime(" Pausing 60 seconds between A and B ", 60)
;~ B()

Func SetPause0()
    $paused = False;Added by Nahuel
EndFunc   ;==>SetPause0

Func PauseTime($pausename, $pausetime)
    $tpause = TimerInit()
    $diffpause = 0
    $paused=True;Added by Nahuel
    While ($diffpause < 1000 * $pausetime) And $paused;Added by Nahuel
        $diffpause = TimerDiff($tpause)
;~      $totalsecpause = $pausetime - Int($diffpause / 1000)
;~      $minpause = Int($totalsecpause / 60)
;~      $secpause = $totalsecpause - ($minpause * 60)
;~      ToolTip("[ " & $scripttitle & " ] " & $pausename & " " & $minpause & " mins & " & $secpause & " sec ...", 400, 3)
        Sleep(1000)
    WEnd
    $diffpause = 0
    $tpause = 0
    ToolTip("")
EndFunc   ;==>PauseTime
Posted (edited)

Three virgin internets to you for pointing out my idiocy! The solution was staring me in the face...

Thanks much, man.

Edited by Kiljaden

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
×
×
  • Create New...