Jump to content

Can autoit be used as a Tasks Scheduled


Recommended Posts

You could use the windows scheduler to run AutoIt scripts, or you could write a script compleatly in AutoIt that contains an array of times, and checks the time every minute (or second, if you need to start an application on an exact second.) It could basically check the time every minute, and if the time matches that of a schedguled event, run the program associated with it.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

You could use the windows scheduler to run AutoIt scripts, or you could write a script compleatly in AutoIt that contains an array of times, and checks the time every minute (or second, if you need to start an application on an exact second.)  It could basically check the time every minute, and if the time matches that of a schedguled event, run the program associated with it.

When I do stuff like that I usually have it sleep 30 minutes to save resources

Rick

Link to comment
Share on other sites

When I do stuff like that I usually have it sleep 30 minutes to save resources

It just depends on how often you need to check to run something. If running your script 30 seconds or more apart from your start time would cause it to fail, you'd need to check more often than once every 60 seconds. I suppose one advantage to using the windows scheduler is that there is not an extra tax on the system.

Edited to add in a missing letter

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Well I have a batch file that I would like to run once a day and a exe that I would like to run once a day both 7 days a week .

If i need it more all just click it .

Link to comment
Share on other sites

Then a 30 minute pause would save a lot of CPU cycles :D

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

That depends on if you want to start the counting over when your computer shuts down or not. If you don't, then you'll need to write to an ini file the last time you ran the program, and see if it has been more than 1 day for the 1 day program, and 7 for the other one. If this is not important, then you could simply define two timers, and check each timer every 30 minutes for the proper amount of time having expired:

$timer1 = TimerStart()
$timer2 = TimerStart()
$day = 86400000;1 day in milliseconds

While 1
  Sleep(30 * 60 * 1000);sleep for half an hour
;one day testing:
  If TimerStop($timer1) > $day Then
    Run('"C:\Program Files\program1.exe"')
    $timer1 = TimerStart()
  EndIf
  If TimerStop($timer2) > 7 * $day Then
    Run('"C:\Program Files\other.exe"')
    $timer2 = TimerStart()
  EndIf
WEnd

To use the first method, write the date and time of the last program run, and have your while loop compare the current date and time to the last date and time, and figure out if more time has occured than 1 or 7 days.

Honestly, it would probably be a lot eaisier to use the build in scheduler instead of tring to code it in AutoIt. It's doable, just a fair amount harder than the 2nd method I listed.

Added code to reset the timers

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

ya it not that inportant when it runs . just to empty recycle bin and run a bat file to delete some stuff .

Thanks for the code . I just don't know this stuff good yet .maybe never will .

Link to comment
Share on other sites

ya it not that inportant when it runs . just to empty recycle bin and run a bat file to delete some stuff .

Thanks for the code . I just don't know this stuff good yet .maybe never will .

I also used an ini file to set a time of the day

If you do use runwait and if it's a short script the second variable as well as minute

Rick

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