Jump to content

TIME function/syntax


Recommended Posts

Hi all,

I need to some loop of tasks in a dynamic , defined interval of time such as in 3 minutes or 5 minutes, etc. how do I do it with autotit ? Thanks.

As an example:

$min = InputBox("Minutes", "How long to wait: ")
If @error > 0 Then
    Exit
EndIf

$sleep = ($min * 60) * 1000
If $sleep > 2147483646 Then
    MsgBox(0, "Error", "Um, sorry, can't go over 24 days :)'")
    Exit
EndIf

While 1
    Sleep($sleep)
        MsgBox(0, "Done", "Yep, waited: "&$min&" minutes.")
WEnd

Just a very basic example of how to calc how many minutes you want into miliseconds, and then sleep for that amount of time and execute a command. You could even do a function, if you wanted after the sleep command. heck, this could even be accomplished with the adlib command lol. There's so many different choices. Just remember, sleep doesn't go over 24.85ish days; but then again, why wait that long to run any script haha

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Oops what i meant is i wanna run some tasks for a given time, not to wait for that given time then execute.

For eg, i have a function counting from 1 to n ( may sleep1 or 2 or 3, etc. seconds between numbers ) in a given time here such as 4 minutes, 10 minutes, etc.

Edited by betien
Link to comment
Share on other sites

I think he wants to be calling functions and doing calculations while looping in a dynamic amount of time. For that you wll have to use Timerinit()

$Timer = Timerinit()
$DynamicTimeStamp = 5000 

While Timerdiff($Timer) < $DynamicTimeStamp
    ;do some stuff in here for $dynamicTimeStamp amount of time
    ;You can change the $DynamicTimeStamp variable in here if you want

    sleep(1) ;Optional so your Processor doesn't get bogged down

Wend
    
msgbox(0,"I looped for:",$dynamicTimeStamp & "mS") ; Debug message
Edited by BotXpert
Link to comment
Share on other sites

I think he wants to be calling functions and doing calculations while looping in a dynamic amount of time. For that you wll have to use Timerinit()

$Timer = Timerinit()
$DynamicTimeStamp = 5000 

While Timerdiff($Timer) < $DynamicTimeStamp
    ;do some stuff in here for $dynamicTimeStamp amount of time
    ;You can change the $DynamicTimeStamp variable in here if you want

    sleep(1) ;Optional so your Processor doesn't get bogged down

Wend
    
msgbox(0,"I looped for:",$dynamicTimeStamp & "mS") ; Debug message

Yes, this is what I want . Thanks a heap.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...