It's my first AutoIt script and almost obviously I'm trying to automate some operations in an external program.
My concern points to time an operation takes to complete, that can vary according to the PC's tasks loading, and how to control that.
I'd work these issues out through the Sleep() or the WinWaitActive() functions. The first one, even though easy to use, is unable to manage situations where the execution time vary significantly. The second one is able to detect the moment when a new window becomes active and so it seems to be the correct solution.
But not in this situation I'm facing: at the end of script (not exactly at the end, because this routine exists inside a loop) I send the command to save the file early modified, and a "Save as" windows opens inside the main program; now I send the keystrokes to perform the file saving, and at that moment... well, at that moment I'm not able to manage correctly the further events.
Using a long Sleep() break could be boaring in case of a small file, but still unsafe in case of a huge file to save on a by accident temporarily busy system: waiting time could run off before the saving completes and the next instructions coming from the script would be lost.
But also WinWaitActive() seems unappropriate, because that is what happens: I'm checking whether the main window of the program is ready to receive new keystrokes; in effect this function tests the moment when the main window becomes active, but this moment happens when the "Save as" windows closes - even though the saving process isn't yet ended -; so the script resume to execute and the further commands (closing the saved file and repeating the loop with a new file) go down the drain.
Any suggestion to work the trouble out? Thanks in advance :-)
h61Omrod
My concern points to time an operation takes to complete, that can vary according to the PC's tasks loading, and how to control that.
I'd work these issues out through the Sleep() or the WinWaitActive() functions. The first one, even though easy to use, is unable to manage situations where the execution time vary significantly. The second one is able to detect the moment when a new window becomes active and so it seems to be the correct solution.
But not in this situation I'm facing: at the end of script (not exactly at the end, because this routine exists inside a loop) I send the command to save the file early modified, and a "Save as" windows opens inside the main program; now I send the keystrokes to perform the file saving, and at that moment... well, at that moment I'm not able to manage correctly the further events.
Using a long Sleep() break could be boaring in case of a small file, but still unsafe in case of a huge file to save on a by accident temporarily busy system: waiting time could run off before the saving completes and the next instructions coming from the script would be lost.
But also WinWaitActive() seems unappropriate, because that is what happens: I'm checking whether the main window of the program is ready to receive new keystrokes; in effect this function tests the moment when the main window becomes active, but this moment happens when the "Save as" windows closes - even though the saving process isn't yet ended -; so the script resume to execute and the further commands (closing the saved file and repeating the loop with a new file) go down the drain.
Any suggestion to work the trouble out? Thanks in advance :-)
h61Omrod