Glyph Posted June 2, 2007 Posted June 2, 2007 (edited) $time = sleep (2000) while 1 $click=msgbox(1,"test","hahha") if $time <= "500" and $click=1 Then _less() EndIf if $time > "500" and $click=1 Then _more() EndIf WEnd ;less then 500 milliseconds func _less() msgbox(0,"<","was <500") EndFunc ;more then 500 milliseconds func _more() msgbox(0,">","was >500") EndFunc egh, how do i detect if so x time has elapsed? Edited June 2, 2007 by backstabbed tolle indicium
Moderators SmOke_N Posted June 2, 2007 Moderators Posted June 2, 2007 $nTimer = TimerInit() While 1 Sleep(Random(500, 2000, 1)) $nDiff = TimerDiff($nTimer) / 1000 ToolTip('Time Since Looped Started = ' & Round($nDiff, 2) & ' seconds.', 0, 0) WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Glyph Posted June 2, 2007 Author Posted June 2, 2007 HAH! If anyone was wondering... thanks to smoke_n's code, I came up with the following: $nTimer = TimerInit() $msg=msgbox(1,"Timer","Click ok to start time...") if $msg > 1 Then Exit EndIf While 1 ;~ ;random int 10 second difference Sleep(Random(1, 10001, 1)) $nDiff = TimerDiff($nTimer)/ 1000 ;round the time, more than or equal to 5 seconds?. Since you pressed ok, then display the time, and if it is or not greater than or less than. if Round($ndiff,2) >= "5" and $msg = 1 Then msgbox(0,"Timer","Greater than or equal to 5. Number is - "&$ndiff) Exit EndIf ;round the time, less than 5 seconds?. Since you pressed ok, then display the time, and if it is or not greater than or less than. if Round($ndiff,2) < "5" and $msg = 1 Then msgbox(0,"Timer","Less then 5. Number is - "&$ndiff) Exit EndIf WEnd tolle indicium
taylansan Posted June 2, 2007 Posted June 2, 2007 $needed = 2000 ;milisec $start = TimerInit() While 1 $is_finished = TimerDiff($start) ;don need to round cuz u only want the time elapsed? If $is_finished > $needed Then _myFunc() ExitLoop EndIf WEnd Func _myFunc() ;blablabla EndFunc TY.
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