kylomas Posted March 15, 2013 Share Posted March 15, 2013 How do the network timing issues account for the truncated file name? @GIS007 - Is the filename always altered in the same way? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
GIS007 Posted March 15, 2013 Author Share Posted March 15, 2013 Well, someone gave me the idea that network connections can be dropped, especially since there are all these jobs that run at night, so if I did a ping statement (well actually they told me to refresh the network connections. But I'm very new to AutoIT so I try to stick with the stuff I know) it would 'wake up' that network connection. I was going on the assumption that running the exe the first time & it returns only a part of the name is because the connection wasn't refreshed in time? And, no kylomas, the file name that is returned in the error message is not always the same, it drops various amounts of the name.... Is that significant? My boss unfortunately was too busy to test this today but I'll check w/him next week & see if that works. And, good suggestion Tripredacus about the potential issue w/firewall changes, I'll keep that in mind. Awesome group of people here! Link to comment Share on other sites More sharing options...
jdelaney Posted March 15, 2013 Share Posted March 15, 2013 (edited) It's possible that this is running on process 0, which would make sense if running at night with no one logged in, which may/may not share the same drives as your user accounts. Definately look into the Drive* functions, and log all results, so you know what's going on (file*, and _file* functions) edit: oops, 'Session 0', not process 0 Edited March 15, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
GIS007 Posted March 15, 2013 Author Share Posted March 15, 2013 It's possible that this is running on process 0, which would make sense if running at night with no one logged in, which may/may not share the same drives as your user accounts.Definately look into the Drive* functions, and log all results, so you know what's going on (file*, and _file* functions)Okay, will do. Man I was hoping that the ping would fix this. Link to comment Share on other sites More sharing options...
GIS007 Posted March 26, 2013 Author Share Posted March 26, 2013 (edited) Here's my updated script. I am still working on being able to use logging and ControlSend vs Send so unfortunately those changes haven't been incorporated yet. I added line 5 - checking to see if the file exists. When I ran this today it paused after line 13. Any idea why? Thanks for any further help! Edited April 4, 2013 by GIS007 Link to comment Share on other sites More sharing options...
FireFox Posted March 26, 2013 Share Posted March 26, 2013 (edited) @GIS007 The FileExists function is NOT a blocking one, it returns 1 or 0 according to the file existence. If FileExists("file") = 1 Then ;Or simply without "= 1" ;do stuff here if the file exists EndIf Edit: For your script you can do the following : If FileExists("L:\PdxBatch09122012.pbt") = 0 Then Exit(1) Br, FireFox. Edited March 26, 2013 by FireFox Link to comment Share on other sites More sharing options...
GIS007 Posted March 26, 2013 Author Share Posted March 26, 2013 Ok, will try that. I am still having that issue where the program runs fine the second time. I was thinking that it was a network connection being dropped so I have tried ping to refresh the connection (didn't work), so I thought if I had the script go out on the network & check to see if the file existed, it would refresh the connection so the script would run on the first time. Something must be going on somewhere else to cause this? Link to comment Share on other sites More sharing options...
FireFox Posted March 26, 2013 Share Posted March 26, 2013 You should follow jdelaney's instructions, particularly about error/return value checking. Read the help file for each function to know what it returns on success/failure, no way that you can't get out of this issue. Br, FireFox. Link to comment Share on other sites More sharing options...
GIS007 Posted March 26, 2013 Author Share Posted March 26, 2013 You should follow jdelaney's instructions, particularly about error/return value checking.Read the help file for each function to know what it returns on success/failure, no way that you can't get out of this issue.Br, FireFox.I am trying to learn how to write to a file for error checking, etc. I wish I had jdelaney's brain! But I'm really new to AutoIT & my supervisor passed along a script from someone in another county that supposedly works fine for them - it's only 16 lines of code with no error checking, no if/thens, etc & my supervisor is looking at me saying 'why does his work & yours still doesn't when his is so much shorter than yours?' He thinks I am making this too complicated....I will definitely incorporate jdelaney's suggestions into my script as soon as I can get them to work out. It's just so illogical to me that the script will run a second time but not the first. Link to comment Share on other sites More sharing options...
GIS007 Posted March 26, 2013 Author Share Posted March 26, 2013 Using the function help page (which has examples that are of limited use), my WinMenuSelectItem line doesn't work: WinMenuSelectItem("Annotate","Shapefile/DBF Maintenance","") Why does everyone seem to dislike using the Send command? I can see if the keystrokes were complicated it could pose problems but here it seems pretty straightforward? And, I had the same issue with ControlSend not working where just sticking in a 'send' line did work: ControlSend("Open", "File name", 32770, "PdxBatch09122012.pbt") Link to comment Share on other sites More sharing options...
FireFox Posted March 26, 2013 Share Posted March 26, 2013 (edited) Try this, please read carefully my comments : expandcollapse popupRun("C:\Program Files (x86)\Pictometry\ChangeAnalysis2.7\ChangeAnalysis.exe") If @error Then ConsoleWrite("Run failure! @error: " & @error & @CrLf) Exit(1) EndIf ;wait until the file exists (I suppose this is what you wanted to do ?) While FileExists("L:\PdxBatch09122012.pbt") = 0 Sleep(1000) WEnd WinWaitActive("ChangeAnalysis -") ;Get the window by using keystrokes Send("!a{UP}{ENTER}") ;try ControlSend instead, it should be more efficient WinWaitActive("Shapefile/DBF Maintenance") ;use the instance and control type instead of the ID If ControlClick("Shapefile/DBF Maintenance", "Browse...", "[ID:2333]") = 0 Then ConsoleWrite("ControlClick failure!" & @CrLf) Exit(1) EndIf WinActivate("Open") ;add the classname here e.g: [TITLE:Open;CLASS:classname] WinWaitActive("Open") ;same ;Get the file off the L drive Send("L:\PdxBatch09122012.pbt") ;try ControlSetText instead WinActivate("Open") ;same as before WinWaitActive("Open") ;same Send("{ENTER}") ;try ControlClick instead ;use the classname for the following winwait/close functions : WinWait("Shapefile/DBF Maintenance") ;the window does not need to be active when using the Control* functions If ControlClick("Shapefile/DBF Maintenance", "Run", "[ID:2334]") = 0 Then ConsoleWrite("ControlClick failure!" & @CrLf) Exit(1) EndIf WinWait("Shapefile/DBF Maintenance", "List1", 30) ;same If ControlClick("Shapefile/DBF Maintenance", "Done", "[ID:1]") = 0 Then ConsoleWrite("ControlClick failure!" & @CrLf) Exit(1) EndIf WinClose("ChangeAnalysis- ") Br, FireFox. Edited March 26, 2013 by FireFox Link to comment Share on other sites More sharing options...
GIS007 Posted March 26, 2013 Author Share Posted March 26, 2013 Okay, I will try to rewrite my script using your suggestions. Thank you! The reason that I keep going back to using Send is because the keystrokes to get this file menu item are so easy - here is what the GUI looks like (attached image). Any time I try to use ControlSend or WinMenuSelectItem it fails. Link to comment Share on other sites More sharing options...
GIS007 Posted April 4, 2013 Author Share Posted April 4, 2013 (edited) Testing this is difficult because once it fails, the subsequent times it runs successfully, so am really only able to test once per day. Today my IT guy said this script paused at line 19. It has been running correctly for the past week, the only difference is yesterday a user opened the program and pointed it to a different folder (program defaults to the last path that was used, even if the pbt file wasn't there). I'm still working on the error checking - bear with me. Is there a better way to initiate the Browse window to actually find the L drive other than using ControlClick? In case another user opens their program and browses to a different location? Edited April 4, 2013 by GIS007 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