Search code examples
pythonwindowsautohotkeypywinautoconemu

Multiple conemu windows - how to differentiate?


Windows 8.1 , ConEmu 170316 [32] {Preview}

I have multiple Conemu instances running, where each instance equals one "workspace".

I would like to be able to switch to this workspaces with autohotkey or pywinauto. However they require a criterion for selecting the right window, and usually I employ a combination of window title and or window class type.

Is there any setting in conemu that can help me achieve this criterion identifiation for window selection? If there isn't, I will have to write the PID down somewhere when I start the conem windows, then read it to bring up the right window at window activation time.


Solution

  • As per faq (ty Maximus) - see option 1:

    1) Use -title “Window name” switch to explicitly set window title of new ConEmu instance. The example below starts new ConEmu window with title My server and ssh to your.server.com inside. Does not matter if you run another tab, or several tabs from task, the ConEmu window title remains My server. So you may rely on the title for selecting the window with class name VirtualConsoleClass.

    Option 2 is also valid. I'd have to (1) create a config, and (2) hardcode the hashed id in ahk / pywinauto. Just using the window title name seems the right thing to do in my case, the app id setup seems overkill

    2) Windows 7 introduced AppUserModelID. ConEmu uses executable path name and some switches (like -config, -loadcfgfile, -quake) to create a hash to form AppID, which you may see in the About / SysInfo. Current version shows 1d5372066082f23b41ba6aa278e56e9d::163. The trailing ::163 depicts ConEmu internal protocol version which may (and most probably would) be changed in the future. The hash itself is expected to be unchanged. You may query the ID from running ConEmu process using Windows API function GetApplicationUserModelId.

    Thank you Maximus!