What determines the monitor my app runs on?
Asked Answered
O

11

79

I am using Windows, and I have two monitors.

Some applications will always start on my primary monitor, no matter where they were when I closed them.

Others will always start on the secondary monitor, no matter where they were when I closed them.

Is there a registry setting buried somewhere, which I can manipulate to control which monitor applications launch into by default?

@rp: I have Ultramon, and I agree that it is indispensable, to the point that Microsoft should buy it and incorporate it into their OS. But as you said, it doesn't let you control the default monitor a program launches into.

Overview answered 9/9, 2008 at 19:54 Comment(3)
Ultramon is a must-have utility. I have been using it for years.Fiedling
This high-traffic question is starting to look like an ad for Ultramon. DisplayFusion should be mentioned too. I'm not associated with the company, just love what the product does for me. A third well-known one is "Actual Multiple Monitors"Quatrain
@zx81: It's worth noting that when I wrote this back in '08, I had windows xp. UltraMon was useful then, but I can't vouch for it under more recent versions of Windows.Overview
A
46

Correctly written Windows apps that want to save their location from run to run will save the results of GetWindowPlacement() before shutting down, then use SetWindowPlacement() on startup to restore their position.

Frequently, apps will store the results of GetWindowPlacement() in the registry as a REG_BINARY for easy use.

The WINDOWPLACEMENTroute has many advantages over other methods:

  • Handles the case where the screen resolution changed since the last run: SetWindowPlacement() will automatically ensure that the window is not entirely offscreen
  • Saves the state (minimized/maximized) but also saves the restored (normal) size and position
  • Handles desktop metrics correctly, compensating for the taskbar position, etc. (i.e. uses "workspace coordinates" instead of "screen coordinates" -- techniques that rely on saving screen coordinates may suffer from the "walking windows" problem where a window will always appear a little lower each time if the user has a toolbar at the top of the screen).

Finally, programs that handle window restoration properly will take into account the nCmdShow parameter passed in from the shell. This parameter is set in the shortcut that launches the application (Normal, Minimized, Maximize):

if(nCmdShow != SW_SHOWNORMAL)
    placement.showCmd = nCmdShow; //allow shortcut to override

For non-Win32 applications, it's important to be sure that the method you're using to save/restore window position eventually uses the same underlying call, otherwise (like Java Swing's setBounds()/getBounds() problem) you'll end up writing a lot of extra code to re-implement functionality that's already there in the WINDOWPLACEMENT functions.

Alessandraalessandria answered 9/9, 2008 at 23:56 Comment(2)
Thanks for the good answer. Using this info, at least I can manually set some programs to launch in a particular place, if I want to.Overview
It should also be noted that SetWindowPlacement() should check to see if that location does indeed exist. A common scenario is to put a laptop to sleep while its connected to dual monitors, and then wake it up later with only one, in which case the virtual screen space is dramatically smaller.Overview
P
58

Here's what I've found. If you want an app to open on your secondary monitor by default do the following:

1. Open the application.
2. Re-size the window so that it is not maximized or minimized.
3. Move the window to the monitor you want it to open on by default.
4. Close the application.  Do not re-size prior to closing.
5. Open the application.
   It should open on the monitor you just moved it to and closed it on.
6. Maximize the window.

The application will now open on this monitor by default. If you want to change it to another monitor, just follow steps 1-6 again.

Palaeozoic answered 4/2, 2009 at 15:5 Comment(6)
Thanks this really work. one comment I would like to add is that if the app is launched by a program, for e.g launch IE, you have to launch iexplore and follow what TryingToHelp listed. it works. in my case, I have a task scheduled program that launches IE with a given url as parameter. re-sizing and moving this IE launched by task scheduler didn't help.Bestiality
Doesn't work for me on Win7, unfortunately. Steps 1-5 do work, and if I don't maximize, the program (TeXstudio) starts on the proper monitor. As soon as I maximize and then close, the next start will occur on the other display.Towe
I can get this to work for some apps, but on Windows 10 PowerShell always starts on my laptop screen, never on the external monitor that I want it to start on.Arrowwood
Let me add the follwing remark: In my case, when I double-clicked on a .PDF file this did not work. Then I found out that it makes a difference to really open the application rather then double-clicking on an associated file. In this case, opening Adobe Acrobat via start menu, then doing the steps you described (i.e. move window to the desired monitor, then close it) just worked fine. Also ensure that the application window fits completely on the target screen and does not overlap to the 2nd monitor before you close it.Catfish
Important: Move the window with your mouse. Don't use the shift-windowskey-arrowkey hotkey or it will not work.Exonerate
This doesn't work. IT REQUIRES THE APP to actually save it's settings and shit and many apps are not properly designed. Very annoying... but part of life.Kennethkennett
A
46

Correctly written Windows apps that want to save their location from run to run will save the results of GetWindowPlacement() before shutting down, then use SetWindowPlacement() on startup to restore their position.

Frequently, apps will store the results of GetWindowPlacement() in the registry as a REG_BINARY for easy use.

The WINDOWPLACEMENTroute has many advantages over other methods:

  • Handles the case where the screen resolution changed since the last run: SetWindowPlacement() will automatically ensure that the window is not entirely offscreen
  • Saves the state (minimized/maximized) but also saves the restored (normal) size and position
  • Handles desktop metrics correctly, compensating for the taskbar position, etc. (i.e. uses "workspace coordinates" instead of "screen coordinates" -- techniques that rely on saving screen coordinates may suffer from the "walking windows" problem where a window will always appear a little lower each time if the user has a toolbar at the top of the screen).

Finally, programs that handle window restoration properly will take into account the nCmdShow parameter passed in from the shell. This parameter is set in the shortcut that launches the application (Normal, Minimized, Maximize):

if(nCmdShow != SW_SHOWNORMAL)
    placement.showCmd = nCmdShow; //allow shortcut to override

For non-Win32 applications, it's important to be sure that the method you're using to save/restore window position eventually uses the same underlying call, otherwise (like Java Swing's setBounds()/getBounds() problem) you'll end up writing a lot of extra code to re-implement functionality that's already there in the WINDOWPLACEMENT functions.

Alessandraalessandria answered 9/9, 2008 at 23:56 Comment(2)
Thanks for the good answer. Using this info, at least I can manually set some programs to launch in a particular place, if I want to.Overview
It should also be noted that SetWindowPlacement() should check to see if that location does indeed exist. A common scenario is to put a laptop to sleep while its connected to dual monitors, and then wake it up later with only one, in which case the virtual screen space is dramatically smaller.Overview
M
13

It's not exactly the answer to this question but I dealt with this problem with the Shift + Win + [left,right] arrow keys shortcut. You can move the currently active window to another monitor with it.

Marrin answered 18/9, 2014 at 9:42 Comment(2)
This worked for me but without Shift key i.e Win + [left,right] - helped me when working with one monitor and app opening on missing one!Aquiline
Important note: If you use this technique, windows will not save the current window position. You have to move/resize the window at least once with the mouse to achieve this.Exonerate
B
11

Get UltraMon. Quickly.

http://realtimesoft.com/ultramon/

It doesn't let you specify what monitor an app starts on, but it lets you move an app to the another monitor, and keep its aspect ratio intact, with one mouse click. It is a very handy utility.

Most programs will start where you last left them. So if you have two monitors at work, but only one at home, it's possible to start you laptop at home and not see the apps running on the other monitor (which now isn't there). UltrMon also lets you move those orphan apps back to the main screen quickly and easily.

Basilius answered 9/9, 2008 at 20:11 Comment(5)
I use UltraMon at home and work. Don't know how people live without it, really. lol. Can be a bit flaky at times when using the Smart Taskbar, but works well enough and often enough for me to stick with it. -- Kevin FairchildBorman
What a tacky website. It's 2009 people! But interesting product. Thanks for the link :)Talkie
I'm in this exact situation - a laptop docked with dual monitors at work, but just a little laptop screen when I'm away. It's astoundingly frustrating when an application loads in an area that used to be visible - MS Outlook is one of the biggest offenders. I'll get a copy of Ultramon and hopefully it makes life a little easier. Thanks!Yoder
If software is going to be mentioned, in 2015, DisplayFusion should be on the list. In Prefs / Window Locatoin, you can specify where specific apps should open. I like that the list is populated by currently open programs, so you don't have to hunt for them.Quatrain
To move apps that are 'trapped' on another screen use [win]+[arrow] when the app is in focus. This will move the app from screen to screen. Stop when it comes into view. Works on Win 7+Shillelagh
B
4

I'm fairly sure the primary monitor is the default. If the app was coded decently, when it's closed, it'll remember where it was last at and will reopen there, but -- as you've noticed -- it isn't a default behavior.

EDIT: The way I usually do it is to have the location stored in the app's settings. On load, if there is no value for them, it defaults to the center of the screen. On closing of the form, it records its position. That way, whenever it opens, it's where it was last. I don't know of a simple way to tell it to launch onto the second monitor the first time automatically, however.

-- Kevin Fairchild

Borman answered 9/9, 2008 at 20:4 Comment(0)
F
3

Important note: If you remember the position of your application and shutdown and then start up again at that position, keep in mind that the user's monitor configuration may have changed while your application was closed.

Laptop users, for example, frequently change their display configuration. When docked there may be a 2nd monitor that disappears when undocked. If the user closes an application that was running on the 2nd monitor and the re-opens the application when the monitor is disconnected, restoring the window to the previous coordinates will leave it completely off-screen.

To figure out how big the display really is, check out GetSystemMetrics.

Freightage answered 16/9, 2008 at 15:55 Comment(0)
A
2

So I had this issue with Adobe Reader 9.0. Somehow the program forgot to open on my right monitor and was consistently opening on my left monitor. Most programs allow you to drag it over, maximize the screen, and then close it out and it will remember. Well, with Adobe, I had to drag it over and then close it before maximizing it, in order for Windows to remember which screen to open it in next time. Once you set it to the correct monitor, then you can maximize it. I think this is stupid, since almost all windows programs remember it automatically without try to rig a way for XP to remember.

Amp answered 31/3, 2009 at 20:27 Comment(1)
Didn't really answer the question, but helped me :)Agama
I
1

So I agree there are some apps that you can configured to open on one screen by maximizing or right clicking and moving/sizing screen, then close and reopen. However, there are others that will only open on the main screen.

What I've done to resolve: set the monitor you prefer stubborn apps to open on, as monitor 1 and the your other monitor as 2, then change your monitor 2 to be the primary - so your desktop settings and start bar remain. Hope this helps.

Innate answered 7/6, 2012 at 18:17 Comment(0)
C
0

Do not hold me to this but I am pretty sure it depends on the application it self. I know many always open on the main monitor, some will reopen to the same monitor they were previously run in, and some you can set. I know for example I have shortcuts to open command windows to particular directories, and each has an option in their properties to the location to open the window in. While Outlook just remembers and opens in the last screen it was open in. Then other apps open in what ever window the current focus is in.

So I am not sure there is a way to tell every program where to open. Hope that helps some.

Connett answered 9/9, 2008 at 20:5 Comment(0)
H
0

I've noticed that if I put a shortcut on my desktop on one screen the launched application may appear on that screen (if that app doesn't reposition itself).

This also applies to running things from Windows Explorer - if Explorer is on one screen the launched application will pick that monitor to use.

Again - I think this is when the launching application specifies the default (windows managed) position. Most applications seem to override this default behavior in some way.

A simple window created like so will do this:

hWnd = CreateWindow(windowClass, windowTitle, WS_VISIBLE | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, SW_SHOW, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);

Hokeypokey answered 10/9, 2008 at 12:55 Comment(0)
C
-3

Right click the shortcut and select properties. Make sure you are on the "Shortcut" Tab. Select the RUN drop down box and change it to Maximized.

This may assist in launching the program in full screen on the primary monitor.

Chishima answered 31/12, 2014 at 0:3 Comment(1)
This doesn't actually answer the question, and this is an old question.Drennen

© 2022 - 2024 — McMap. All rights reserved.