Sign in to follow this  
Followers 0
thenewkid

a timer

11 posts in this topic

how can i do i timer in autoit? so it would count down for 60 sec if you know what i mean?

thx


some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with

Share this post


Link to post
Share on other sites



If you are just looking for the nuts and bolts of how to work with a timer, check out TimerInit() in the help file


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

i try this but it pauses my whole script and i cant use it intill it finshs

$start = TimerInit()
Sleep(30000)
$stop = TimerDiff($start)

some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with

Share this post


Link to post
Share on other sites

Yup, thats what the Sleep function does.

Sleep is used in the example just to create a passage of time so that the TimerDiff shows something.

What you probably want to do is to periodically check if the value of TimerDiff($start) is greater than the value of time that you need.


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

how would i do that?


some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with

Share this post


Link to post
Share on other sites

; Demo timer
$Time = TimerInit()
MsgBox(32, "Demo Timer", "Hit OK when you feel like it...")
$TimeDiff = TimerDiff($Time) / 1000 ; convert msec to sec
$TimeDiff = Round($TimeDiff, 3) ; round to nearest msec
MsgBox(64, "Demo Timer", "It took you " & $TimeDiff & " seconds to hit OK.")

Read the help file... :shocked:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

How are you intending to use it?

Do you want some kind of clock to tick down in a GUI of some sort?

Are you just wanting an invisible script to be doing something then stop after a certain amount of time has passed?

$start = TimerInit()

While 1
    $time = TimerDiff($start)
    ; you could be doing whatever you want here
    ToolTip("Running: " & $time)
    Sleep(100) ; just put this in so we dont eat up the CPU
    If $time > 10000 Then Exit
WEnd

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

how can i do i timer in autoit? so it would count down for 60 sec if you know what i mean?

thx

Or if you just want a countdown Timer.

For $i = 60 to 0 step -1
     ToolTip($i,0,0)
     Sleep(1000)
Next

Share this post


Link to post
Share on other sites

i would have the timer running but the gui has to be able to be used as well at the same time as the timer is running


some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with

Share this post


Link to post
Share on other sites

GUIRegisterMsg() and WM_TIMER

Or AdLibEnable() a function that runs every few seconds to check on the timer.

:shocked:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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