用VB编写在指定窗体内自动找色,找图,找到以后鼠标自动移动上去点击一下!
用VB编写在指定窗体内自动找色,找图,找到以后鼠标自动移动上去点击一下!(含详细代码!及说明)高分处理!用VB编写在指定窗体内自动找颜色,找到以后鼠标自动移动上去点击一下...
用VB编写在指定窗体内自动找色,找图,找到以后鼠标自动移动上去点击一下! (含详细代码!及说明)高分处理!
用VB编写在指定窗体内自动找颜色,找到以后鼠标自动移动上去点击一下! (含详细代码!及说明)高分处理! 展开
用VB编写在指定窗体内自动找颜色,找到以后鼠标自动移动上去点击一下! (含详细代码!及说明)高分处理! 展开
2个回答
展开全部
你是在用VB写挂吧?呵呵。不要用这种LJ思路做挂。对于网络游戏,你要学会封包的操作。网上有很多有关的。你可以看一下。对于单机游戏。那更是没得说。只要改一下内存就行了。可以说太容易了。
如果你非要找图的话。这里有点资料。
'下面是屏幕找色实例,请根据实际情况进行验证。
Option Explicit
'定义一个POINTAPI
Private Type POINTAPI
x As Long
y As Long
End Type
'定义一个找色区域
Private Type RECT
Left As Long '区域坐标x
Top As Long '区域坐标y
Right As Long '区域宽
Bottom As Long '区域高
End Type
'Windows API 声明
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
'测试颜色函数,给定屏幕任意找色区域值,返回坐标位置
Private Function ifColor(x As RECT, ByVal color As Long) As POINTAPI
On Error Resume Next
Dim nTmpColor As Long, i As Long, j As Long
For i = x.Left To x.Left + x.Right
For j = x.Top To x.Top + x.Bottom
nTmpColor = GetPixel(GetDC(0), i, j)
If color = nTmpColor Then
ifColor.x = i
ifColor.y = j
Exit Function
End If
DoEvents
Next
Next
End Function
Private Sub Command1_Click() '全屏幕找色,时间花费较长
Dim t As POINTAPI, m As RECT
With m
.Top = 0
.Left = 0
.Bottom = Screen.Height / Screen.TwipsPerPixelY
.Right = Screen.Width / Screen.TwipsPerPixelX
End With
t = ifColor(m, 1447073)
Debug.Print t.x, t.y
End Sub
Private Sub Command2_Click() '某区域找色,时间花费少
Dim t As POINTAPI, m As RECT
With m
.Top = 300
.Left = 300
.Bottom = 100
.Right = 100
End With
t = ifColor(m, RGB(0, 125, 125))
Debug.Print t.x, t.y
End Sub
API函数GetPixel就可以得到颜色值了,但找图难度太高,往往通过对指定的几个像素的颜色来判断。并且问题的表述也不是很清楚。
建议你多看一些有关的教程。看样你是初做挂吧。我也在学习这方面的知识。
对于鼠标的操作之类的API网上太多了。随便一搜索就行了。
声明在这里给你写了Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
这是移动的函数。如果要点击就是要用sendmessage函数了。你可以自己看一下
如果你非要找图的话。这里有点资料。
'下面是屏幕找色实例,请根据实际情况进行验证。
Option Explicit
'定义一个POINTAPI
Private Type POINTAPI
x As Long
y As Long
End Type
'定义一个找色区域
Private Type RECT
Left As Long '区域坐标x
Top As Long '区域坐标y
Right As Long '区域宽
Bottom As Long '区域高
End Type
'Windows API 声明
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
'测试颜色函数,给定屏幕任意找色区域值,返回坐标位置
Private Function ifColor(x As RECT, ByVal color As Long) As POINTAPI
On Error Resume Next
Dim nTmpColor As Long, i As Long, j As Long
For i = x.Left To x.Left + x.Right
For j = x.Top To x.Top + x.Bottom
nTmpColor = GetPixel(GetDC(0), i, j)
If color = nTmpColor Then
ifColor.x = i
ifColor.y = j
Exit Function
End If
DoEvents
Next
Next
End Function
Private Sub Command1_Click() '全屏幕找色,时间花费较长
Dim t As POINTAPI, m As RECT
With m
.Top = 0
.Left = 0
.Bottom = Screen.Height / Screen.TwipsPerPixelY
.Right = Screen.Width / Screen.TwipsPerPixelX
End With
t = ifColor(m, 1447073)
Debug.Print t.x, t.y
End Sub
Private Sub Command2_Click() '某区域找色,时间花费少
Dim t As POINTAPI, m As RECT
With m
.Top = 300
.Left = 300
.Bottom = 100
.Right = 100
End With
t = ifColor(m, RGB(0, 125, 125))
Debug.Print t.x, t.y
End Sub
API函数GetPixel就可以得到颜色值了,但找图难度太高,往往通过对指定的几个像素的颜色来判断。并且问题的表述也不是很清楚。
建议你多看一些有关的教程。看样你是初做挂吧。我也在学习这方面的知识。
对于鼠标的操作之类的API网上太多了。随便一搜索就行了。
声明在这里给你写了Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
这是移动的函数。如果要点击就是要用sendmessage函数了。你可以自己看一下
参考资料: http://zhidao.baidu.com/question/82338883.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询