How to detect if a screenshot is all black? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rc76
Posts: 153
Joined: 07 Nov 2020, 01:45

How to detect if a screenshot is all black?

24 May 2024, 05:17

Hi,

I uses gdip to get screenshot of my screen.

I sometimes get a "whole black" screenshot from my gdip function, I am wondering is there anyway I can "detect" the returned image is all black, by:
- return a value of 1 if entire screenshot picture is black
- return a value of 0 if not entirely black

here is my gdip function to get screenshot:

Code: Select all

TakePic_Desktop(){

  filename := "DesktopScreenshot.png"

  SaveImageFromScreen(Filename,0,0,1680,1050)

 ; If "filename" is all black png, than return 1, else return 0

  return
}

#Include Gdip.ahk
SaveImageFromScreen(Filename,X,Y,Width,Height) {
  pToken := Gdip_StartUp()
  pArg := X . "|" . Y . "|" . Width . "|" . Height
  pBitmap := Gdip_BitmapFromScreen(pArg)
  Gdip_SaveBitmapToFile(pBitmap,Filename)
  Gdip_DisposeImage(pBitmap)
  Gdip_Shutdown(pToken)
}
Thank you so much!
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How to detect if a screenshot is all black?  Topic is solved

24 May 2024, 06:35

Hello,

This might be done simply by ImageSearch if you search for a black image and then check the ErrorLevel from the search.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: peter_ahk and 357 guests