Basically what i am doing is letting the user select a point on the screen(x,y)
Then i use a Loop to:
get a screenshot of this as a 1 by 1 bitmap.
load it into a picturebox
I then use getpixel on this bmp to get color
Then i check if the green value of the pixel is > 220
if it is i exit my loop
Then i perform what i need to.
The problem is that the pixel changes quickly and i am having to keep re-writing the bitmap image waiting for the change. By the the the pixel has turned green and already changed colors.
I am trying to get the mouse to click, the instant the pixel turns greens, but it has been delayed a bit.
Is there a better way to monitor a pixel on the screen was a faster "reaction time".
I read about getdibits() but since i am getting a new bitmap everytime the pixel is not green, i do not think dibits would help. Also it seemed a little complicated if i was not gonna get a performance gain.
Private Sub MonitorPixel()
Dim xAxis As Integer
Dim yAxis As Integer
Dim bmp As New Bitmap(1, 1, PixelFormat.Format32bppArgb)
Dim gr As Graphics = Graphics.FromImage(bmp)
Dim MyColor As Color = color.black 'Reset Color to non-green color
Do Until MyColor.G > 225
gr.CopyFromScreen(xAxis, yAxis, 0, 0, New Size(2, 2), CopyPixelOperation.SourceCopy)
PictureBox1.Image = bmp
MyColor = bmp.GetPixel(0, 0)
Loop
SetMousePos(xAxis, yAxis)
LeftClick()
End Sub
Then i use a Loop to:
get a screenshot of this as a 1 by 1 bitmap.
load it into a picturebox
I then use getpixel on this bmp to get color
Then i check if the green value of the pixel is > 220
if it is i exit my loop
Then i perform what i need to.
The problem is that the pixel changes quickly and i am having to keep re-writing the bitmap image waiting for the change. By the the the pixel has turned green and already changed colors.
I am trying to get the mouse to click, the instant the pixel turns greens, but it has been delayed a bit.
Is there a better way to monitor a pixel on the screen was a faster "reaction time".
I read about getdibits() but since i am getting a new bitmap everytime the pixel is not green, i do not think dibits would help. Also it seemed a little complicated if i was not gonna get a performance gain.
Private Sub MonitorPixel()
Dim xAxis As Integer
Dim yAxis As Integer
Dim bmp As New Bitmap(1, 1, PixelFormat.Format32bppArgb)
Dim gr As Graphics = Graphics.FromImage(bmp)
Dim MyColor As Color = color.black 'Reset Color to non-green color
Do Until MyColor.G > 225
gr.CopyFromScreen(xAxis, yAxis, 0, 0, New Size(2, 2), CopyPixelOperation.SourceCopy)
PictureBox1.Image = bmp
MyColor = bmp.GetPixel(0, 0)
Loop
SetMousePos(xAxis, yAxis)
LeftClick()
End Sub