Terminal Connectivity in Windows using Console

This HowTo documents how to integrate Geany with Console using AutoHotKey in Windows. This is useful since the terminal emulation feature is absent in geany on windows. Console is a tabbed wrapper for terminal-like programs in windows, and can be used as a shell to run anything from cmd.exe, python, rterm, etc. to Midnight Commander. AutoHotKey is a scripting language and interpreter that specializes in process management and keyboard shortcuts.

Setup

AutoHotKey.ahk
TestConsole()
{
	IfWinNotExist, ahk_class Console_2_Main,
	{
		Run, C:\path\to\Console.exe -t DefaultTab
		WinWait, ahk_class Console_2_Main,
	}
}
 
ActivateConsole()
{
	TestConsole()
	WinActivate, ahk_class Console_2_Main,
	WinWaitActive, ahk_class Console_2_Main,
}
 
#1::
WinGetActiveTitle, editor
old_clipboard = %clipboard%
Send, {CTRLDOWN}c{CTRLUP}
ActivateConsole()
Send, {CTRLDOWN}{END}{CTRLUP}{RETURN}
WinActivate, %editor%,
clipboard = %old_clipboard%
return
 
#2::
WinGetActiveTitle, editor
old_clipboard = %clipboard%
Send, {HOME}{HOME}{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}
ActivateConsole()
Send, {CTRLDOWN}{END}{CTRLUP}{RETURN}
WinActivate, %editor%,
clipboard = %old_clipboard%
WinWaitActive, %editor%,
Send, {HOME}{DOWN}
return
 
#3::
WinGetActiveTitle, editor
old_clipboard = %clipboard%
Send, {CTRLDOWN}ac{CTRLUP}
ActivateConsole()
Send, {CTRLDOWN}{END}{CTRLUP}{RETURN}
WinActivate, %editor%,
clipboard = %old_clipboard%
return

This script, when run, will bind the following commands:

To change these bindings, replace the #1, #2, or #3 in the above script with bindings that can be found here.