I have a code which I'm attempting to use that isn't working properly:
Here is the code (full/runable) *requires 1 button (B1), 1 richtextbox (R1), 1 timer (Timer1)
What the code is supposed to do, is scan the entire screen and add the found colors to a string list. The string list is then populated in the richtextbox after scanning is complete.
The error happening is: All Of The argb Pixels Are Being Detected As 0,0,0,0 (thinking its locked on 0,0 somehow, possibly?)
Any help would be greatly appreciated, example or patch even more :bigyello:
Thanks! :check:
Here is the code (full/runable) *requires 1 button (B1), 1 richtextbox (R1), 1 timer (Timer1)
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
Me.Opacity = 0
Me.Activate()
Me.BringToFront()
Timer1.Interval = 500
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim words As New List(Of String)
words.Clear()
Dim x As Integer
Dim y As Integer
Dim ScreenX As Integer
Dim ScreenY As Integer
Dim g As Graphics
Dim Img As Bitmap
Timer1.Stop()
ScreenX = My.Computer.Screen.Bounds.Width
ScreenY = My.Computer.Screen.Bounds.Height
g = Graphics.FromHwnd(Me.Handle)
g.CopyFromScreen(0, 0, ScreenX - 1, ScreenY - 1, New Size(ScreenX, ScreenY))
Img = New Bitmap(ScreenX, ScreenY, g)
For x = 0 To ScreenX - 1
For y = 0 To ScreenY - 1
words.Add(Img.GetPixel(x, y).ToString)
words.Add("Location: " & "X: " & x & " Y: " & y & " ")
' The Searched Color
If Img.GetPixel(x, y) = Color.FromArgb(255, 51, 134, 166) Then
g.Dispose()
MsgBox("Found Color!")
Exit Sub
End If
Next y
Next x
R1.Lines = words.ToArray
g.Dispose()
MsgBox("Done")
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Fixed3D
Me.WindowState = FormWindowState.Normal
Me.Opacity = 100
Me.Activate()
Me.BringToFront()
End Sub
End ClassThe error happening is: All Of The argb Pixels Are Being Detected As 0,0,0,0 (thinking its locked on 0,0 somehow, possibly?)
Any help would be greatly appreciated, example or patch even more :bigyello:
Thanks! :check: