SetTitleMatchMode 3 ; exact match required !c:: Settimer GetIt, 30 ; another thread gets buffer RunWait %comspec% /k echo Hello World! ; will be closed from GetIt ; at this point: console buffer -> ClipBoard StringReplace Text,ClipBoard,`r`n%A_WorkingDir%>,,R ; remove last command prompt MsgBox %Text% Return GetIt: IfWinNotExist %comspec% ; title changed while busy Return ; keep trying until idle Settimer GetIt, Off ; need not run any more WinActivate %comspec% ; no title suffix when done ClipBoard = Send !{Space}es{Enter} ; select all, copy to clipboard ClipWait 2 Send !{Space}c ; close console window ReturnWhile a console application runs it changes the title of the window. Monitoring the change tells us, when the application terminates. We run the desired program via cmd.exe. Its full path is stored in %comspec%, which is the title of its window when idle. "cmd.exe /k" runs the program, and remains open. Before running the program we start a timer, which checks in every 30 ms if a window exists with the idle cmd.exe title. If it is found, the checking can stop. We activate from the context menu (Alt-Space) Edit/Select all. Sending Enter copies the selection to the clipboard, from where we only need to remove the bottommost command prompt to get the output of the console application.
We have to make sure the buffer is large enough for holding the full output. We can set it up to 999 lines via the properties of the command prompt, and making it the default. The "Select all" menu item only selects the beginning of the buffer, so a large one does not slow things down. Another approach is to use "|more" and a loop to get the output one screen at a time.