[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.
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
Re: Need help.. Know what color the screen is
NVM i probebly miss understud you
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.
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)
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?
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
Re: Need help.. Know what color the screen is
Quote:
Originally Posted by Jazz00006
Yeah what are the odds of that :)
Ty.. I will check it out.
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 :)