Jump to content

Recommended Posts

Posted

Is it possible to write a script to have it start at a specific time of the day or night? I am still learning this and i am hoping someone is able to help me. Instead of having it sleep in ms, i was hoping there was another command that would make it start at a specific time on my computer.

 

Thanks in advance

  • Developers
Posted
2 minutes ago, boat_58 said:

i was hoping there was another command that would make it start at a specific time on my computer.

I honestly would use the build-in windows scheduler for that. :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

I also agree that Task Scheduler is the most reliable/best way to have a task start at the same time every day. But for the sake of my own education I had a look at the perfectly good date/time macros in AutoIT, just in case you want your script to hang around doing not much until a certain time has come (say, 13 minutes past 1 in the afternoon), this much is simple.

Do
If @HOUR & ":" & @MIN = "13:13" Then
    ConsoleWrite(@HOUR & ":" & @MIN & @CRLF) ; write to console but could be any action really
    ExitLoop ; if we exit the loop it only runs once, remove if you want this to happen every day
EndIf
Sleep(1000)
Until 0

But what if the time you specified in your code has already passed (such as the system was asleep)? Ok, just change the comparison operator so instead of "=" you use ">=", then it will trigger after the time has passed too.

Really have a close look at Windows task scheduler (I'm looking at Windows 10) - you can set multiple triggers, you can define different conditions, you can define retry on failure (now, that looks interesting: how does the task schedule know a task has failed? What do we need in our script to assure this is properly working?), there is an history kept, etc.. The built-in scheduler is really pretty fail-safe once you have your task set up.

Anyway someone tackled running tasks at set times a long time ago and there are good (simple) examples of using the Time and Date macros there, have a look, and best of luck!

 

Always carry a towel.

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
  • Recently Browsing   0 members

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