83bj60 Posted September 1, 2004 Share Posted September 1, 2004 hello Folks, Well it seams my last lenghty post got gobbled up the preview monster last night... this script I am workning on is bringing me to my knees!!! There is nmo problem in logic or syntax, but I need this script to work to try save 2 hours of tedium daily which I would love to use... to get some more sleep!!! It is a sxcript whihc calls several programs to post process images (loading, debarrellizing, pre-processing, enhancing, poost-procesing and EXIF data manipulation, with final moving and thumbnail creation!...) It is 40K in lenhght at this time, wityh 1500 lines 3/4 of which are comments. the problem I am gettinmg is with TIMING. sometimes the computer runs too fast, sometimes not fast5 enough for the script to catch up. That WinWaitActive/NotActive statement is what causes the most grief! I was wondering if you code experts would have any advice on making the scrpit FOLLOW ITS ORDERS!!! I have tried to use varying Sleep() statements, more WinWaitxxxx tstements with increasing levels of grief! Is there a way to force the computer to give AutoIt the procesing priority it needs to "catch" the process as it develops instead of essentially "standing by on the sidelines and hoping to catch a piece of the action" ? Please excuse me for the typos, I'm late for my appointmanet and have had no time to correct. Any advice would be GREATLY appreciated, I'm loosing too much sleep opn this!!! Best Reagrds, 83bj60 Link to comment Share on other sites More sharing options...
this-is-me Posted September 1, 2004 Share Posted September 1, 2004 Attach your script if you can instead of posting it in a codeblock and we will see if we can help you. Under most circumstances it is better not to use sleep unless absolutely necessary. Adding some checks to see if a window's text has changed or something like that may work better. Who else would I be? Link to comment Share on other sites More sharing options...
SlimShady Posted September 1, 2004 Share Posted September 1, 2004 (edited) Some tips: 1. Try the WinWaitDelay option WinWaitDelay Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250).Opt("WinWaitDelay", 250) 2. If you send keystrokes you can decrease the delay of that too. SendKeyDelay Alters the the length of the brief pause in between sent keystrokes. Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead.Opt("SendKeyDelay", 5) Good luck. Edited September 1, 2004 by SlimShady Link to comment Share on other sites More sharing options...
83bj60 Posted September 2, 2004 Author Share Posted September 2, 2004 (edited) Thank you all warmly for your help, I will look at your suggestions as soon as I have more time (tomorrow probably). The delay or timing problem IS my main problem! It seems to me that the script behaves as if it were simply passive, and that the running programs have teh upper hand and do what they want. Like Larry says, it looks like I may have to check and code ven more than I already did... But about execution: how fast can the script run? Under some circumstances, my programs run blindingly fast when keystrokes are sent: the next window may appear simply for a 1/100 of a second, for example. What is the shortest delay between window polling? I was using the typical combination: Run("C:\Graphic.Pro\Exifer\Exifer.exe") ; ; ; Wait till Exifer is active and settled ; WinWaitActive("Exifer") Sleep(8000); Wait it has finished going through enumerating all the thumnails ; ; ; Now select all files (^a) and Restore the Backups (^r). ; A dialog box named "Replace EXIF/IPTC data" opens and ; you must press "Yes for all". We do it this way: ; Send("^a"); select all Sleep(1000); to allow time for the program to stop "selecting all" Send("^r"); restore EXIF Data into the selected files WinWaitActive("Replace EXIF/IPTC data"); wait till that status window appears ; ; ; Click the "Yes for all" button ; ControlClick("Replace EXIF/IPTC data", "", "TButton2") ; ; ; Now it loads the backups, and a window called "Loading backups..." ; with a progress bar appears. We have to wait till it ends before ; continuing. ; WinWaitActive("Loading backups..."); wait till the window actually appears before checking its closure otherwise the next window may timeout immediately WinWaitClose("Loading backups..."); <-- the script can lockup here (the previous window was not seen, I suppose) ; ; ; Closing Exifer ; WinKill("Exifer") and lo and behold, if there are only a few files on the same drive, the operation is so fast that the script locks up! So I tried to put sleep statements, but further timing issues appeared, and the script would lock up somewhere else (depending on the computer's mood)... You can surely understand my frustration! If you want me to send the complete code, gladly, but it's huge! The main problem lies in the second half of the script, where there is a lot of user intervention (read: a LOT of clicking!!!) and the resulting program response can be extremely quick (changing the EXIF dates in the EXIF data of a file, for example, can be blindingly fast, like up to 100 files modified per second!). is there an option to make the script run checking teh action every millisecond insead of every 250 millisecond, for example? can the WinWaitDelay be set to 0 (none) or at least all the way down to 1 millisecond, or is script execution limited by keyboard delay when sending keystokes? Any further ideas regarding that matter would be greatly appreciated, thank you for your kind help so far Best Regards, 83bj60 Edited September 2, 2004 by 83bj60 Link to comment Share on other sites More sharing options...
ezzetabi Posted September 2, 2004 Share Posted September 2, 2004 (edited) Check the Exifer window win WinSpy... there is not way to see if it had enumerated all the thumnails? E.g. a percent indicator with readable text a bar with readable color a message somewhere like 'Done' the mouse arrow shape even... Edited September 2, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
this-is-me Posted September 2, 2004 Share Posted September 2, 2004 (edited) Instead of just winwaitactive, do winwait and then winwaitactive then winwaitclose. EDIT: Replace all winwaitactives with winwait and then winwaitactive Edited September 2, 2004 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
83bj60 Posted September 2, 2004 Author Share Posted September 2, 2004 Check the Exifer window win WinSpy... there is not way to see if it had enumerated all the thumnails? E.g. a percent indicator with readable text a bar with readable color a message somewhere like 'Done' the mouse arrow shape even... <{POST_SNAPBACK}>Actually, I was looking at it closely today as it ran (with 6 restartable interruptions and a non-restartable jam near the end) and watching the locations in the code, and it seems that at least in some places I could probably use a checking routine like: $i=0 $cursor=MouseGetCursor() Do If $cursor=2 Then; normal arrow pointer ExitLoop EndIf ContinueLoop Until $i=1 ..To wait for the hourglass animated cursor to stop. then I could go on proceeding with the script... Thanks for your input, I feel I'm getting closer! Link to comment Share on other sites More sharing options...
83bj60 Posted September 2, 2004 Author Share Posted September 2, 2004 Instead of just winwaitactive, do winwait and then winwaitactive then winwaitclose. EDIT: Replace all winwaitactives with winwait and then winwaitactive <{POST_SNAPBACK}>Another smart tip! You guys are great, and I mean not just those who I responded direct with quotes... I've been using a lot of WinActivate("Photo Processing") WinWaitActive("Photo Processing") trouble is, sometimes the windows are already active and then the scripts locks up... I was thinking about forcing a minimize after process, but it's probably best to do it the way you are describing Thanks, much appreciated Link to comment Share on other sites More sharing options...
83bj60 Posted September 2, 2004 Author Share Posted September 2, 2004 Some tips: 1. Try the WinWaitDelay option Opt("WinWaitDelay", 250) 2. If you send keystrokes you can decrease the delay of that too. Opt("SendKeyDelay", 5) Good luck. <{POST_SNAPBACK}>I've been experimenting with shortening the WinWaitDelay and increasing the SendKeyDelays and I believe I'm on the right path! I only got 6 stoppages this time that I was able to restart (and only had one unrestorable stop)... I'm not unhappy considering the lenght of the script and my inexperience with AutoIt and I'm getting there easier thanks to your great help I'm looking forward to weekend tweaking of the script after I've caught up with my work backlog Link to comment Share on other sites More sharing options...
83bj60 Posted September 7, 2004 Author Share Posted September 7, 2004 I've been experimenting with shortening the WinWaitDelay and increasing the SendKeyDelays and I believe I'm on the right path! <{POST_SNAPBACK}>Well it appears that Opt("WinWaitDelay, 0) and Opt(SendKeyDelay, 150) solved my main timing issues, but I still have to use many sleep statements... The main problems are with applications that are running even after they seem to have terminated in Windows (as evidenced by the hard drive still accessing). Some windows appear to continue on a while but invisibly without being closeable and windows that simply can't be closed... In any case the script is running quite reliably now although much code cleaning remains to be done. After removing most comments, I still have about 500 lines of code in there, and this is my first attempt at coding in quite a while!!! Anyhow, I can now auto process 200 3MP images in aspproximately 15 steps (application instances) in about 1.5 hours, during which I can have supper, watch a movie or take a nap Thank you Jon for one of the best apps I've come accross in years! Thank you SlimShady for your spot-on advice about the delay otions! Thank you This-is-me for making me take a deeper look at all the WinXxxxXxxx statements, there is a lot of powerfull features in these commands! Thank you ezzetabi, the way I could proceed without a sleep statement there is using some sort of code sequence that would compare the only two number 'words' in the status bar sequence to contuinue on ('are those two number words equal/' if they are, we are finished opening and get on with our work). The statement is present as "visible window text" in the format " 140 images (140 with EXIF/IPTC): 161.251 KB Any ideas how I could make a test of these two number sequences (always 1st and third word of the Window Text)? Thank you Larry for the MouseCursor Tip, in that case the cursor does not cahnge while the loading operatio is happening. I did slow down the CPU to 1% to see if other windows would appear (even fleetingly) and with certain programs, some otherwise too fleeting windows appear, but not in this case. Maybe it has to do with the way the program communicates with Windows... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now