DynaRun tempScript pipeName static DefaultArgs UInt UInt UInt 255 UInt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
DynaRun(tempScript, pipeName = "")
{
static DefaultArgs := ["UInt", 2, "UInt", 0, "UInt", 255, "UInt", 0, "UInt", 0, "Ptr", 0, "Ptr", 0, "Ptr"]
static BOM := Chr(0xFEFF)
(pipeName = "" && pipeName := "AHK_" . A_TickCount)
pipeGA := DllCall("CreateNamedPipe", "Str", "\\.\pipe\" pipeName, DefaultArgs*)
pipe := DllCall("CreateNamedPipe", "Str", "\\.\pipe\" pipeName, DefaultArgs*)
if (pipe = -1 || pipeGA = -1)
return false
Run, % A_AhkPath . " ""\\.\pipe\" . pipeName . """",, UseErrorLevel HIDE, processID
if ErrorLevel
MsgBox, 262144, ERROR, % "Could not open file:`n ""\\.\pipe\" . pipeName . """"
DllCall("ConnectNamedPipe", "Ptr", pipeGA, "Ptr", 0), DllCall("CloseHandle", "Ptr", pipeGA)
DllCall("ConnectNamedPipe", "Ptr", pipe, "Ptr", 0)
, tempScript := BOM . tempScript
, tempScriptSize := (StrLen(tempScript)+1)*2
if !DllCall("WriteFile", "Ptr", pipe, "Str", tempScript, "UInt", tempScriptSize, "UInt*", 0, "Ptr", 0)
return A_LastError
DllCall("CloseHandle", "Ptr", pipe)
return processID
}