1
votes

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.

2
I think this question is more suited for SuperUser since you're asking about program settings, not about programming. - BrenBarn
@BrenBarn not necessarily. I'm open to other suggestions that do not necessarily involve settings changed only. If I have to code something in python to get around this limitation (I suggest one of the off-the-top-of-my-head ways of doing it), I am happy to do that. Open to suggestions. - MrR
How do you run ConEmu instances? I don't understand why do you want to use external hotkey managers to activate ConEmu window... - Maximus
@Maximus thank you for the AMAZING Conemu. - MrR

2 Answers

1
votes

I can say only about pywinauto. When you call app = Application().start('ConEmu64.exe') pywinauto already remembers process PID and every new WindowSpecification object assumes this PID. Of course, it's true only if you're controlling start of ConEmu (or any other app). More details can be found in the Getting Started Guide.

Method app.connect(title="some unique tab name") will also remember the PID in app object. But if there are few instances with the same title, you need to disambiguate it using found_index=0 criterion, for example. Or right click on the tab and choose "Rename tab..." context menu item which changes the window title.

I took a short look at ConEmu. Toolbars and tabs are visible even to Spy++. So the most of actions can be automated. Just not sure about console inside a tab. If you want to type some commands, it's much better to use standard Python module subprocess because GUI automation for console programs looks very very strange. ;)

1
votes

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!