Hi,
I'm evaluating MacroScheduler for purchase.
I have a loop in which I run the ScreenCapture command to save a screenshot to a particular file.
The filename does not change on each loop because there are several thousand iterations and I don't want to flood my hard drive with screenshot images.
Everything works perfectly on the first loop, but the second time around, I get an error # 2 from SCREENCAP_RESULT indicating the image could not be saved to the specified file.
I've done some testing and can only guess that this may be a result of that image not being released by whatever process is saving to it so that by the time the next ScreenCapture command is run, the image is still locked.
Is there any validity to this suspicion, and if so, is there a way to force the release of that file?
Incidentally, each loop takes roughly 2 minutes to complete, so I can't imagine it's just moving too fast for my OS.
Finally, I have tried saving the screenshots to separate files on each loop and it works fine, so there doesn't appear to be any syntax problems with my code.
Thanks in advance for any help!
Problems with ScreenCapture Loop
Moderators: JRL, Dorian (MJT support)
This sample code works fine for me. I'm using MS ver 10.1.21 on XP service pack 3 inside a VMWare virtual machine.
[code]
Label>Loop
ScreenCapture>10,10,200,200,c:\mypic.bmp
If>SCREENCAP_RESULT>0
MessageModal>Error saving screencapture - %SCREENCAP_RESULT%
Endif
Wait>5
Goto>Loop
[/code]
I think we need to know more about your operating environment. Also can you post your code for us to look at?
[code]
Label>Loop
ScreenCapture>10,10,200,200,c:\mypic.bmp
If>SCREENCAP_RESULT>0
MessageModal>Error saving screencapture - %SCREENCAP_RESULT%
Endif
Wait>5
Goto>Loop
[/code]
I think we need to know more about your operating environment. Also can you post your code for us to look at?
The following loops 5 times and saves the captured screen to the same file name each time. This does not error for me....
I see adroege has just posted more or less the same thing. I'm using the latest version 12.1
I see adroege has just posted more or less the same thing. I'm using the latest version 12.1
Code: Select all
Let>kk=0
Label>Loop
ScreenCapture>0,0,100,100,%temp_dir%screencapturefile.jpg
Add>kk,1
If>kk=5
Exit>0
EndIf
Wait>2
Goto>Loop
Check your permissions in the folder where you are writing files. If you do not have "Full Control" you will not be able to delete existing files, even ones you created. The ability to create files only requires "Modify" or "Write" permissions. Try deleting or overwriting files manually to check how this works. You should not have these problems if you write to your personal file folders such as "My Documents", "My Pictures", or the SCRIPT_DIR where you are developing your script.Finally, I have tried saving the screenshots to separate files on each loop and it works fine, so there doesn't appear to be any syntax problems with my code.
If that is not the problem, notice the examples posted by adroege and JRL do ScreenCapture for only a small portion of the screen and include a small wait. This might make a difference if your script overtakes the machines caching capabilities (if that is possible). Also, JRL wrote a jpg file which is smaller.
Additions to original Post:
I noticed on my machine only local administrators can delete files on folders other than the users personal folders. A standard user will not be able to delete or overwrite files for example on on the root folder C:\.
I also ran this test with no problems:
Code: Select all
Let>xx=0
Repeat>xx
Let>xx=%xx%+1
ScreenCapture>0,0,1200,1000,%SCRIPT_DIR%\ScreenCaptureTest.bmp
Until>xx=100
Gale