Jump to content

Check for the existence of a file every X seconds


Recommended Posts

Hi,

I've recently discovered and started using AutoIT (what an amazing scripting tool!) and have been piecing together my first script. I'm no coder and I've hit a bit of a brick wall in trying to get my script to check for the existence of a file every X seconds. Here's basically what my script does :

On the click of a button it picks up the current time, adds a minute to that, and rewrites an .XML config file (including current time plus one minute) that is referenced (at the current time plus one minute) by a service process that reads and imports a data file into a database. What I need in my script is a function that will check for when the data file disappears (is successfully processed) so that an appropriate message can be displayed to the user ... and if it isn't successfully processed after a given length of time then again a message is displayed.

The utility dialogue I've created is very simple consisting of three buttons ("Initiate Processing", "Reset Processing Time", and "Exit") and, quite importantly I think, displays a clock so that users have an idea of when processing was initiated and how long it is taking. Cribbing some code from the AutoIt Help I've tried various methods, and the one method I've think that works (using a For ... Next loop with Sleep() like in a progress meter) in respect of checking for the successful processing of the data file has the major disadvantage of stopping the clock while it is running. I just can't seem to get my head round how I can carry out a file-check every X seconds without interfering with the real-time operation of the clock. Does anybody out there have any experience of such a problem? Any advice would be much appreciated - many thanks in anticipation.

Link to comment
Share on other sites

Hi xzaz,

Actually, I revisited the use of AdlibEnable (tried that before ... didn't work ... tried it in a different way & place ... did work ... go figure) with it executing the "check payment file" function with a 5 second interval. I introduced a counter to clock up to a specific number of seconds which is tested to act as a limiter or time-out so that the checking function doesn't just go on forever if the payment file fails to process for some reason. This all seems to do what I want it to without interfering with the function of the clock being displayed in the user dialog. Problem solved. ;-) It's just amazing what can be done with AutoIt.

Link to comment
Share on other sites

Can we see the script where you tried to use AdlibEnable? I think we can fix it in a jiff.

Hi Volly,

'Sokay - I nailed this ... and I wouldn't want to embaress myself by posting my primitive scripting ;-) even though I'm quite pleased with the result. Hopefully my next effort will be a bit more elegant and sophisticated.

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