Sign in to follow this  
Followers 0
Ashen

_ScreenCapture_SaveImage not saving images

5 posts in this topic

Hey Guys,

I am running a very simple code intended to create a screenshot of a part of my screen.

My problem is that only the first screenshot I take is saved (and even that doesn't always happen), but then after I call my function for the second time the older screenshot is not over-written (and if I delete the old screenshot then no new screenshot is created).

Here's my code:

#include <ScreenCapture.au3>

dim $sFilePath = "E:\tmp.BMP"
dim $OCR_Rectangle[4] = ["760", "480", "1068", "522"]

_ScreenCapture_SaveImage($sFilePath, _ScreenCapture_Capture("",$OCR_Rectangle[0], $OCR_Rectangle[1], $OCR_Rectangle[2], $OCR_Rectangle[3],False),True)

I am losing hope here, guys. Any chance any of you have any idea what's going on?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Why are you nesting the _ScreenCapture functions?
 
_ScreenCapture_Capture($sFilePath,$OCR_Rectangle[0], $OCR_Rectangle[1], $OCR_Rectangle[2], $OCR_Rectangle[3],False)

should also do it.

Br,
UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks for the input, UEZ, but I already tried that (and I re-tried it just now) and it still has the same results - no file is saved.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Check out the coordinates you want to capture -> it shouldn't be strings in this case because "760" is greater than "1068" and error -1 will be set.

#include <ScreenCapture.au3>

dim $sFilePath = "E:\tmp.BMP"
dim $OCR_Rectangle[4] = [760, 480, 1068, 522]
ConsoleWrite(_ScreenCapture_Capture($sFilePath,$OCR_Rectangle[0], $OCR_Rectangle[1], $OCR_Rectangle[2], $OCR_Rectangle[3],False) & @LF)

Unfortunately _ScreenCapture_Capture() doesn't convert the input to an integer value automatically.

 

Br,

UEZ

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks so much! that solved the problem instantly. You've saved me many an hour of frustration :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0