Page 1 of 1

Return string to cmd screen from compiled .exe AHK script

Posted: 12 Sep 2019, 05:35
by aircooled
I need to return a string like ABCD:1234;DEFG;5678 to the calling environment from a compiled .exe file.

I am using AHK v. 1.1.30.1

I execute the .exe in cmd and wish it to return the value to screen.

I have tried:
return
ExitApp
ExitCode (it whould be possible to return an expression from this)
StrPut

with no success until now. I need it to return the value the same way a .bat file in cmd would return the command "echo ABCD:1234;DEFG;5678"

my compiled ahk file is performing an amount of functionality which results in a string that I need written to screen. Is it possible?

Re: Return string to cmd screen from compiled .exe AHK script

Posted: 12 Sep 2019, 16:43
by aircooled
Is there really nobody that can help how to make an .exe compiled ahk file return a string when executed in console?

My AHK .exe file performs some logic and returns the results in the form of a semicolon separated string.

Something like

34223423;23423545;234234

Is it possible to have the .exe file return that when executed in cmd console?

The same way a .bat file returns with "echo 34223423;23423545;234234"

Please help.

Thank you.

Re: Return string to cmd screen from compiled .exe AHK script

Posted: 12 Sep 2019, 16:59
by ilhom
Can check to see if the command console is active through IfWinActive and then input the string.
https://www.autohotkey.com/docs/commands/WinActive.htm

So if console isn't active, it runs however you have it running now.
If console is active, you can send the input as text so you can see the command in the console just like @echo in .bat files.

Re: Return string to cmd screen from compiled .exe AHK script

Posted: 12 Sep 2019, 18:18
by jeeswg
Perhaps you want this:

To write:
FileAppend with * (stdout) or ** (stderr):
FileAppend - Syntax & Usage | AutoHotkey
https://www.autohotkey.com/docs/commands/FileAppend.htm

To read:
ExecScript example code to receive stdout/stderr:
Run / RunWait - Syntax & Usage | AutoHotkey
https://www.autohotkey.com/docs/commands/Run.htm

Re: Return string to cmd screen from compiled .exe AHK script  Topic is solved

Posted: 15 Sep 2019, 23:42
by aircooled
Thank you all. This did the trick:

Fileappend:
Standard Output (stdout): Specifying an asterisk (*) for Filename causes Text to be sent to standard output (stdout).

Easier than I thought. :dance: