Jump to content

_ScreenCapture/Save Image is blank!?


Recommended Posts

Hello everyone! So I've got a little problem here that I can't seem to be able to resolve. I've already searched the forums, and tried Google for any help, but no luck.

I'm quite new to AutoIt, although I love it's fairly ease-of-use language. I actually just started a few days ago and have decided to make a program from it with multiple features for a game. One of the features I am trying to add is a screenshot feature to take high quality pictures in-game and automatically save them within a folder.

This is where my problem begins, although my script is successful in creating the folder, and saving multiple screen captures, the scree captures turn out blank and I can't understand why. Maybe it's some thing quite simple, maybe not.

If anyone could point me in the right direction, or help me resolve this, I'd very much appreciate it.

Here's part of the code:

HotKeySet("{INSERT}", "pScreenshot")
Func pScreenshot()
    Local $hBmp
    DirCreate(@DesktopDir & "\TestCaptures\")

    $hBmp = _ScreenCapture_Capture("")
    _ScreenCapture_SaveImage(@DesktopDir & "\TestCaptures\RFscreenie_" & @HOUR & "_" & @MIN & "_" & @SEC & ".png", $hBmp)

EndFunc   ;==>pScreenshot

This is the part of the script that takes the screenshot. As you can see, by pressing the hotkey "INSERT", the script takes a capture and makes a folder on the desktop with the base name followed by the time the capture was taken at. But as I said, the capture comes out as all black and there is nothing on it otherwise. It does takes captures perfectly when I'm just doing it on the desktop, but if I take it within the game, it fails to have anything on it.

Thanks in advanced.

Link to comment
Share on other sites

  • 1 year later...

For games, you must use the _ScreenCapture_CaptureWnd function instead. I'm still having issues with screenshots of games in fullscreen mode where images is black on certain layers sometimes. In windowed mode, this works great. Try this for your case:

HotKeySet("{INSERT}", "pScreenshot")
Func pScreenshot()
    Local $folder = @DesktopDir & "\TestCaptures"
    DirCreate($folder)

    _ScreenCapture_CaptureWnd($folder & "\RFscreenie_" & @HOUR & "_" & @MIN & "_" & @SEC & ".png", WinGetHandle("[ACTIVE]"))
    
EndFunc   ;==>pScreenshot
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...