I noticed something really strange. If I run the following code from VS2013, it works as expected. However, when I manually double-click the compiled .exe, it is not. This makes me think that VS2013 is somehow launching higher resolution applications.
#include <stdio.h> #include <tchar.h> #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { printf("You have 5 seconds to open a Metro App. \nThen we'll try setting the TaskBar as the foreground window.\n\n"); Sleep(5000); printf("Setting Taskbar as foreground window now... \n"); SetForegroundWindow(FindWindow(L"Shell_TrayWnd", NULL)); getchar(); return 0; }
When starting from VS2013: even if the Metro application is open (occupies the entire screen), after the taskbar is set as the foreground window, the user returns to the desktop.
Double-clicking .exe: If Metro is the foreground window, nothing happens.
As a side note, I tried right-clicking and "Run as administrator", however this still does not work. This is even more confusing. Does anyone know what is going on here?
In addition, I am running a preview of Windows 8.1.
source share