Sign in to follow this  
Followers 0
Glyph

if x time has passed then do func

4 posts in this topic

#1 ·  Posted (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 by backstabbed

tolle indicium

Share this post


Link to post
Share on other sites



$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.

Share this post


Link to post
Share on other sites

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

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