Sign in to follow this  
Followers 0
Champak

Timer Jump Function

3 posts in this topic

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



#2 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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  
Followers 0