1 | #include <Constants.au3> |
---|
2 | |
---|
3 | Global $g_nExitCode = Main() |
---|
4 | Exit $g_nExitCode |
---|
5 | |
---|
6 | Func Main() |
---|
7 | If $CmdLine[0] Then |
---|
8 | Call($CmdLine[1]) |
---|
9 | If @error Then MsgBox(4096 + 16, "Error", "Invalid function") |
---|
10 | Else |
---|
11 | Master() |
---|
12 | EndIf |
---|
13 | EndFunc ; Main() |
---|
14 | |
---|
15 | Func Master() |
---|
16 | Local $pid = RunSelf("Parent", $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD) |
---|
17 | ProcessWaitClose($pid) |
---|
18 | MsgBox(4096, "", "From Parent:" & @CRLF & StdoutRead($pid)) |
---|
19 | EndFunc ; Master() |
---|
20 | |
---|
21 | Func Parent() |
---|
22 | ConsoleWrite("Parent!!!" & @CRLF) |
---|
23 | Local Const $sChildExe = @ScriptDir & "\Child.exe" |
---|
24 | If Not FileExists($sChildExe) Then Return MsgBox(4096 + 16, "Error", "Unable to find child executable") |
---|
25 | Local $pid = Run($sChildExe, @WorkingDir, @SW_SHOWNORMAL, $STDIN_CHILD + $STDERR_MERGED) |
---|
26 | ProcessWaitClose($pid) |
---|
27 | Local $s = StdoutRead($pid) |
---|
28 | MsgBox(4096, "", "From Child:" & @CRLF & $s) |
---|
29 | ConsoleWrite($s) |
---|
30 | EndFunc ; Parent() |
---|
31 | |
---|
32 | Func RunSelf($sCmdLine, $nStdio = 0, $sWorkingDir = @WorkingDir, $nShow = @SW_SHOWNORMAL) |
---|
33 | Local $sCmd |
---|
34 | If @Compiled Then |
---|
35 | $sCmd = @AutoItExe & " " & $sCmdLine |
---|
36 | Else |
---|
37 | $sCmd = @AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptFullPath & '" ' & $sCmdLine |
---|
38 | EndIf |
---|
39 | Return Run($sCmd, $sWorkingDir, $nShow, $nStdio) |
---|
40 | EndFunc ; RunSelf() |
---|