|
-
Aug 13th, 2007, 08:46 PM
#1
Thread Starter
Member
[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.
-
Aug 13th, 2007, 08:50 PM
#2
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.
-
Aug 13th, 2007, 08:50 PM
#3
Addicted Member
Re: Need help.. Know what color the screen is
NVM i probebly miss understud you
vb Code:
If(this post = helped you) then
You.rate = me
End if
 
**Fazi's idea =]
-
Aug 13th, 2007, 10:00 PM
#4
Thread Starter
Member
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.
-
Aug 13th, 2007, 10:37 PM
#5
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.
-
Aug 14th, 2007, 12:02 AM
#6
Thread Starter
Member
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?
-
Aug 14th, 2007, 12:19 AM
#7
Addicted Member
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
-
Aug 14th, 2007, 12:22 AM
#8
Thread Starter
Member
Re: Need help.. Know what color the screen is
 Originally Posted by Jazz00006
Yeah what are the odds of that 
Ty.. I will check it out.
-
Aug 14th, 2007, 01:06 AM
#9
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|