numpad1::
window := "ahk_exe Code.exe"
hWnd := WinExist(window)
color := GetPixel(hWnd, 10, 10)
msgbox, %color%
return
GetPixel(hWnd, X, Y) {
hDC := DllCall("GetDC", "Ptr", hWnd, "Ptr")
hMDC := DllCall("CreateCompatibleDC", "Ptr", hDC, "Ptr")
WinGetPos,,, W, H, ahk_id %hWnd%
hBitmap := DllCall("CreateCompatibleBitmap", "Ptr", hDC, "UInt", W, "UInt", H, "Ptr")
hObj := DllCall("SelectObject", "Ptr", hMDC, "Ptr", hBitmap, "Ptr")
DllCall("PrintWindow", "Ptr", hWnd, "Ptr", hMDC, "UInt", 2)
COLORREF := DllCall("GetPixel", "Ptr", hMDC, "UInt", X, "UInt", Y)
DllCall("SelectObject", "Ptr", hMDC, "Ptr", hObj, "Ptr")
DllCall("DeleteDC", "Ptr", hMDC)
DllCall("DeleteObject", "Ptr", hBitmap)
DllCall("ReleaseDC", "Ptr", hWnd, "Ptr", hDC)
Return Format("{:#x}", (COLORREF & 0xFF) << 16 | (COLORREF >> 8 & 0xFF) << 8 | COLORREF >> 16)
}