Champak Posted January 30, 2008 Share Posted January 30, 2008 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 30, 2008 Developers Share Posted January 30, 2008 (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 January 30, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Champak Posted January 31, 2008 Author Share Posted January 31, 2008 Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now