Results 1 to 9 of 9

Thread: [RESOLVED] Need help.. Know what color the screen is

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2007
    Posts
    59

    Resolved [RESOLVED] Need help.. Know what color the screen is

    I'm wanting to make a program which operation will be based on if the color of the center of the screen matches the one picked.. I'm not sure how this could be done.. Looking for any idea's at this point.. Ty for any help in advance..

    Need to make a vb program that can find out what color the center of the screen is, and compare it with a color selected.

  2. #2
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Need help.. Know what color the screen is

    Here is a method that Jazz00006 came up with.
    Code:
    Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
    Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
    Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    
     
    
     Type PointAPI
       x As Long
       y As Long
       End Type
       Public Type RECT
       Left As Long
       Top As Long
       Right As Long
       Bottom As Long
       End Type
    
     
    
    
     
    
    Dim SelWnd As Long
    Code:
    Private Sub Command1_Click()
        SCREENDC = GetDC(0)
        Label1.caption = GetPixel(SCREENDC, 500, 500) 
    End Sub
    
    Private Sub Command2_Click()
        if text1.text=label1.caption then msgbox("Same")
    End Sub
    Last edited by Mxjerrett; Aug 13th, 2007 at 08:55 PM.

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  3. #3
    Addicted Member Incures's Avatar
    Join Date
    May 2006
    Location
    south afrika
    Posts
    205

    Re: Need help.. Know what color the screen is

    NVM i probebly miss understud you
    vb Code:
    1. If(this post = helped you) then
    2. You.rate = me
    3. End if


    **Fazi's idea =]

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2007
    Posts
    59

    Re: Need help.. Know what color the screen is

    Mxjerrett hey.. Ty for that I can see its working buts not in the center of my screen I think it has to do with my screen resolution. is that a formula for finding which coordinates is the center?

    Edit I think I got it.. Just divide the resolution by 2 for each x and y.
    Last edited by 8bangerstang; Aug 13th, 2007 at 10:07 PM.

  5. #5
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Need help.. Know what color the screen is

    The coordinates I provided arent correct. They were an example. Replace
    Code:
    Label1.caption = GetPixel(SCREENDC, 500, 500)
    with,
    Code:
    Label1.caption = GetPixel(SCREENDC, screen.width, screen.height)

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2007
    Posts
    59

    Re: Need help.. Know what color the screen is

    I have it working like it should but when I run Medal of Honor it doesnt read the colors right anymore.. I set the screen resolution to the same and all..

    Any Ideas?

  7. #7
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: Need help.. Know what color the screen is

    You first need to get the window handle (hwnd) of your game, then when you have that you can use GetDC, and from there GetPixel.

    Amazingly I already made a source today for something similar to this.

    http://cruels.net/index.php?s=&showt...ndpost&p=48114

  8. #8

    Thread Starter
    Member
    Join Date
    Jul 2007
    Posts
    59

    Re: Need help.. Know what color the screen is

    Quote Originally Posted by Jazz00006
    You first need to get the window handle (hwnd) of your game, then when you have that you can use GetDC, and from there GetPixel.

    Amazingly I already made a source today for something similar to this.

    http://cruels.net/index.php?s=&showt...ndpost&p=48114

    Yeah what are the odds of that

    Ty.. I will check it out.

  9. #9

    Thread Starter
    Member
    Join Date
    Jul 2007
    Posts
    59

    Re: Need help.. Know what color the screen is

    ok got it working in the game but my send keys arent going to the game .. trying to send pressing the p button left mouse click would prolly work better though.. Thanks again jazz

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