FileOpen with * for stdIn and stdOut

Editor for AutoHotkey written completely in AutoHotkey.

Moderator: maestrith

User avatar
nnnik
Posts: 3547
Joined: 30 Sep 2013, 01:01
Location: Germany

FileOpen with * for stdIn and stdOut

14 Apr 2017, 03:42

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
Recommends AHK Studio
just me
Posts: 5656
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: FileOpen with * for stdIn and stdOut

14 Apr 2017, 04:12

It is working here. You have to type a query and press Enter.
User avatar
nnnik
Posts: 3547
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: FileOpen with * for stdIn and stdOut

14 Apr 2017, 04:32

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.
Recommends AHK Studio
User avatar
maestrith
Posts: 743
Joined: 16 Oct 2013, 13:52

Re: FileOpen with * for stdIn and stdOut

31 May 2017, 02:53

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
AHK Studio OSD GUI Creator
Donations
Discord
All code is done on a Windows 10 PC Running x64 and AutoHotkey x32

Return to “AHK Studio”

Who is online

Users browsing this forum: No registered users and 1 guest