Page 1 of 1

FileOpen with * for stdIn and stdOut

Posted: 14 Apr 2017, 03:42
by nnnik
This example from the help does nothing for me except for opening a new window:

Code: Select all

; Open a console window for this demonstration:
DllCall("AllocConsole")
; Open the application's stdin/stdout streams in newline-translated mode.
stdin  := FileOpen("*", "r `n")  ; Requires v1.1.17+
stdout := FileOpen("*", "w `n")
; For older versions:
;   stdin  := FileOpen(DllCall("GetStdHandle", "int", -10, "ptr"), "h `n")
;   stdout := FileOpen(DllCall("GetStdHandle", "int", -11, "ptr"), "h `n")
stdout.Write("Enter your query.`n\> ")
stdout.Read(0) ; Flush the write buffer.
query := RTrim(stdin.ReadLine(), "`n")
stdout.WriteLine("Your query was '" query "'. Have a nice day.")
stdout.Read(0) ; Flush the write buffer.
Sleep 5000

Re: FileOpen with * for stdIn and stdOut

Posted: 14 Apr 2017, 04:12
by just me
It is working here. You have to type a query and press Enter.

Re: FileOpen with * for stdIn and stdOut

Posted: 14 Apr 2017, 04:32
by nnnik
Seems it doesn't work when I run it from AHK studio. I guess that's the case due to AHK Studio grabbing stdout and stdin.

Re: FileOpen with * for stdIn and stdOut

Posted: 31 May 2017, 02:53
by maestrith
nnnik wrote:Seems it doesn't work when I run it from AHK studio. I guess that's the case due to AHK Studio grabbing stdout and stdin.
Sadly when you use Studio it does hook into the stdin and stdout to help with displaying errors.

Code: Select all

;menu Basic Run
#SingleInstance,Force
x:=Studio()
File:=x.Current(2).file
SplitPath,File,Filename,Dir
Run,%Filename%,%Dir%
ExitApp
Put that into the Plugins folder and refresh the plugins. That will give you a basic run that will not do anything fancy