0

If Notepad is open (or many other programs, don't need to be pinned) and user shift+clicks its taskbar item, it will open a new window. This behavior doesn't seem to be handled but the Windows Shell so it won't open another instance by default.

I have tried creating a hook MainWindowProc to get all window messages but that is not one of them and I don't know how to detect that event. Is there a way to get it from .NET?

Daniel
  • 1,064
  • 2
  • 13
  • 30
  • 1
    It will open another instance of any program. It's just that some programs, the ones that should not have more then one instance running at the same time, implement a check that stops them if there is another instance of a program already running. [This](https://stackoverflow.com/questions/93989/prevent-multiple-instances-of-a-given-app-in-net) question has some answers on how to implement it yourself. – defaultUsernameN Apr 02 '21 at 21:46
  • 1
    A new Instance of the executable is started if the executable is started from a shortcut (as when you start your Notepad from the Start menu). Not if you run the executable directly. A Window doesn't receive any specific message when a SHIFT+Click event is generated on its Taskbar icon (except `WM_GETICON`, if the mouse pointer hovers the icon long enough). Or `WM_ACTIVATE` and `WM_APPACTIVATE` when the app is activated/deactivated by a standard click on the icon. – Jimi Apr 03 '21 at 17:09
  • @Jimi you are right. It is a bad design on MSFT side that it has to be started from a shortcut to react to Shift+Click so debugging that feature is not possible – Daniel Apr 03 '21 at 20:14
  • Well, this is the same situation when someone starts a second instance of your app, you handle it the same way. – Jimi Apr 04 '21 at 01:42

0 Answers0