Vb.net Net中的颜色变化类似于Autoit
我有一个简单的pixelsearch函数,可以在屏幕上搜索特定的Argb颜色。 这已经很好用了,它可以找到带有颜色的像素,但我想给它添加一个颜色变化检测 它应该检测的像素的颜色有时会从(255、100、100、100)更改为(255、110、94、102)或其他(值会更改10个点)。现在,Pixelsearch函数应该有一个Variationdetection,这样它就可以检测到颜色相近的像素,而不是只搜索颜色(255、100、100、100),它还应该搜索(255、101、99、102)。。。还有更多 是否可以对其进行编码,而不是将每种颜色调暗并搜索 这就是我已经掌握的代码:Vb.net Net中的颜色变化类似于Autoit,vb.net,variations,Vb.net,Variations,我有一个简单的pixelsearch函数,可以在屏幕上搜索特定的Argb颜色。 这已经很好用了,它可以找到带有颜色的像素,但我想给它添加一个颜色变化检测 它应该检测的像素的颜色有时会从(255、100、100、100)更改为(255、110、94、102)或其他(值会更改10个点)。现在,Pixelsearch函数应该有一个Variationdetection,这样它就可以检测到颜色相近的像素,而不是只搜索颜色(255、100、100、100),它还应该搜索(255、101、99、102)。。。
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim xd3 = Color.FromArgb(255, 100, 100, 100) 'Searching for this color on the screen
Dim b As New Bitmap(2210, 1100) 'Position of Bitmap
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(b)
g.CopyFromScreen(Me.Left, Me.Top, 0, 0, b.Size) 'Searching on Screen
For i = 0 To (Me.Width - 0) 'searching each pixel
For j = 0 To (Me.Height - 0) 'searching each pixel
If b.GetPixel(i, j) = xd3 Then 'If pixel has same color that im searching for it will show a messagebox true
MessageBox.Show("true")
End If
Next
Next
End Sub
我建议这样做:
If Color_Is_In_The_Target_Variations(10, b.GetPixel(i, j), xd3) Then
MessageBox.Show("true")
End If
及
Private Function Color\u是作为布尔值的\u目标变量(变量为整数,测试为颜色,目标为颜色)
如果tested.R>=target.R-变异并被测试。R=target.G-变异并被测试。G=target.B-变异并被测试。B我建议如下:
If Color_Is_In_The_Target_Variations(10, b.GetPixel(i, j), xd3) Then
MessageBox.Show("true")
End If
及
Private Function Color\u是作为布尔值的\u目标变量(变量为整数,测试为颜色,目标为颜色)
如果tested.R>=target.R-variation And tested.R=target.G-variation And tested.G=target.B-variation And tested.B这正是我所需要的,非常感谢它工作得很好:)这是我的荣幸:)这正是我所需要的,非常感谢它工作得很好:)这是我的荣幸:)