

Return DllCall("SelectObject", "UInt", hdc, "UInt", hgdiobj) Return DllCall("CreateCompatibleBitmap", UInt, hdc, Int, w, Int, w) Return DllCall("CreateCompatibleDC", "UInt", hdc) Pc_hmObj := SelectObject(pc_hmCDC, pc_hmBmp)ĭllCall("PrintWindow", "UInt", pc_wID, "UInt", pc_hCDC, "UInt", 0)ĭllCall("BitBlt", "UInt", pc_hmCDC, "Int", 0, "Int", 0, "Int", 1, "Int", 1, "UInt", pc_hCDC, "Int", pc_x, "Int", pc_y, "UInt", 0xCC0020)ĭllCall("GetBitmapBits", "UInt", pc_hmBmp, "UInt", VarSetCapacity(pc_bits, 4, 0), "UInt", &pc_bits)ĭeleteObject(pc_hBmp), DeleteObject(pc_hmBmp)ĭllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC) Pc_hmBmp := CreateCompatibleBitmap(pc_hDC, 1, 1) Pc_hObj := SelectObject(pc_hCDC, pc_hBmp) Pc_hBmp := CreateCompatibleBitmap(pc_hDC, pc_w, pc_h) WinGetPos,, , pc_w, pc_h, ahk_id %pc_wID%

Pc_hDC := DllCall("GetDC", "UInt", pc_wID)

The pixel must be visible in other words, it is not possible to retrieve the pixel color of a window hidden behind another window.Ī window that is partially transparent or that has one of its colors marked invisible (TransColor) typically yields colors for the window behind itself rather than its own.To retrieve the pixel color from a window, which is out of screen (fully or partially), transparent/translucent, or behind (an)other window(s), use this function:
