Is there anyway to activate a window first, and then perform getpixel on that active window? Also, is there anyway to use the window title as the hwnd?Code:Public Class Form1 Public Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Integer, ByVal x As Int32, ByVal y As Int32) As Int32 Private Declare Function GetForegroundWindow Lib "user32" () As Integer Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Integer) As Integer Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Integer, ByVal hdc As Integer) As Integer Private Sub MSPaint() Dim HDC As Integer Dim hWnd As Integer = GetForegroundWindow() HDC = (GetWindowDC(hWnd)) If GetPixel(HDC, 400, 400) = &HFFFFFF Then MsgBox("Correct!") Else MsgBox("Fail!") End If ReleaseDC(hWnd, HDC) End Sub
For instance: Untitled - Paint instead of GetForegroundWindow.




Reply With Quote