1

If I create a Windows 8 shortcut for a console application and set a shortcut key (cf. the screenshot below), then using that shortcut while the application is already open will not open the application again but rather change focus to the window containing the running application.

This behavior differs from what happens if I simply open the shortcut without pressing the shortcut keys, in which case a new application is opened. On the other hand, for non-console applications, pressing the shortcut keys will open a new window even if one is already open.

So, is there any way to make the shortcut keys for a console application shortcut always open a new application?

The solutions to this StackOverflow question seem to suggest that using start cmd /c to run the relevant application might be helpful, but that doesn't seem to do the job in the case of shortcuts.

enter image description here

  • 1
    Its possible the shortcut key is intercepted by your console application and used there instead. Try clicking on the taskbar or anywhere else outside of the app and press your shortcut key then to confirm. Also try changing the shortcut key to something else to confirm. – LPChip Mar 14 '18 at 11:53
  • @LPChip: Thanks for the comment. Tried changing the focus to different other application, and the effect of the shortcut always becomes to bring the console application into focus; if, for example, the application is minimized, then pressing the shortcut key will restore the window. I tried with a few other shortcut keys, such as CTRL + ALT + æ and CTRL + ALT + TREMA, which gives the same behavior. – fuglede Mar 14 '18 at 11:57
  • Changing the shortcut to a .bat calling start C:\...\sh.exe does create a new window for each call but ends up spawning a new default console, which is not the desired behavior. – fuglede Mar 14 '18 at 12:07
  • Do you really need a shortcut key? If not, try this method: once the app is loaded, hold shift and click the app in the taskbar. You may need to pin the app to the taskbar first. – LPChip Mar 14 '18 at 12:29
  • Yes, the idea for this would be to support a keyboard-only workflow. The second-best solution I could come up with would be to add the application to PATH and only fire it up using Win+R -> name. Still, though, since this works for non-console applications, I would've imagined it to somehow also be possible in this case. – fuglede Mar 14 '18 at 13:08
1

using that shortcut while the application is already open will not open the application again but rather change focus to the window containing the running application.

When you set a hotkey in the shortcut properties, Windows apply this hotkey to the window (WM_SETHOTKEY) the application creates. Of course that leads to observed behavior. If app is already started - shortcut is processed "by application window" and started instance is just focused. But when you double-click on the shortcut - Windows does not process hotkey.

On the other hand, for non-console applications, pressing the shortcut keys will open a new window even if one is already open.

That is because these applications ignore WM_SETHOTKEY message. And this may be considered as a bug of these applications.

using start cmd /c ... to run the relevant application might be helpful, but that doesn't seem to do the job in the case of shortcuts.

That is the simpliest solution. Why don't you like it?

You may run the shell as

start "your bash" cmd /c sh.exe"

And configure colors via console window properties (not a shortcut). After that colors will be applied to new instances.

Or you may try ConEmu. There are a lot of options, for example Default terminal feature.

  • Thanks. Regarding the start solution, I'm not a fan because it creates a new window without any of the other settings (buffer size, colors, ...) that are set as part of the shortcut. Is there any way to keep those? – fuglede Mar 14 '18 at 15:14
  • Answer updated. – Maximus Mar 14 '18 at 22:37
  • What does "your bash" refer to here (noting that running sh corresponds to running bash as a non-login shell)? – fuglede Mar 18 '18 at 8:20
  • It's just a your preferred name of the console, under this "name" your colors would be stored. – Maximus Mar 18 '18 at 12:36
  • Ah, clever! Slightly annoying that it creates and immediately kills another window, but it still beats all alternatives. – fuglede Mar 18 '18 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.