Jump to content

Run a script every <insert interval of time>


Recommended Posts

Hello, I am new to autoit and programming in general. I have made an autoit script, which I want to be run once an hour. I am having trouble figuring out the syntax to do this, can anyone help?

Thank you!

I suppose you could make another script to run it, it would look something like this:

$hour = @Hour;Grab the current hour as a variable
$min = @Min;Grap the current minute as a variable

ShellExecute('put the other script's full path here');Run your hourly script first

While 1;Keep on repeating 
    If $hour < @Hour then;If the saved hour is less then the current hour check the next statement
        If $min < @Min then;If the saved minute is less then the current minute check the next statement
            ShellExeCute('put the other script's full path here');Run the script
            $hour = @Hour;Re grab the hour
            $min = @Min;Re grab the minute
        EndIf 
    EndIf 
    Sleep(200);Wait a bit to check in order to keep CPU usage down
WEnd

I haven't tested this because I don't want to wait an hour but it should work.

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

ok so here is the code I am using

-----------------------------------------------------------------------------------------

$hour = @Hour;Grab the current hour as a variable

$min = @Min;Grap the current minute as a variable

ShellExecute(C:\scripts\galacticatest.ahk);Run your hourly script first

While 1;Keep on repeating

If $hour < @Hour then;If the saved hour is less then the current hour check the next statement

If $min < @Min then;If the saved minute is less then the current minute check the next statement

ShellExeCute(C:\scripts\galacticatest.ahk);Run the script

$hour = @Hour;Re grab the hour

$min = @Min;Re grab the minute

EndIf

EndIf

Sleep(200);Wait a bit to check in order to keep CPU usage down

WEnd

------------------------------------------------------------------------------------------

When I run this script I get the following error

---------------

Error at Line 4.

Line Text: \scripts\galacticatest.ahk

Error: The leftmost character above is illegal in an expression.

The program will exit.

---------------

Any thoughts?

Link to comment
Share on other sites

When I run this script I get the following error

---------------

Error at Line 4.

Line Text: \scripts\galacticatest.ahk

Error: The leftmost character above is illegal in an expression.

The program will exit.

---------------

Any thoughts?

I have some... You forgot to add the quotes "".

ShellExeCute("C:\scripts\galacticatest.ahk")

Cheers... :)

Link to comment
Share on other sites

Two other approaches would be:

1) Just schedule the thing in your windows task scheduler.

2) If you don't want the hassle of having two different autoit scripts, the one running the other, you might just wait an hour in the main loop and then do the hourly stuff:

While 1

$ti = TimerInit()

While TimerDiff($ti) < 60 * 60 * 1000 ; <- 60*60*1000 = amount of miliseconds in one hour

Sleep(1000) ; <- wait for a second

WEnd

; Do The Hourly Stuff

WEnd

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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