Jump to content
Sign in to follow this  
Champak

Timer Jump Function

Recommended Posts

Champak

I'm trying to make a function that will skip portions of the function for a certain amount of time if a hotkey is pressed without using sleep...because it ties up the GUI. So I came up with the following but don't know how to really implement it. My problem is the timer freezing up the GUI. Is this possible, or am I just going to have to stick with the sleep function.

HotKeySet("{ENTER}","StartSkip")

Func whatever()
        $Jump_POINotify = ""
        If $Elapsed > 0 Then
            ConsoleWrite("Key pressed, now jumping")
            $Jump_POINotify = "POINotify"
        EndIf
        If $Jump_POINotify <> "POINotify" Then
            ConsoleWrite("Not jumping")
            ;Whatever I put as my script here, this is what will be jumped for 10 sec. if I hit the enter key.
        EndIf
EndFunc

Func StartSkip()
    $Elapsed = 0
    $StartTime = TimerInit()
    Do
        $i = $i - 1
        $Elapsed = TimerDiff($StartTime) / 1000
        $Elapsed = Round($Elapsed)
    Until $Elapsed = 10
    $Elapsed = 0
EndFunc

Thanks.

Share this post


Link to post
Share on other sites
Jos

untested but something like this should work:

HotKeySet("{ENTER}", "StartSkip")
Global $StartTime=0
;
Func whatever()
    $Jump_POINotify = ""
    If $StartTime <> 0 Then $Elapsed = TimerDiff($StartTime)/1000
    If $Elapsed > 0  And $Elapsed < 10 Then
        ConsoleWrite("Key pressed, now jumping")
        $Jump_POINotify = "POINotify"
    EndIf
    If $Jump_POINotify <> "POINotify" Then
        ConsoleWrite("Not jumping")
;Whatever I put as my script here, this is what will be jumped for 10 sec. if I hit the enter key.
    EndIf
EndFunc ;==>whatever
;
Func StartSkip()
    $StartTime = TimerInit()
EndFunc ;==>StartSkip
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Champak

Thanks.

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  

×