mozart90 Posted March 22, 2006 Share Posted March 22, 2006 (edited) Hi I've got a problem. In my skript I have to wait until a file saving is finished so I can proceed loading the file in another application. The question is how can I find out when the file is written completly to disk. I 've tried it with the fileopen command, but I didn't get an error ... while 1 $file = fileopen("c:\testfile.bmp",1) if @error then continue loop else exit loop wend msgbox(0,"","Filewriting has finished") Any suggestions? Geetings Mozart90 Edited March 22, 2006 by mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
billmez Posted March 22, 2006 Share Posted March 22, 2006 (edited) Hi I've got a problem. In my skript I have to wait until a file saving is finished so I can proceed loading the file in another application. The question is how can I find out when the file is written completly to disk. I 've tried it with the fileopen command, but I didn't get an error ... while 1 $file = fileopen("c:\testfile.bmp",1) if @error then continue loop else exit loop wend msgbox(0,"","Filewriting has finished") Any suggestions? Geetings Mozart90 How is the file being written to disk, is it from the AutoIT script or another application? Edited March 22, 2006 by billmez Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted March 22, 2006 Moderators Share Posted March 22, 2006 This might work, but it depends on how the file is being written. While 1 $a_size = FileGetSize("c:\testfile.bmp") If $a_size == 0 Then Sleep(200) ContinueLoop Else Sleep(200) $b_size = FileGetSize("c:\testfile.bmp") If $a_size == $b_size Then ExitLoop EndIf WEnd MsgBox(0, "", "File has finished installing.") Link to comment Share on other sites More sharing options...
mozart90 Posted March 22, 2006 Author Share Posted March 22, 2006 ... the file is written from adobe acrobat. it is an jpg export from a hole page, which I want to crop with another proggi. (Starts with cmd line option jpg name). The saving in Acrobat time is very different, it depend on the amount of grafics on the page thats why i can't use a simple sleep(). the idea comparing the filesize I didn' tried yet because it failed with the Internet explorer.... Greetings Mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
billmez Posted March 22, 2006 Share Posted March 22, 2006 ...the file is written from adobe acrobat. it is an jpg export from a hole page, which I want to crop with another proggi. (Starts with cmd line option jpg name). The saving in Acrobat time is very different, it depend on the amount of grafics on the page thats why i can't use a simple sleep().the idea comparing the filesize I didn' tried yet because it failed with the Internet explorer....Greetings Mozart90Are you using AutoIT to save the file from Acrobat, or doing it manually? Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted March 22, 2006 Moderators Share Posted March 22, 2006 ...the file is written from adobe acrobat. it is an jpg export from a hole page, which I want to crop with another proggi. (Starts with cmd line option jpg name). The saving in Acrobat time is very different, it depend on the amount of grafics on the page thats why i can't use a simple sleep().the idea comparing the filesize I didn' tried yet because it failed with the Internet explorer....Greetings Mozart90Does Adobe not give you some kind of progress indicator while it is exporting? Link to comment Share on other sites More sharing options...
mozart90 Posted March 22, 2006 Author Share Posted March 22, 2006 Does Adobe not give you some kind of progress indicator while it is exporting?belive it or not this time it works (comparing the filesize)and yes there is a progress bar in the status line at the bottom fo the window...Is ther the possibility to 'read' this progress bar. @billmez I use some send() commands Mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
billmez Posted March 22, 2006 Share Posted March 22, 2006 belive it or not this time it works (comparing the filesize)and yes there is a progress bar in the status line at the bottom fo the window...Is ther the possibility to 'read' this progress bar. @billmez I use some send() commands Mozart90If that works, stay with it. Otherwise, is there another command you can send to Acrobat after the send commands you are currently using that will not complete until the file is saved (like file-close). If so, you can insert that in your command chain and then do your file processing after it. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted March 22, 2006 Moderators Share Posted March 22, 2006 belive it or not this time it works (comparing the filesize)and yes there is a progress bar in the status line at the bottom fo the window...Is ther the possibility to 'read' this progress bar. @billmez I use some send() commands Mozart90If you can get the controlID you may be able to use ControlCommand( "title", "text", controlID,"IsVisible", ""). Link to comment Share on other sites More sharing options...
jvanegmond Posted March 22, 2006 Share Posted March 22, 2006 (edited) From help FileOpen: Success: Returns a file "handle" or use with subsequent file functions. Failure: Returns -1 if error occurs. -1 is not 0 so it's true.. Might want to look at that. I'm not sure. Else use this: FileExists Edited March 22, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
billmez Posted March 22, 2006 Share Posted March 22, 2006 From help FileOpen:Success: Returns a file "handle" or use with subsequent file functions. Failure: Returns -1 if error occurs. -1 is not 0 so it's true.. Might want to look at that. I'm not sure.Else use this: FileExistsHe is not opening a file through AutoIT, it is being opened and saved through Adobe Acrobat. FileExists will return true as long as the file is there, even if it is still open and being written to. That is his original problem, finding when the file is completed. Link to comment Share on other sites More sharing options...
seandisanti Posted March 22, 2006 Share Posted March 22, 2006 belive it or not this time it works (comparing the filesize)and yes there is a progress bar in the status line at the bottom fo the window...Is ther the possibility to 'read' this progress bar. @billmez I use some send() commands Mozart90i'd say to watch the progress bar, check out PixelGetColor() or PixelChecksum() either could easily be used to tell when the progress bar has completed. Link to comment Share on other sites More sharing options...
jvanegmond Posted March 22, 2006 Share Posted March 22, 2006 i'd say to watch the progress bar, check out PixelGetColor() or PixelChecksum() either could easily be used to tell when the progress bar has completed.My idea, sometimes the title changes or a window closes. In that case it is Really easy. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted March 22, 2006 Moderators Share Posted March 22, 2006 (edited) Like I said, you can use ControlCommand(). This works on Adobe Standard 6.0: While 1 $IsVisible = ControlCommand("Adobe Acrobat Standard", "", "AVL_AVView13", "IsVisible", "") If $IsVisible == 1 Then MsgBox(0, "", "IS Visible!!!", 1) If $IsVisible == 0 Then MsgBox(0, "", "NOT Visible!!!", 1) Sleep(1000) WEnd Edited March 22, 2006 by big_daddy Link to comment Share on other sites More sharing options...
blindwig Posted March 23, 2006 Share Posted March 23, 2006 the quick and easy way: Dim $i1=1, $i2=2 While $i1 <> $i2 or $i1 = 0 $i1 = FileGetSize($FileName) Sleep(5000) $i1 = FileGetSize($FileName) Wend Basically, if the file stops growing, then you can assume it's done. Not as elegant as watching for a known progress bar, but it is easier to re-use. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
UmeshS Posted March 13, 2009 Share Posted March 13, 2009 Has anyone tried to use _WinAPI_WaitForSingleObject() UDF to accomplish waiting for a file to complete writing (without busy waiting, i.e. polling with sleep() )? Thanks. Umesh 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