I'm trying to have AHK read (doesn't need to write) from an existing named pipe created by a small nodejs test server but the script freezes until it receives data..is there a way it can act normal (not freeze, accept hotkeys, etc) and act more on events like a websocket, or chatserver, etc?
The code below is slightly modified Read.AHK from https://www.autohotkey.com/board/topic/103403-ipc-using-named-pipes/
I just put it in a loop and added a GUI to read line by line but it also gives the error The following variable name contains an illegal character: "welcome"
I also found viewtopic.php?t=9858 but I think that's more or less the opposite of what I need.
Code: Select all
ptr := A_PtrSize ? "Ptr" : "UInt"
char_size := A_IsUnicode ? 2 : 1
pipe_name := "\\.\pipe\testpipe"
Gui,Add,Edit,x0 y0 W640 h480 vedittxt,
GuiControl,,Edit1
Gui,Show,Center, w640 h480
While !DllCall("WaitNamedPipe", "Str", pipe_name, "UInt", 0xffffffff)
Sleep, 500
Loop {
Loop, read, %pipe_name%
ToolTip, %A_LoopReadLine%
;txt := %A_LoopReadLine%
;txt := RegExReplace(%A_LoopReadLine%, [^a-zA-Z], Replacement="")
guicontrol,, edittxt, %txt%
}