PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Move Hidden Windows to active screen

Open MikeWilliams-UK opened this issue 5 years ago • 32 comments

Move Hidden Windows to active screen

Some applications do not play nicely with multiple monitor scenarios. They mainly the ones which remember their screen position.

Scenario Laptop with additional monitor.

Start an affected application when you have two monitors connected and move it to monitor two, shut PC down.

Disconnect the second monitor, then start up PC and run the affected application.

All you see is a task bar icon becuse the application has blisfully unaware thet the second monitor is not preset jumped to the monitor which does not now exist.

I know there is a documented way to move such windows to an available screen, but it requires quite a bit of faffing arround. I invariably end up googling for the required key chord each time I need it becuase it does not happed that often, but often enough to cause irritation.

A hook that allowed the user to right click the task bar icon and "move to screen n" would be very much appreciated.

Some of the code in https://github.com/MikeWilliams-UK/SSMS-Window-Fixer may be of use in this.

MikeWilliams-UK avatar Oct 25 '19 07:10 MikeWilliams-UK

Hi @MikeWilliams-UK , can you give an (or few) examples of applications with steps to recreate this?

Great idea, just want to be sure we fully understand the scenario.

crutkas avatar Oct 25 '19 22:10 crutkas

Sure will do. I will try to compile a list of apps which do it.

MikeWilliams-UK avatar Oct 26 '19 11:10 MikeWilliams-UK

Would you believe it, I am having trouble finding apps which now do this. The one I remember which gave me most grief was Notepad++, but just done a test and that now handles this properly. WinZip used to suffer too, but that was some time ago so might not be applicable now.

MikeWilliams-UK avatar Oct 28 '19 09:10 MikeWilliams-UK

@MikeWilliams-UK there are other cases/scenarios that trigger this problem, I remember it happened to me without an external monitor, just closing an app when it was half way out of the screen on the left, when I reopened it, its size was smaller and it wasn't visible on the screen. It's also annoying when you have the second monitor connected but turned off, Windows still sees it so if you closed the app then it was on the second monitor it will reopen there and it's annoying to have to turn the monitor on to move the window.

enricogior avatar Oct 28 '19 09:10 enricogior

@enricogior The more scenarios we can suggest the better chance of this being implimented.

MikeWilliams-UK avatar Oct 28 '19 11:10 MikeWilliams-UK

not saying this isn't useful or this scenario doesn't happen. But lets be sure we can test against known scenarios so lets create a few repro steps here so we know what we are targetting and can validate something works

crutkas avatar Oct 28 '19 21:10 crutkas

As a developer I appreciate that a scenario to test is vital.

I will see what I can find ...

MikeWilliams-UK avatar Oct 29 '19 08:10 MikeWilliams-UK

I thought that Notepad++ and Winzip exhibitd this behaviour, but sadly not. I have found the FileZilla 3.45.1 exhibits almost the same, with most of the window off screen. Not 100% off screen which was my original gripe with the 3rd party software, but it shows it as best I can find at the moment.

I will of course update this issue when I find others.

/Mike

MikeWilliams-UK avatar Nov 05 '19 20:11 MikeWilliams-UK

Possible to get a screenshot?

crutkas avatar Nov 06 '19 06:11 crutkas

Just captured a screen shot

  1. Open FileZilla on monitor 2
  2. Shutdown Laptop
  3. Disconnect monitor 2
  4. Start Laptop
  5. Open FileZilla

See screen shot below FileZilla Partially Off Screen

MikeWilliams-UK avatar Nov 06 '19 18:11 MikeWilliams-UK

I have been doing some more testing and I can now confirm that with the auxiliary monitor on the LEFT side of the laptop screen the behaviour is seen with WinZip (20.5)

I suspect that there are more applications which exhibit this behaviour due to the auxiliary screen having NEGATIVE co-ordinates.

  1. Ensure auxiliary monitor is on LEFT of primary monitor
  2. Open WinZip and move to auxiliary monitor, close WinZip
  3. Shutdown Laptop
  4. Disconnect auxiliary monitor
  5. Start Laptop
  6. Open WinZip

Winzip Left Monitor

MikeWilliams-UK avatar Nov 09 '19 12:11 MikeWilliams-UK

I've also noticed that when turning off a monitor connected via DisplayPort, the monitor disappear from the Window Display setting, but if the monitor is connected via HDMI, turning it off doesn't make it disappear, and so applications that open where they were closed, they end up on the turned off monitor.

enricogior avatar Nov 13 '19 10:11 enricogior

@enricogior I have seen that too as I have my laptop set up in my office connected to second monitor via HDMI. If I forget (or don't bother) to turn it on it does indead become a ghost monitor. In my case as I have windows task bar set up to "show taskbar buttons on" to "Taskbar where the window is open" I have to either turn the monitor on or unplug the cable. In this case my suggested tool would not help as there is no icon to right click on.

image

MikeWilliams-UK avatar Nov 14 '19 08:11 MikeWilliams-UK

hmmm, since this is on app launch after the state change, this would make us have to monitor all windows. Detect launch and do the resize. Part of me wonders however how to deal with apps w/ splash screens.

just detecting "useable" screen state isn't a good state by itself since i know i've hidden windows like that on purpose.

crutkas avatar Dec 18 '19 20:12 crutkas

I was thinking of it NOT being automatic for just such reasons. In Chem4Word we deliberately send windows off-screen(s) while they are composing.

I was thinking of it hooking into the right click action of a taskbar icon.

MikeWilliams-UK avatar Dec 19 '19 11:12 MikeWilliams-UK

I agree, this should not be automatic.

enricogior avatar Dec 19 '19 12:12 enricogior

IMHO Not being automatic should simplify the code.

MikeWilliams-UK avatar Dec 19 '19 12:12 MikeWilliams-UK

Manual workaround from Raymond Chen https://devblogs.microsoft.com/oldnewthing/20090511-00/?p=18303

enricogior avatar Jan 09 '21 13:01 enricogior

Sadly this does not work all of the time.

MikeWilliams-UK avatar Jan 09 '21 13:01 MikeWilliams-UK

Is this issue still relevant? Anything PowerToys can do about?

Jay-o-Way avatar Nov 22 '21 22:11 Jay-o-Way

I think this is a great issue but need clear repro steps. Win11 I know for some scenarios made things better in terms of dock / undock

crutkas avatar Nov 23 '21 07:11 crutkas

A couple of apps that might help people out:

  • Cmdow is a command line tool that can manipulate windows.
  • MultiMonitorTool from NirSoft is a GUI and command line tool can move windows between monitors. This would only be helpful if you have more than one monitor.

And to reiterate the workaround from Raymond Chen linked to above:

  1. Switch to the application by using Alt+Tab / Win+Tab or the taskbar
  2. Press Ctrl+Space to activate the window menu. (The one in the top left with Maximize/Restore, Move, Resize etc.) You should be able to see the menu in the top left of your screen at this point
  3. Press M to activate the _M_ove entry in the menu, (or whatever letter is underlined in your language) you should be able to see the menu but you can Google for images of it in your language.) Alternatively press Down Arrow, Down Arrow to navidage to the move option in the menu and Enter to activate it.
  4. Press any of the Arrow keys: Left Arrow / Right Arrow / Up Arrow / Down Arrow This step is important, it puts the window into a moving mode and allows the next step to work.
  5. Move the mouse and the window should automatically snap to the mouse position.

SamHasler avatar Nov 23 '21 09:11 SamHasler

@SamHasler I know that the workaround exists, but I personally don't use it enough for it to be in my "muscle memory" of actions that I always end up googling for it each time :-)

Of the two apps the CLI tools looks most powerfull but requires too much detail for the average user The GUI tool by NirSoft seems to lack the ability to position a window to a specific position on a screen which would be most usefull.

MikeWilliams-UK avatar Nov 23 '21 16:11 MikeWilliams-UK

I think this is a great issue but need clear repro steps. Win11 I know for some scenarios made things better in terms of dock / undock

What was wrong with my steps outlined in https://github.com/microsoft/PowerToys/issues/557#issuecomment-552097202?

MikeWilliams-UK avatar Nov 23 '21 16:11 MikeWilliams-UK

@MikeWilliams-UK

NirSoft have another tool that can move (center) windows on a single monitor.

  1. Download the WinLister application here.
  2. Run WinLister as Administrator and select the window you wish to move back on Screen. Not running as administrator will not give the application the ability to move the windows for you.
  3. Right click and select “Center Selected Windows” and you’re done!

(credit to this superuser.com answer)

SamHasler avatar Dec 01 '21 10:12 SamHasler

@MikeWilliams-UK

NirSoft have another tool that can move (center) windows on a single monitor.

1. Download the WinLister application [here](http://www.nirsoft.net/utils/winlister.html).

2. Run WinLister as Administrator and select the window you wish to move back on Screen. Not running as administrator will not give the application the ability to move the windows for you.

3. Right click and select “Center Selected Windows” and you’re done!

(credit to this superuser.com answer)

Interesting utility, thanks for pointing it out. Shame it only centres on primary screen ... Not sure why it would need admin rights for processes that are not elevated? Just tested it non elevated to try to move it's own window and it crashed !

MikeWilliams-UK avatar Dec 01 '21 10:12 MikeWilliams-UK

One of the comments on the answer points out that there's also WinExplorer which doesn't need admin rights. There's also GUIPropView

SamHasler avatar Dec 01 '21 10:12 SamHasler

@MikeWilliams-UK what's the status for your issue?

Jay-o-Way avatar Apr 04 '22 12:04 Jay-o-Way

This is a nice to have.

MikeWilliams-UK avatar Apr 04 '22 12:04 MikeWilliams-UK

This is still a problem and has been ever since we started to use multiple monitors and laptops.

The https://github.com/microsoft/PowerToys/issues/557#issuecomment-552097202 is very much on point. Sleep / Hibernate while on multiscreen and open in another config you often have the problem.

The WinExplorer, GUIPropView does not solve it at all. WinLister does solve it but it cumbersome.

On windows pre-11, you can alt+space, select move, press an arrow key and then position the window visible by mouse. On Windows 11, alt+space is now a global search, so instead you have to (one option) to shift+right click a window at the task bar , to get to the window menu, and then again -> move, arrow, mouse will do the trick.

The thing is that it is not impossible to do but feels decidedly dirty to do, and 90% of users out there has no clue.

I really feel that this issue should be fixed by the windows manager team (whatever they are called) at microsoft. They haven't fixed the issue in about 2 decades, so they are likely not about to. For me the great fix would be:

  • Whenever I switch to a program, either by clicking the task bar, alt+tab, windows+tab it should be placed on my main windows screen if it is placed in a non-visible screen. That's it.

For power tools: 1) Would it be possible to hook into window activation? If not, 2) add a windows menu to restore on visible screen? Or 3) a global hotkey to place all windows on visible screen (filtering only the windows/programs on the start bar as there can be other hidden windows meant to be hidden), or 4) whenever windows config change, reposition those hidden windows on main screen?

soerennielsen avatar Jan 29 '23 20:01 soerennielsen