|
-
Jun 8th, 2002, 01:09 PM
#1
Thread Starter
Member
¿ Searching for a color ?
How do I make VB search the computer screen for a certain color pixel, then have it center the mouse on it? Could I make this work while running a different program and having this run in the background???
-Thx

- Sk
-
Jun 8th, 2002, 01:12 PM
#2
Frenzied Member
it would probably take a while because you would have to step through every pixel on screen and then use the getpixel api call.
-
Jun 8th, 2002, 01:14 PM
#3
Thread Starter
Member
Well, could I have it search everytime I press a button.
And could I make it run while running another program?
-Thx

- Sk
-
Jun 8th, 2002, 01:26 PM
#4
Frenzied Member
i'll make a program to do it. it will probably take 10mins or so to run it.
-
Jun 8th, 2002, 01:30 PM
#5
Frenzied Member
VB Code:
'Declaration
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
'Code to check
Dim CurrentPixel As Long
For i = 0 To Screen.Width Step Screen.TwipsPerPixelX
For j = 0 To Screen.Height Step Screen.TwipsPerPixelY
CurrentPixel = GetPixel(0, i, j)
If RGB(192, 192, 192) = CurrentPixel Then 'replace with your color!
'do something
End If
Next j
Next i
-
Jun 8th, 2002, 02:04 PM
#6
Thread Starter
Member
I tried that and for some reason it didn't work...
And I know what I put in has R:0 G:191 B:0
Maybe it's just me, but I put this code:
VB Code:
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyL Then
Dim CurrentPixel As Long
For i = 0 To Screen.Width Step Screen.TwipsPerPixelX
For j = 0 To Screen.Height Step Screen.TwipsPerPixelY
CurrentPixel = GetPixel(0, i, j)
If RGB(0, 191, 0) = CurrentPixel Then 'replace with your color!
'do something
MsgBox "x:" & i & "y:" & j
End
End If
Next j
Next i
End If
End Sub
Thanks 4 that much
Oh, and how do I make this work whenever I press L, even if I am in a different program?
And what id the ''ByVal hdc As Long'' mean?
- Thank you very much 4 helping me

- Sk
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
|