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 ;)
Printable View
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 ;)
it would probably take a while because you would have to step through every pixel on screen and then use the getpixel api call.
Well, could I have it search everytime I press a button.
And could I make it run while running another program?
-Thx ;)
i'll make a program to do it. it will probably take 10mins or so to run it.
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
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 ;)