#include "CoProc.au3"
_CoProc("Test_1(1)")
_CoProc("Test_2(2)")
Func Test_1($sText)
Local $iPID = Run('cmd')
Sleep(3000)
$var = WinList()
For $i = 1 To $var[0][0]
$temppid = WinGetProcess($var[$i][1])
If $temppid = $iPID Then ExitLoop
Next
ControlSend($var[$i][1], '', '', $sText)
EndFunc ;==>Test_1
Func Test_2($sText)
Local $iPID = Run('cmd')
Sleep(3000)
$var = WinList()
For $i = 1 To $var[0][0]
$temppid = WinGetProcess($var[$i][1])
If $temppid = $iPID Then ExitLoop
Next
ControlSend($var[$i][1], '', '', $sText)
EndFunc ;==>Test_2
最后还是用CoProc多进程解决的 |