BeginThread 同时运行过程
新开一个线程运行当前脚本,从指定的过程开始运行
字符串型,过程名
整数型,线程ID  [注:8.20版新增返回值参数]



MessageBox "多线程命令还在测试当中,并不稳定,请谨慎使用"
//下面这个例子会打开一个记事本,用2个线程向其中模拟按键
Call RunApp("notepad")
Delay 1000
DimEnv Key
Key=65
BeginThread Thread1
While True
    Call PressKey()
    key=key+1
    If (key>90)
        key=65
    EndIf 
Wend
EndScript 
Sub Thread1()
    For 10
        Call PressKey()
    Next  
    KeyPress 13,1
    SayString "线程1已经结束"
    KeyPress 13,1
End Sub
Sub PressKey()
    KeyPress key,1
    Delay 200
End Sub




-----------------------------------------------------------------
 以下为新增功能(版本未发布请勿使用) [注:8.20版新增返回值参数]

MessageBox "多线程命令还在测试当中,并不稳定,请谨慎使用"
线程ID=BeginThread(测试) //启动“测试”线程的运行,并返回线程ID编号
For 3 
    Delay 1000
Next 
StopThread 线程ID //3秒后停止“测试”线程的运行
Sub 测试()
    i=0
    Do 
        Call Plugin.Msg.ShowScrTXT(0, 0, 1024, 768, "屏幕内容填写"&i, "0000FF") 
        Delay 1000
        i=i+1
    Loop 
End Sub 

MessageBox "多线程命令还在测试当中,并不稳定,请谨慎使用"
//下面这个例子会打开一个记事本,用2个线程向其中模拟按键
VBSCall RunApp("notepad")
Delay 1000
SetEnv "Key","65"
BeginThread "Thread1"
While 1
    Gosub PressKey
    key=key+1
    If key>90
        key=65
    EndIf 
    SetEnv "Key",CStr(key)
EndWhile 
EndScript 
Sub Thread1
    For 10
        Gosub PressKey
    EndFor 
    KeyPress 13,1
    SayString "线程1已经结束"
    KeyPress 13,1
Return 
Sub PressKey
    key=GetEnv("Key")
    KeyPress key,1
    Delay 200
Return