Jump to content

Run a script when a file is updated


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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