'Windows How to open apps on specific monitor at startup

I am struggling to find a way to automatically run apps specified monitors at startup. In my case, I have two apps. One app needs to be opened and maximized on the primary screen and the second app needs to be opened on the secondary screen and maximized.



Solution 1:[1]

If you p/invoke ShellExecuteEx you can set the SEE_MASK_HMONITOR flag and the hMonitor member. Starting with Windows 8, Explorer sets STARTUPINFO::hStdOutput to a monitor handle when starting applications from the taskbar.

Whether or not the application you are starting cares is another question. Anything that remembers its previous position is unlikely to care. If the app creates its first window with CW_USEDEFAULT it might work.

Getting something to start maximized is easier. ProcessStartInfo::WindowStyle, SHELLEXECUTEINFO and STARTUPINFO all allow you to force this. The first call to ShowWindow will respect the forced show mode...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anders