Jump to content
Sign in to follow this  
dorochet

Run a script every <insert interval of time>

Recommended Posts

dorochet

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!

Share this post


Link to post
Share on other sites
Achilles

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]

Share this post


Link to post
Share on other sites
dorochet

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?

Share this post


Link to post
Share on other sites
GreenHouse

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

Share this post


Link to post
Share on other sites
dorochet

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

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

Cheers... :)

Silly mistake, thank you

Share this post


Link to post
Share on other sites
GreenHouse

Silly mistake, thank you

Hey no problem at all.... :) I'm new too and I am still making a plenty of those myself... haha just gotta be casual about it... be allright...

Have a good night.

- Pas

Share this post


Link to post
Share on other sites
Fossil Rock

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

That's funny .... wanting to run an AutoHotKey script with AutoIt. :)

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
SadBunny

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.

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  

×