-
-
Save J2TEAM/924ea793d7ccb86e4f90 to your computer and use it in GitHub Desktop.
Read pixel from hidden window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WinAPI.au3> | |
#include <WindowsConstants.au3> | |
Opt("WinTitleMatchMode", 2) | |
Local $hCompDC = _WinAPI_CreateCompatibleDC(0) | |
Local $tBMI = DllStructCreate($tagBITMAPINFO) | |
DllStructSetData($tBMI, 1, DllStructGetSize($tBMI) - 4) ; size of struct | |
DllStructSetData($tBMI, 2, 400) ; width | |
DllStructSetData($tBMI, 3, 400) ; height | |
DllStructSetData($tBMI, 4, 1) | |
DllStructSetData($tBMI, 5, 32) ; bits per pixel | |
$aDIB = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBMI), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'uint', 0) | |
$hGDIObj = $aDIB[0] | |
$hPtr = $aDIB[4] | |
_WinAPI_SelectObject($hCompDC, $hGDIObj) | |
$hPixelStruct = DllStructCreate("dword[160000]", $hPtr) | |
$hWnd = WinGetHandle("Paint") | |
$hWndDC = _WinAPI_GetDC($hWnd) | |
Local $iX = 20 | |
Local $iY = 20 | |
DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "ptr", $hCompDC, "int", 0) | |
$iColor = MsgBox(0, "Color", '0x' & Hex(DllStructGetData($hPixelStruct, 1, $iY * 400 + $iX + 1), 6)) | |
_WinAPI_ReleaseDC(0, $hCompDC) | |
_WinAPI_ReleaseDC($hWnd, $hWndDC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment