Results 1 to 3 of 3

Thread: finding colour under cursor

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Sydney Australia
    Posts
    20

    Exclamation

    hiya all,

    I would like to know how I would be able to find the colour that is underneath the cursor. eg same as in Photoshop where you can set a colour by putting your mouse over the colour you want.

    But I want to be able to do this over the desktop and over other programs.

    I have no idea on how to do this and any help would be most apreashiated.

    Thanks
    Remember www.mos.net.au for all your computer needs.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    'Put all this in a module
    Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function GetDesktopWindow Lib "user32" () As Long
    Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
    Type POINTAPI
            X As Long
            Y As Long
    End Type
    
    Function coloratcursor() as long
    Dim pa As POINTAPI
    GetCursorPos pa
    coloratcursor = GetPixel(GetWindowDC(GetDesktopWindow), pa.X, pa.Y)
    End Function
    OnColorClick 50, 100, vbYellow
    And call Coloratcursor and it will return the color
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Sydney Australia
    Posts
    20

    thanks

    thanks..

    that is what i was after
    Remember www.mos.net.au for all your computer needs.

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