我这个脚本 第一个窗口只运行一次 第二个重复运行的,如何修改为两个脚本同时运行??
HwndEx = Plugin.Window.Search("魔兽世界")
dim MyArray
MyArray = Split(HwndEx, "|")
Delay 10000 '延时时间
For UBound(MyArray)
Call Plugin.Bkgnd.KeyPress(Myarray(0), 70)
Delay 3500'延时时间
Call Plugin.Bkgnd.KeyPress(Myarray(0), 70)
Delay 3250'延时时间
Call Plugin.Bkgnd.KeyPress(Myarray(0), 49)
Delay 2310'延时时间
Call Plugin.Bkgnd.KeyPress(Myarray(0), 52)
Delay 1280'延时时间
i=i+1
Next
If UBound(MyArray) >= 1 Then
i=1
For UBound(MyArray)
Call Plugin.Bkgnd.KeyPress(Myarray(1), 50)
Delay 3650'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 70)
Delay 3120'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 69)
Delay 3030'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 82)
Delay 4890'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 32)
Delay 4100'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 49)
Delay 3120'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 69)
Delay 3820'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 81)
Delay 1830'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 50)
Delay 3580'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 70)
Delay 3210'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 69)
Delay 3150'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 49)
Delay 2205'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 69)
Delay 11000'
i=i+1
Next
End If
单线程脚本怎么写也不会同时操作两个窗口,改成了多线程,变量i删了,循环改成了do...loop,两个窗口的脚本以子程序的方式调用,可以测试一下
dim MyArray
MyArray = Split(HwndEx, "|")
Delay 10000'延时时间
Dimenv 窗口二
Call 窗口一_sub
窗口二=BeginThread(窗口二_sub)
Sub 窗口一_sub
Do
Call Plugin.Bkgnd.KeyPress(Myarray(0), 70)
Delay 3500'延时时间
Call Plugin.Bkgnd.KeyPress(Myarray(0), 70)
Delay 3250'延时时间
Call Plugin.Bkgnd.KeyPress(Myarray(0), 49)
Delay 2310'延时时间
Call Plugin.Bkgnd.KeyPress(Myarray(0), 52)
Delay 1280'延时时间
Loop
End Sub
Sub 窗口二_sub
Do
Call Plugin.Bkgnd.KeyPress(Myarray(1), 50)
Delay 3650'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 70)
Delay 3120'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 69)
Delay 3030'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 82)
Delay 4890'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 32)
Delay 4100'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 49)
Delay 3120'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 69)
Delay 3820'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 81)
Delay 1830'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 50)
Delay 3580'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 70)
Delay 3210'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 69)
Delay 3150'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 49)
Delay 2205'
Call Plugin.Bkgnd.KeyPress(Myarray(1), 69)
Delay 11000'
Loop
End Sub追问
这个也不能同时对两个窗口同时操作,也是第一个窗口循环结束后循环第二个窗口
追答第八行和第九行换一下就行了,先用线程调用子程序,主线程就会继续运行了
我本机没测试,抱歉
你这个脚本我没看懂,i的变量究竟用在哪里了,改成整体循环不行吗?第一个窗口运行完一次之后,再运行第二个窗口,然后整体循环。这个循环条件没看懂。
delay 3000
hwnd2=Plugin.Window.mousepoint()//自己切换下两个窗口