[Visual Basic] 纯文本查看 复制代码Dim WindowsCount//定义一个变量,存入要多开的窗口数量
WindowsCount = 0//变量赋值为0
Dim Windows(999)//定义一个数组,用来存入游戏句柄,可存入1000个游戏窗口,我想应该也许大概可能没人能开1000个游戏窗口吧,要是开1000个记事本窗口我也是服的
Dim i, j, ClickType
MessageBox "先设置每个窗口的句柄,需要多少填多少,没有留空!"
Do //循环 配合loop使用 exit do跳出循环
Delay 200
//If boBox1.ListIndex = 0 Then
MessageBox "获取句柄模式: 注意!"&vbcr&"在需要获取的窗口内单击鼠标,提示成功后进行相关即可!"
do
ClickType = WaitClick()
Windows(WindowsCount) = Plugin.Window.MousePoint()
//Call Plugin.Sys.SetCLB(Hwnd) 这句也不需要了,我注释掉了
i = msgbox("句柄:"&Windows(WindowsCount)&vbcr&"获取句柄成功!!!"&vbcr&"需要再次获取,点击确定继续!取消退出此模式!", vbOKCancel, "获取句柄模式")
If i = 2 Then
//EndScript 这里应该是有问题的,代码应该改成 Exit Do
Exit Do
//============================以下为我添加的代码
Else
WindowsCount = WindowsCount + 1//添加一个判断,继续添加游戏窗口则WindowsCount自增1
If WindowsCount > 999 Then //如果窗口数大于1000个,则不能再添加游戏窗口了
MessageBox "您添加的游戏窗口过多,自动结束添加游戏窗口操作"
Exit Do
End If
//============================以上为我添加的代码
End If
loop
//ElseIf boBox1.ListIndex = 1 Then
//Exit Do
//End If
loop
MessageBox "多窗口操作模式:"&vbcr&"注意看很重要!!!!!!"&vbcr&"首次需要绑定主窗口句柄,请在主操作模拟器内点击鼠标左键,绑定之后进行任意点击,其它已设置句柄的窗口模拟器会复制相同操作!"
//============================以下为我添加的带代码
Dim WindowRect, WindowRectS, RectEx, MousePosX, MousePosY, Cursor_OffsetX, Cursor_OffsetY//定义WindowRect变量获取主窗口大小,定义RectEx变量方便用来操作
Do
ClickType = WaitClick()
WindowRect = Plugin.Window.GetClientRect(Windows(0))
RectEx = split(WindowRect, "|")
GetCursorPos MousePosX, MousePosY
SaveMousePos
Cursor_OffsetX = MousePosX - RectEx(0)
Cursor_OffsetY = MousePosY - RectEx(1)
//主窗口操作完毕,偏移也获取完毕,接下来的就是对其余的游戏窗口进行操作了
For j = 1 To WindowsCount
Call Plugin.Window.Show(Windows(j))
WindowRect = Plugin.Window.GetClientRect(Windows(j))
RectEx = split(WindowRect, "|")
MoveTo RectEx(0) + Cursor_OffsetX, RectEx(1) + Cursor_OffsetY
Delay 10
Select Case ClickType
Case 0
//这里可以判断鼠标是左键单击还是右键单击、双击等
Case Else
LeftClick 1
End Select
Next
Call Plugin.Window.Show(Windows(0))
RestoreMousePos
Loop
//============================以上为我添加的代码,往下的代码可以不用了
//还想完善一下,但是也不早了,明天得努力工作,代码就先这样子了。。。。。。
//有个不足之处就是脚本重启一次就要重新获取一次游戏窗口,这点完全可以用别的方法代替,比如写入配置中就是一个不错的方法
//另外还想说一点:这个脚本改改可以做的更强大,比如多窗口后台同步鼠标事件、同步键盘事件等等,需要用到插件
//最后:纯属个人突发兴趣,想把这个脚本完善一下,因为下面的代码BUG太多。。。。。。如果冒犯请楼主删除
/*
Hwnd = Plugin.Window.MousePoint()
MessageBox "绑定成功!"
sRect = Plugin.Window.GetClientRect(Hwnd)
Windo = Split(sRect, "|")
do
Click = WaitClick()
If Click <> 0 Then
GetCursorPos x, y
SaveMousePos
Delay 100
MoveTo Windo(0), Windo(1)
Delay 100
GetCursorPos x1, y1
Call Hit()
RestoreMousePos
End If
Delay 100
Loop
Sub Hit()
If Form1.InputBox2.text <> "" Then
sRect1 = Plugin.Window.GetClientRect(Form1.InputBox2.text)
Win = Split(sRect1, "|")
MoveTo Win(0) + x - x1, Win(1) + y - y1
Delay 100
LeftClick 1
End if
If Form1.InputBox3.text <> "" Then
sRect1 = Plugin.Window.GetClientRect(Form1.InputBox3.text)
Win = Split(sRect1, "|")
MoveTo Win(0) + x - x1, Win(1) + y - y1
Delay 100
LeftClick 1
End If
If Form1.InputBox4.text <> "" Then
sRect1 = Plugin.Window.GetClientRect(Form1.InputBox4.text)
Win = Split(sRect1, "|")
MoveTo Win(0) + x - x1, Win(1) + y - y1
Delay 100
LeftClick 1
End If
If Form1.InputBox5.text <> "" Then
sRect1 = Plugin.Window.GetClientRect(Form1.InputBox5.text)
Win = Split(sRect1, "|")
MoveTo Win(0) + x - x1, Win(1) + y - y1
Delay 100
LeftClick 1
End If
If Form1.InputBox6.text <> "" Then
sRect1 = Plugin.Window.GetClientRect(Form1.InputBox6.text)
Win = Split(sRect1, "|")
MoveTo Win(0) + x - x1, Win(1) + y - y1
Delay 100
LeftClick 1
End If
If Form1.InputBox7.text <> "" Then
sRect1 = Plugin.Window.GetClientRect(Form1.InputBox7.text)
Win = Split(sRect1, "|")
MoveTo Win(0) + x - x1, Win(1) + y - y1
Delay 100
LeftClick 1
End If
If Form1.InputBox8.text <> "" Then
sRect1 = Plugin.Window.GetClientRect(Form1.InputBox8.text)
Win = Split(sRect1, "|")
MoveTo Win(0) + x - x1, Win(1) + y - y1
Delay 100
LeftClick 1
End If
If Form1.InputBox9.text <> "" Then
sRect1 = Plugin.Window.GetClientRect(Form1.InputBox9.text)
Win = Split(sRect1, "|")
MoveTo Win(0) + x - x1, Win(1) + y - y1
Delay 100
LeftClick 1
End If
End Sub
*/