I have an already-started console application, under Windows XP. I want to attach it to a different console emulator such as Console2 or ConEmu. This is possible with ConEmu, and it works if I run ConEmu then use its "Attach to" menu entry and select my console application in the list.
I am now trying to automate this. I want to be able to focus the console application window, press a key, and have it attached to a new instance of ConEmu. I tried to write an AutoHotKey macro to attach the currently focused console application when I press Win+A, but I can't figure out how to use
ConEmuC. Here's my attempt:
#IfWinActive, ahk_class ConsoleWindowClass #a:: WinGet, app_pid, PID Run c:\opt\ConEmu-120704\ConEmu.exe /detached, , , conemu_pid Run c:\opt\ConEmu-120704\ConEmu\ConEmuC.exe /ATTACH /PID=%app_pid% Return
All I get the following error popup:
Attach to GUI was requested, but there is no console processes! c:\opt\ConEmu-120704\ConEmu\ConEmuC.exe /ATTACH /PID=7104
Yet if I use the “Attach to” menu entry in the ConEmu instance, the console application gets attached. I need to tick the “alternative mode” checkbox introduced in version 120704, if that's relevant.
How do I use
ConEmuC (or any other method) to attach an existing console application to a new ConEmu instance? Even better, how do I attach an existing instance (if I want a new instance, I can just create it beforehand)? And how do I specify alternative mode?