Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PipeRun("MsgBox Hello World!")
- code =
- (%
- MsgBox % "1+2+3+4+5+6+7+8+9 = " Sum(1,2,3,4,5,6,7,8,9)
- Sum(Args*) {
- sum := 0
- for k,v in Args
- sum += v
- return sum
- }
- )
- PipeRun(code)
- return ; End of auto-execute
- PipeRun(Script) {
- pipes := []
- pipeName := "\\.\pipe\AHK" A_TickCount
- loop 2 {
- hPipe := DllCall("Kernel32\CreateNamedPipe", "Str",pipeName, "UInt",2
- , "UInt",0, "UInt",255, "UInt",0, "UInt",0, "UInt",0, "Ptr",0)
- if (hPipe = -1)
- return false
- pipes.Push(hPipe)
- }
- try {
- fn := ["ComObjCreate", "ComObject"][SubStr(A_AhkVersion, 1, 1)]
- shell := %fn%("WScript.Shell")
- shell.Exec(A_AhkPath " " pipeName)
- } catch {
- return false
- }
- DllCall("Kernel32\ConnectNamedPipe", "Ptr",pipes[1], "Ptr",0)
- DllCall("Kernel32\CloseHandle", "Ptr",pipes[1])
- DllCall("Kernel32\ConnectNamedPipe", "Ptr",pipes[2], "Ptr",0)
- if !(FileOpen(pipes[2], "h", "UTF-8").Write(Script))
- return false
- DllCall("Kernel32\CloseHandle", "Ptr",pipes[2])
- return true
- }
Add Comment
Please, Sign In to add comment