Sign in to follow this  
Followers 0
MajSlayer420

Time Functions in Autoit3

4 posts in this topic

Hello I wanted to know if anyone knew how to make a timer to call a function at a certian time?

Say I enter 11:00(military time please) into a input, how can I get my program to detect when this time has arrived then call a function?

Thanks

MajSlayer420

Share this post


Link to post
Share on other sites



It would be better to use Windows Scheduled Tasks, and have it call a script that does the shutdown at a certain time. Otherwise, your script has to run continuously until the time arrives. Unless you have special circumstances that necessitate having a script run constantly, that's the way to go.

Now, as to scripting the startup of the computer... that's been discussed before:

http://www.autoitscript.com/forum/index.php?showtopic=31067


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Yes I do plan on running the script 24/7, I found some code that I figure might work if I implement it into my main loop.

#include <Date.au3>

While 1

If _NowTime(4) = "21:31" Then ; added the 4 parameter, to exclude the seconds(i dont think if you wake one second later makes any difference )

MsgBox(0,"wake","up")

EndIf

Sleep(100)

WEnd

Will this work?

Thanks for the reply

MajSlayer420

Share this post


Link to post
Share on other sites

No, because your sleep is too short. It will call the function many times during 21:31. Make your sleep= Sleep(60*1000) so it waits a full minute before testing the time again.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

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