Jump to content
Sign in to follow this  
soma01

Run a script when a file is updated

Recommended Posts

soma01

I am a newbie and need some help on writing a script.

I would like to do some processing just after a file has been updated (by another application); some kind of trigger on event. I would like to do this without looping.

Is this possible ?

If not, then as the file will be updated once per minute at 00 seconds, I could wait in my script until @Sec = 5, do what I have to do, then sleep (55000) and loop; but I am a bit afraid of the load the loop will put on my CPU.

Could someone just put me in the right direction ?

Thanks

Share this post


Link to post
Share on other sites
Richard Robertson

If your script is sleeping, it will use 0% CPU.

Share this post


Link to post
Share on other sites
Yashied

I am a newbie and need some help on writing a script.

I would like to do some processing just after a file has been updated (by another application); some kind of trigger on event. I would like to do this without looping.

Is this possible ?

If not, then as the file will be updated once per minute at 00 seconds, I could wait in my script until @Sec = 5, do what I have to do, then sleep (55000) and loop; but I am a bit afraid of the load the loop will put on my CPU.

Could someone just put me in the right direction ?

Thanks

Maybe this.

Local $TimeOut = 5 * 1000 ; 5 Sec
Local $TD = TimerInit()

While 1
    If TimerDiff($TD) > $TimeOut Then
        ...
        $TD = TimerInit()
    EndIf
    ...
    Sleep(10)
WEnd
Edited by Yashied

Share this post


Link to post
Share on other sites
muncherw

I am a newbie and need some help on writing a script.

I would like to do some processing just after a file has been updated (by another application); some kind of trigger on event. I would like to do this without looping.

Is this possible ?

If not, then as the file will be updated once per minute at 00 seconds, I could wait in my script until @Sec = 5, do what I have to do, then sleep (55000) and loop; but I am a bit afraid of the load the loop will put on my CPU.

Could someone just put me in the right direction ?

Thanks

I don't see how you can do it without a loop. A sleep for a few seconds wouldn't really cause a load problem (heck even if it was 100 milliseconds). You could use something like FileGetTime to see if the file has changed.


Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.