按键精灵9能实现后台拖动吗
Delay300HandleArray=Plugin.BGCP2_02.LoadBMP("C:\Users\Administrator\Desktop\新建文件夹(4)\...
Delay 300
HandleArray=Plugin.BGCP2_02.LoadBMP("C:\Users\Administrator\Desktop\新建文件夹 (4)\QQ截图20150607222851.bmp")
Call Plugin.BGCP2_02.FindPicture(hwnd, 0, 0,1024, 768 ,HandleArray(0),30,0.9,intX1,intY1)
If intX1 > 0 And intY1 > 0 Then
Call Plugin.Bkgnd.MoveTo(Hwnd, intX1, intY1)
Call Plugin.Bkgnd.LeftDown(Hwnd, intX1, intY1)
Delay 300
HandleArray=Plugin.BGCP2_02.LoadBMP("C:\Users\Administrator\Desktop\新建文件夹 (4)\QQ截图20150609182157.bmp")
Call Plugin.BGCP2_02.FindPicture(hwnd, 0, 0,1024, 768 ,HandleArray(0),30,0.9,intX6,intY6)
If intX6 > 0 And intY6 > 0 Then
Call Plugin.Bkgnd.MoveTo(Hwnd, intX6, intY6)
End If
Call 分解
End If
Goto 开始找图
Sub 分解
HandleArray=Plugin.BGCP2_02.LoadBMP("C:\Users\Administrator\Desktop\新建文件夹 (4)\QQ截图20150607223300.bmp")
Call Plugin.BGCP2_02.FindPicture(hwnd, 0, 0,1024, 768 ,HandleArray(0),30,0.9,intX2,intY2)
If intX2 > 0 And intY2 > 0 Then
Delay 300
Call Plugin.Bkgnd.MoveTo(Hwnd, intX2, intY2)
Delay 300
Call Plugin.Bkgnd.LeftUp(Hwnd, intX2, intY2)
Delay 300
End If
End Sub
这个拖动部分的代码,可以后台识图点击,但是按下左键拖动,弹起就不行了,求解 展开
HandleArray=Plugin.BGCP2_02.LoadBMP("C:\Users\Administrator\Desktop\新建文件夹 (4)\QQ截图20150607222851.bmp")
Call Plugin.BGCP2_02.FindPicture(hwnd, 0, 0,1024, 768 ,HandleArray(0),30,0.9,intX1,intY1)
If intX1 > 0 And intY1 > 0 Then
Call Plugin.Bkgnd.MoveTo(Hwnd, intX1, intY1)
Call Plugin.Bkgnd.LeftDown(Hwnd, intX1, intY1)
Delay 300
HandleArray=Plugin.BGCP2_02.LoadBMP("C:\Users\Administrator\Desktop\新建文件夹 (4)\QQ截图20150609182157.bmp")
Call Plugin.BGCP2_02.FindPicture(hwnd, 0, 0,1024, 768 ,HandleArray(0),30,0.9,intX6,intY6)
If intX6 > 0 And intY6 > 0 Then
Call Plugin.Bkgnd.MoveTo(Hwnd, intX6, intY6)
End If
Call 分解
End If
Goto 开始找图
Sub 分解
HandleArray=Plugin.BGCP2_02.LoadBMP("C:\Users\Administrator\Desktop\新建文件夹 (4)\QQ截图20150607223300.bmp")
Call Plugin.BGCP2_02.FindPicture(hwnd, 0, 0,1024, 768 ,HandleArray(0),30,0.9,intX2,intY2)
If intX2 > 0 And intY2 > 0 Then
Delay 300
Call Plugin.Bkgnd.MoveTo(Hwnd, intX2, intY2)
Delay 300
Call Plugin.Bkgnd.LeftUp(Hwnd, intX2, intY2)
Delay 300
End If
End Sub
这个拖动部分的代码,可以后台识图点击,但是按下左键拖动,弹起就不行了,求解 展开
1个回答
展开全部
可以试试让鼠标一次移动极少的距离,通过多次的移动最终到达目标坐标,以此来模拟鼠标移动。
以下是前台的操作,主要是展示原理,你也可以不看,反正我看着也头晕。
Dim OriginX, OriginY, DestinationX, DestinationY
//起点和终点的横纵坐标
Dim SignedDistanceX, SignedDistanceY
//两点之间的横纵距离(有符号)
Dim UnsignedDistanceX, UnsignedDistanceY
//两点之间的横纵距离(无符号)
Dim Times,TempTimes
//鼠标移动的次数
/*
以下是调试部分
OriginX = 0
OriginY = 0
DestinationX = 500
DestinationY = 500
*/
SignedDistanceX = DestinationX - OriginX
SignedDistanceY = DestinationY - OriginY
UnsignedDistanceX = Abs(SignedDistanceX)
UnsignedDistanceY = Abs(SignedDistanceY)
//Abs()函数返回数字的绝对值
If UnsignedDistanceX >= UnsignedDistanceY Then
Times = UnsignedDistanceY
ElseIf UnsignedDistanceX < UnsignedDistanceY Then
Times = UnsignedDistanceX
End If
//得到鼠标需要移动的次数
For TempTimes = 1 to Times
MoveTo TempTimes * SignedDistanceX / Times + OriginX, TempTimes * SignedDistanceY / Times + OriginY
Delay 1
Next
下面是我据此写的一个调用过程(可后台),你可以把它放在你的命令库里,以便直接调用。
具体方法是:点开我的命令库前面的加号,在其中一个上右键(如“键盘”),新建。
代码在此
Sub 模拟鼠标移动【无句柄取负一】(起点横坐标,起点纵坐标,终点横坐标,终点纵坐标,句柄)
SignedDistanceX = 终点横坐标 - 起点横坐标
SignedDistanceY = 终点纵坐标 - 起点纵坐标
UnsignedDistanceX = Abs(SignedDistanceX)
UnsignedDistanceY = Abs(SignedDistanceY)
//Abs()函数返回数字的绝对值
If UnsignedDistanceX >= UnsignedDistanceY Then
Times = UnsignedDistanceY
ElseIf UnsignedDistanceX < UnsignedDistanceY Then
Times = UnsignedDistanceX
End If
//得到鼠标需要移动的次数
If 句柄 = - 1 Then
For TempTimes = 1 To Times
MoveTo TempTimes * SignedDistanceX / Times + 起点横坐标, TempTimes * SignedDistanceY / Times + 起点纵坐标
Delay 1
Next
Else
If Plugin.Window.IsWindow(句柄) = 0 Then
MessageBox "窗口不存在"
Else
For TempTimes = 1 To Times
Call Plugin.Bkgnd.MoveTo(句柄, TempTimes * SignedDistanceX / Times + 起点横坐标, TempTimes * SignedDistanceY / Times + 起点纵坐标)
Delay 1
Next
End If
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询