My desktop application hook some hot keys eg: CTRL+SHIFT+F12, while the hot keys are pressed, it will bring my desktop application window into foreground or stay on top. But in Window 8 or 8.1, while it is in Window Start Screen or Metro App is running in foreground, my program unable to switch back to desktop mode and bring my window into foreground. I have tried the following API, SetFocus(hwnd); ShowWindow(hwnd, SW_SHOW); SetActiveWindow(hwnd); SetForegroundWindow(hwnd); SwitchToThisWindow(hwnd);
I even try on ShellExecute on "explorer.exe shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257}", it doesn't work.
I'm not sure how Classic Shell latest version (http://www.classicshell.net) able to do this, when I pressed SHIFT+WIN key, it able to switch from Metro Mode back to desktop mode and show the Classic Shell Window.
Thanks.
You should be able to set a User Model ID to your application and use some of the newer APIs to bring it in focus when the user is in "Metro". Here are some code fragments in C++ to illustrate:
Somewhere shared:
In your "desktop" application startup:
In your bring-into-focus-code:
Your shortcut:
Microsoft introduce some other goofy rules tied to all of this as well. You may have to add some additional information to your application's shortcut and have that shortcut pinned to the start menu for all of this to work (no, seriously). If you find this to be the case, here is a bit of code for updating your shortcut and adding the Model ID: