Hi All,
I'm having issues with my bejeweled bot picking up colors from my timer which is connected to a picturebox which is allowing me to select the rectangle based on the games location with the following code;
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles tmrRecognizeColors.Tick
Dim graph As Graphics
screenshot = New System.Drawing.Bitmap(rect.Width, rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(rect.X, rect.Y, 0, 0, rect.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Dim x, y As Integer
For x = 20 To 300 Step 40
For y = 30 To 310 Step 40
Dim c As Color = screenshot.GetPixel(x, y)
If c.R > 250 And c.G < 5 And c.B < 30 Then
Grid((((x - 20) / 40) + 1), (((y - 30) / 40) + 1)) = Color.Red
NumGrid((((x - 20) / 40) + 1), (((y - 30) / 40) + 1)) = 1
Then problem i'm having is that the colors are for a different game, and it's not detecting the read properly.
The actual color for red is red: 236,Green: 133, Blue: 110 but i've tried changing this and it still isn't working based on the use of either '> or <' and i've tried using for example;
If c.R = "236" And c.G = "133" And c.B = "110" Then
Grid((((x - 20) / 40) + 1), (((y - 30) / 40) + 1)) = Color.Red
NumGrid((((x - 20) / 40) + 1), (((y - 30) / 40) + 1)) = 1
But it isn't successful.
Any idea how i can overcome this issue?
What I have tried:
Changing the values based on the rgb color in the game i'm using.