Use a command prompt for information output?

Get help with using AutoHotkey and its commands and hotkeys
Ferro
Posts: 2
Joined: 13 Jun 2016, 09:45

Use a command prompt for information output?

17 Oct 2016, 23:01

I'm looking for a way to send information to a command prompt's output. For example, when I type ipconfig, the ipconfig program then shows some basic network adapter info in the prompt. That output is what I want to be able to send to the prompt after a script is executed by that prompt.

Any ideas? I'm assuming this is going to require DLL calls or something advanced that I have no idea where to begin looking for what I need.
gwarble
Posts: 240
Joined: 30 Sep 2013, 15:01

Re: Use a command prompt for information output?

17 Oct 2016, 23:16

Yes its possible and pretty easy... there are two methods:
1) use AttachConsole to, well, attach to the console window that launched it
2) compile the script (or at least make a dedicated copy of ahk.exe) and set the exe subsystem to be a console application

you would then do a fileappend to stdout to write the text
searching the forum should reveal examples of both
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
lexikos
Posts: 6176
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Use a command prompt for information output?

18 Oct 2016, 03:42

The second option is better. Without it, the command prompt may not wait for your script to finish, because it is not a console app. In that case, the prompt may appear before your script writes its output; for example:

Code: Select all

C:\>script.exe

C:\>The output of your script.
gwarble
Posts: 240
Joined: 30 Sep 2013, 15:01

Re: Use a command prompt for information output?

20 Oct 2016, 19:05

I agree and use the second option whenever possible. But, the downside is if you use the app both from the command prompt and not, then you get the ugly command prompt pop up when you don't want it... So there is no all-case perfect solution as far as i know
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
lexikos
Posts: 6176
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Use a command prompt for information output?

20 Oct 2016, 22:53

Of course, you can run both the compiled console app and the uncompiled script. Or you can modify AutoHotkey and use both the modified version and the original.

Every other console program out there has the same issue. Usually the solution is either to have two executables, or to just hide the console window.

Return to “Ask For Help”

Who is online

Users browsing this forum: andremarasca, Bing [Bot], Google [Bot], Scr1pter and 27 guests