boein Posted January 27, 2015 Share Posted January 27, 2015 Hi, When you want to copy a file to a network share sometimes it takes 1 sec sometimes 3 sec before it's copied. How can you check if the file is completely copied before continuing with your script. One remark, the copy is not initiated by an autoit command but with "file save-as" executed by autoit using the controlsend command. Meaning you really have to wait before the program has finished the "save" before the script can continue. I tried to check filexists in a loop or filesize but it doesn't seem to work. It's also impossible to read the statusbar of the file-save completing because I cannot retreive the controlID of that statusbar. The application is Lotus Notes 7 and it almost reveals no control id's. Anyone ideas? Regards, Boein Link to comment Share on other sites More sharing options...
water Posted January 27, 2015 Share Posted January 27, 2015 Another approach would be to not automate the GUI but to use COM. When calling the SaveAs method you can be sure that your script only continues when the file has been written. Plus you can check for errors.. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
boein Posted January 27, 2015 Author Share Posted January 27, 2015 Another approach would be to not automate the GUI but to use COM. When calling the SaveAs method you can be sure that your script only continues when the file has been written. Plus you can check for errors.. Hi, I was using autoit for this reason :-). I cannot approach lotus notes using COM without installing additional sofware I guess, and I haven't played witth notes APi's before. Using Autoit would be the easiest way in this case, but unfortunately you're less in control for this matter. Anyway is there no way to check if i file is saved using autoit instead of COM, checking "file in use" in a loop or something like that? Regards, Boein Link to comment Share on other sites More sharing options...
Yashied Posted January 27, 2015 Share Posted January 27, 2015 _WinAPI_FileInUse() My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
boein Posted January 27, 2015 Author Share Posted January 27, 2015 _WinAPI_FileInUse() Thanks, but this one also does not seem to wait long enough Imagine this:Lotus Notes client is open then - file - save attachment $clipfile = "h:somepdf.pdf" send("!s") while fileexists($clipfile) = 0 wend while _WinAPI_FileInUse ($clipfile) = 1 sleep(1000) wend msgbox ($mb_systemmodal,"",$clipfile) When executing this script, on the notes client, in the status bar I can see saving somepdf.pdf10% saving somepdf.pdf 50% saving somepdf.pdf 90% saving somepdf.pdf100% but before reaching 100% I already got the msgbox from autoit displayed, meaning autoit doesn's wait before the file save is completed. Regards, Boein regards, Boein Link to comment Share on other sites More sharing options...
water Posted January 27, 2015 Share Posted January 27, 2015 Or use _WinAPI_LockFile to get exclusive access to the file. If successful the file has been fully written. Don't forget to release the file again. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
boein Posted January 27, 2015 Author Share Posted January 27, 2015 $clipfile = "h:somepdf.pdf" send("!s") sleep(1000) while fileexists($clipfile) = 0 wend while _WinAPI_FileInUse ($clipfile) = 1 sleep(1000) wend msgbox ($mb_systemmodal,"",$clipfile) Hi all, Maybe the _WinAPI_FileInUse was working after all. I put a sleep of 1sec between the "save" and start of _WinAPI_FileInUse check and that seems to work. Even a file that takes >5 secs to save seems to wait. I guess you need to put a tiny break between issuing the "save" and the first check to see if the file is in use, otherwise autoit is too fast and already did the fileinuse check before the save was started? But strange thing is that the fileexists routine did not prevent to wait until the file was created. Anyway sleeping 1sec is acceptable for me :-) Reagards Boein Link to comment Share on other sites More sharing options...
alienclone Posted January 27, 2015 Share Posted January 27, 2015 instead of just checking to see if the file exists, tell the script to wait until the file exists. $clipfile = "h:\somepdf.pdf" send("!s") do sleep(100) until fileexists($clipfile) while _WinAPI_FileInUse ($clipfile) = 1 sleep(1000) wend msgbox ($mb_systemmodal,"",$clipfile) If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
benched42 Posted January 27, 2015 Share Posted January 27, 2015 I use Yashied's Copy UDF. Lots of options within that. I've used it successfully to copy across our company WAN to locations across the globe. '?do=embed' frameborder='0' data-embedContent>> Who lied and told you life would EVER be fair? 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