Results 1 to 2 of 2

Thread: Using GetPixel on entire screen?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Using GetPixel on entire screen?

    Is there any way to use GetPixel on the screen no matter what programs are shown or desktop? GetPixel needs the handle as the parameter. I just want to know the color of anywhere that is shown on the screen no matter what program it is and not worry about the handle.

    Is this possible?

    Thanks

  2. #2
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Using GetPixel on entire screen?

    VB Code:
    1. Private Declare Function GetDesktopWindow Lib "user32" () As Long
    2. Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
    3. Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    4.  
    5. Private Sub Command1_Click()
    6.   Dim dhwnd As Long
    7.   Dim dhdc As Long
    8.   Dim color As Long
    9.   Dim x As Long
    10.   Dim y As Long
    11.  
    12.   dhwnd = GetDesktopWindow
    13.   dhdc = GetWindowDC(dhwnd)
    14.   color = GetPixel(dhdc, x, y)
    15. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width