How do I get a window back on the screen when it moved far, far away?


Commenter Aggravated notes that some programs remember their location when the window is closed and restore to that location when the window is reopened, even if that position is off the screen. These programs clearly were using screen coordinates instead of workspace coordinates to save and restore the window.

Okay, so you’ve got a program that restored its window position incorrectly and ended up putting it off the screen. Now what do you do?

The keyboard interface comes to the rescue.

Switch to the application, say by clicking on its taskbar button or by Alt+Tab’ing to it. Then type Alt+Space to call up the System menu: You should get a window floating at the edge of the screen. Type M to select Move, then press an arrow key to enter Move mode. (Doesn’t matter which.)

At this point, you could stick with the keyboard motif and hold down the appropriate arrow key to move the window back onto the screen. Or you can pull a little magic trick: Wave the mouse around. Boom, the window leaps to the mouse like one of those cheapo magic tricks where something leaps into your hand.

I’m like 95% sure they use string. But it could be magic. No, I’m going with the string.

Comments (63)
  1. Nathan_works says:

    Hey Rocky, watch me pull a rabbit out of my hat..

    Interesting trick, I will have to remember this.. (lap top docked with dual monitors, but if I undock to take home, some winders don’t show back up on screen.. Now I know.. And knowing is half the battle..)

  2. steven says:

    One of my pet peeves is programs failing to use Set/GetWindowPlacement properly. Using a laptop with an extra monitor when docked and having my taskbar at the top of the screen rather than at the bottom I seem to run into this with alarming regularity.

  3. Ickithus says:

    I have this problem occassionally only different, lol.  Sometimes my primary monitor, an Acer, doesn’t come want to come back on after an inactivity suspend and nothing will bring it back but a reboot or a resolution change.  

    I don’t want to reboot so I turn on my secondary monitor to attempt a resolution change but right clicking the desktop there brings up the display properties dialog on the primary monitor where I can’t see it and I can never remember the keys to press to move and get in in view.

  4. Mark says:

    This is another Win32 tax: check for universal shortcuts like Alt+Space, and don’t swallow them.

    [Try writing a Win32 program. You’ll find that you have to go out of your way not to pay this tax. -Raymond]
  5. Steve Hiner says:

    You can also right click the button in the taskbar and select Move from the context menu.  That’s the way I’ve always done it.

  6. someone else says:

    “[Try writing a Win32 program. You’ll find that you have to go out of your way not to pay this tax. -Raymond]”

    The otherwise extremely useful app Launchy does exactly that. It’s standard activation shortcut is Alt+Space. Alt followed by Space still works, though.

    [My original statement stands. -Raymond]
  7. Mark says:

    Raymond: good point, I guess it should be filed under programming pathologies.

  8. Brian says:

    Related to this, I’ve always wondered, why do you have to hit an arrow key before the window starts responding to the mouse?

  9. Mark says:

    Brian: because otherwise the window would jump straight to the mouse when you clicked move.  And you can’t say "wait until the mouse moves" because that’s too easy to set off by accident.  It would be nice if you could right-click for the magic trick, though.

  10. DWalker59 says:

    Yep, like Ickthus, I recently had a hard time trying to get a dual-monitor setup working.  I was changing video adapters and adding a second monitor…

    Occasionally, the hardware boot messages would come up on the primary monitor, but after Windows started, that one was blank.  The second monitor had a desktop background.

    Right-clicking on the secondary monitor to get the display properties dialog didn’t show anything; I’m sure the dialog came up on the blank primary monitor.   It was a bear to finally beat it into submission.

  11. Frank Schwab says:

    I’m going with Mark on this one.

    A great feature addition for a future version of Windows (or a future service pack) would be an addition to the right-click menu on the taskbar button to say "make this window visible".  It should automatically apply restore, move, and size to give me a usable window for this app on the primary monitor.

    /frank

  12. me says:

    Hello,

    just a short nitpicking: ;)

    Keep in mind that "m" for "move" has to be changed for other languages).

    me.

  13. noname says:

    Good tip. But this doesn’t work with mstsc properly and I have yet to find a solution for this (except term serving into the machine straight from the home machine).

    The scenario is like this:

    i)Term served into a machine at work w(dual monitors) from home h(single monitor).

    ii)From the work machine w, try term serving into another machine at work. MSTSC remembers the last screen position and shows up on the secondary monitor. And I have it to open it in maximize mode.

    iii) Right click on the taskbar window to bring up the system menu. Only minimize is allowed. On minimizing, there is only Restore allowed, which maximizes the window again.

    Opening other mstsc windows also uses the same screen coordinates to open.

  14. steveshe says:

    @noname –  You can force the screen resolution to something less than full screen in the mstsc command line and that will get you a window you can then move.

  15. Mark (The other Mark) says:

    In MSTSC, Options, Local Resources. Under the Keyboard section, "Apply Windows key combinations (for example, ALT + TAB)"

    Your choices are "Local Computer", "Remote Computer", and "In full screen only".

    In full screen only means Remote Computer if MSTSC is full screen, otherwise Local. With this option, ALT-SPACE runs exactly where expected- Remote Computer if full screen, local computer if not.

  16. Leo Davidson says:

    Two closely related tips:

    (Raymond’s tip is still the best when dealing with a single window that is off-screen or not resizeable. I use it frequently. In certain situations there are quicker ways to get your windows back, though.)

    1) Lots of off-screen windows.

    If you have several windows off screen (e.g. because you just lost a monitor with a bunch of apps on it) you can snap them all back on-screen in a single step.

    Just do something which causes the desktop work area to be resized. For example, resize or move the taskbar (then move/size it back again).

    2) Resizable window off the top of the screen, but still visible.

    If a window’s titlebar has gone off the top of the screen (often due to top-docked toolbars and apps that don’t use GetWindowPlacement properly), but lower parts of the window are visible and it is resizeable, then resizing it slightly via one of its available edges should snap its titlebar back on-screen so that you can move it again.

    (Both of these work on Vista, at least. It’s possible other versions of Windows behave differently.)

  17. PhantomLord says:

    Thank you, thank you, thank you, thank you. The software we are developing for has all kinds of quirky window placement. Everytime we undock our laptops and bring them to conference rooms to hook up to projectors, things never show up right. The program’s main window doesn’t cause too many problems, but pop up windows do. Fortunately this trick works with them. This tip couldn’t not have been a better time.

    I couldn’t get the waggle to work though on XP. Is that a Vista feature?

  18. John Topley says:

    I have actually had to do this to get a window back on screen before.

  19. It’s a classic, I’ve known about it for years. But hey, somebody needs to tell people about it!

  20. Mark says:

    noname: you can also press Ctrl+Alt+Break, see http://support.microsoft.com/kb/301583.  Interesting how many websites reproduce this page verbatim in order to get Google hits.

  21. dbt says:

    I’ve used this trick to move windows off screen before, but the less said about 14 year old practical jokes the better :)

  22. Dwight Shih says:

    Thank you, Thank you, Thank you.

    I have a dual monitor setup with the 2nd monitor on the left (keeping my windows menu close to the middle of my workspace rather than the far left edge). Every now and then some brilliant piece of software decides that the 2nd monitor is really on the right and opens an window somewhere out there. Taskbar move never worked for me because I didn’t realize I needed to use an arrow button to prime the pump.

  23. warrens says:

    On Windows 7, you can just hit Win+Left or Win+Right until the window comes into view.

    Also, Win+Up and Win+Down have been introduced as shortcuts for Maximize and Restore.

  24. Euro says:

    Yes, I’ve used this trick for years, sometimes to the astonishment of a coworker or two.

    My favorite culprit is a certain internal application that saves its window location on exit, without checking first if the application has been minimized. (see: http://blogs.msdn.com/oldnewthing/archive/2004/10/28/249044.aspx).

  25. Ray Trent says:

    Would you believe the first app I tried this on just now failed, and moved the cursor around its default text input block instead of moving the window.

    That, in spite of it accepting the Alt-Space and showing the movement cursor.

    Sigh.

  26. Josh says:

    I’d always done the same thing, but the first step was simply "Right-click taskbar entry, select Move" then pick up with the Arrow Key tap.  For people who aren’t used to keyboard shortcuts, the mouse commands are a little more intuitive.

    This came up a *lot* during development of span mode features in Remote Desktop, since it often involved switching between double width and normal monitor sizes.  We considered trying to fix it with auto-rearrangement of windows, but that involved a lot of potentially inaccurate heuristics, and would only work when switching from local to remote use, since we lacked control in the remote to local use case.

  27. Slow day? says:

    Are you out of things to talk and write about?

  28. A_me! says:

    Another method I’ve used is to have the window active and use the ‘cascade windows’ option from the task bar.  That usually gives you something you can get ahold of at the expense of resizing everything else on your screen.

  29. Semi Essessi says:

    This is great, but there are some apps out there badly behaved enough to break this. :(

  30. Dale says:

    Thanks for sharing Raymond.

    I have often wondered if there was an easy way to get a window back on screen.

  31. Brian says:

    Mark: Yes, but as soon as you select "Move" your cursor jumps to the title bar (and turns into a move cursor, making you think that moving it will actually do something).

  32. porter says:

    Perhaps people have forgotten you can use Windows without a mouse, trackpad or other pointing device.

  33. porter says:

    > How do I get a window back on the screen when it moved far, far away?

    Send Shrek on a quest to get it back.

  34. Puckdropper says:

    Adjusting the window size via the keyboard works the same way as move.  That may be part of the reason you have to "prime the pump" by tapping one of the arrow keys first to get in to move mode.

  35. Anonymous Coward says:

    >9603999 Just do something which causes the desktop work area to be resized.

    This happens for example, when you use win-L, or when you hibernate. Can’t say I’m happy with that though.

  36. silky says:

    waving the mouse around didn’t work on windows xp … can anyone reproduce?

    [Works for me. Don’t forget to hit an arrow key first. -Raymond]
  37. Worf says:

    I love that trick. I use it to beat the windows update dialog into submission (move it to an edge of the screen) while I do my work to get around to a more convenient time to reboot. Beats having it pop up up every 5 minutes. All I’m left with is a sliver of it along the edge.

    Though, if I cause a desktop resize, it pops back into view. (Unplug external monitor, say)

    Some video drivers also have this capability to rescue lost windows. At least, I think the nVidia ones do.

  38. silky says:

    Ah, indeed I did need to hit the arrow first. My mistake.

  39. Brett Morien says:

    But, I don’t want a trick… I RAS into my work computer (with 2 monitors) daily after working with it all day.  My applications are roughly half on one screen, half on the other.  I don’t want to be smart enough to remember a konami code to be able to see things.

    Can we please think of something smarter than this?  I knew this trick before, but every successive version of Windows gives me hope that I don’t have to trick the operating system into showing me my running applications.

    Seriously… keyboard and mouse shortcuts combined?  I know people who have lost the task bar to resizing/moving…

  40. I’ve been using this trick for a while, since I change a lot from the monitor on my dockstation (with higher resolution) to my laptop monitor when on the move (with lower resolution) and some windows decide to "hide".

    Luckily I found exactly how to do it (as you described).

  41. porter says:

    > I knew this trick before, but every successive version of Windows gives me hope that I don’t have to trick the operating system into showing me my running applications.

    Do you want the Windows 1.0 Tiled Windows?

    Have you tried the desktop’s "Cascade Windows" menu option?

  42. Neil says:

    noname: perhaps you can make your home-to-work session a custom size to cover the unified area of your work monitors?

  43. titania says:

    For problems like this you need a window manager (system) like Oberon, there the screen resolution is always infinite and you just zoom.

  44. Miguel says:

    ¡Thanks a lot! This has ended months of using Photo Editor only in a maximized window!

  45. Chris says:

    @Worf Instead of doing that, you can always just run sc stop wuauserv until you want to restart.

  46. obrienslalom says:

    Man, what great timing.  I read this article yesterday 5/11, and randomly got asked the question by a coworker 5/12. I played it cool like I knew it the whole time. Sorry, I didn’t give you credit!

  47. MadQ says:

    @Chris: at least on XP, CSRSS will be mean and restart the service for you unless the you’ve disabled it. While I usually don’t mind rebooting, when I’m in the middle of complex debugging session, I really, really don’t want to. To solve this problem, I’ve set up a shutdown script (per policy) to re-enable to the the update service. This has served me well, and saved me from missing quite a few critical updates.

    As for the magic window re-appearance trick, it has the disadvantage of turning one into a personal support technician, and word gets around.

  48. Absotively says:

    > Switch to the application, say by clicking on its taskbar button or by Alt+Tab’ing to it. Then type Alt+Space to call up the System menu.

    Is there any reason not to get the System menu in one step by right-clicking the taskbar button?

    [I guess that would work too. I’m personally an Alt+Space person. -Raymond]
  49. Aaargh! says:

    Reminds me of a nice ‘feature’ in Win95 (don’t know if it was still around in Win98).

    If you opened the start menu, closed it with ESC, the menu kept the focus. You could then open the window context menu for the start button with either ALT+space or ALT+minus (can’t remember which, or both) and then choose ‘close’.  Result: a taskbar without start button.

    Could be slightly amusing in combination with teachers, computer salesmen and the like.

  50. Brian says:

    Aaargh!  I used to do that to all the computers in best buy, compusa, computer city, etc…  great fun.

  51. Puckdropper says:

    Absotively,

    I’m using Windows 7 RC.  Right clicking on the task bar icon brings up a different right click menu.  Right clicking on the image of the program still brings up the control menu, though.

    Alt+Space might be easier to explain.

  52. Worf says:

    Strange, when I use Remote Desktop from my single screen at home to my dual monitor work, windows on the second screen migrate to the first when I activate them (but stay on the second screen if I don’t…)

    Gets annoying though since I have to reposition them in the morning.

  53. cthulhu says:

    what if the app is in fullscreen? It doesn’t seem to work then, can’t move it at all. Is this a bug?

  54. MadQ says:

    @cthulhu: You can move even full-screen windows if they’re not maximized. You could try to Restore the window using the same method before moving it. Your mileage may vary.

    "Vee heff vays too make ziss epp break ze rules!"

      — Some programmer with a really bad accent†

    † A fiend of Hogan’s, I hear.

  55. streuth says:

    I don’t know about anyone else, but this is a major beef I have with Windows 7. (Not that anyone is listening to me, because I also hate that the menu based startmenu has gone completely).

    The thing is that with the old style taskbar, move was an option on the task bar application/system menus.

    Now that has gone, replaced by pinning (which IMO is not actually a bad idea) when you get this off screen problem, there is no visible menu that you can use to move the window back on screen.

    Now I know that Raymond has said that the menu should pop up at the edge of the screen, but it doesn’t for me. The reason is that “off screen” for me is a large display which is on the other side of the room, and which I have to physically go to to be able to switch it on.

    What is frustrating is that pinning doesn’t have to exclude the old applicaion/system menu options. O.K. so the new menu override that Windows 7 provides for the taskbar would have more stuff on it, but so what.

    What do Microsoft have against menus all of a sudden. It’s like a menu with more than one item on it is now taboo.

    I swear on my life that this flagellatory sadomasochistic madness is going to bring your business down.

    People liked XP, don’t patronise them with improvements that arent.

    [The option is still there in Windows 7: Right-click the thumbnail, or hold Shift when you right-click the taskbar. And there is a technical reason why pinning cannot be combined with the system menu. I’ll make a note to discuss it in late 2010. -Raymond]
  56. streuth says:

    Aha!

    "Shift"…. I should have known.

    Perhaps there is a technical reason, I’ll bow to your superior knowledge on that one.

    TBH I’m serious about the business thing though. Clearly it’s just an opinion, but there are loads of good things about Vista, but some of the greatest "Microsoft Own" ideas that actually made Microsoft now seem to be under threat from within.

    I know this not because of what I think, but because of what my *mother* thinks.

    Perhaps this is a 2 dimensional way of thinking about all of this, but to me "innovative", is about extending the boundaries.

    The thing is that you’re not extending the boundaries when the boundary behind you moves in the same direction as the boundary that you’re pushing forward.

    To expand the boundaries, one boundary has to be fixed whilst the other moves away from it. Either that or the two boundaries must each move away from the other.

  57. felipe2050 says:

    This doesn’t work with windows without the control menu, for example wizards. Last week I had this problem with the "New Virtual Machine" of Virtual PC

  58. Glass says:

    Not breaking the Alt+Space shortcut is nowhere near paying a tax, it’s more like not commiting murder or something like that.

    BTW, I never use maximize/restore/minimize buttons, only alt+space then X/R/N.

  59. Eric G. says:

    It may just be my ATI driver, but both Firefox and IE like to open on my secondary monitor, even when it’s turned off.

    For some reason, I often have to select "Restore" twice before the "Move" option is enabled.  Any idea why?

  60. paul says:

    Felipe: how did you manage with the "New Virtual Machine" wizard? I’m also having problems with that.

  61. Josh S. says:

    This problem has bothered me for quite a while.  I do wish the operating system would just handle this so that a window can’t be fully offscreen. It’s really bad if the window is off screen but doesn’t have a tray icon, because then it’s nearly impossible to tell that there’s even a window open.

    This bothered me enough that I finally wrote a utility to reposition offscreen windows…  If anyone’s interested, I put it on codeplex (along with the source code) here: http://www.codeplex.com/SheepDog.  

    It’s still a little rough around the edges, and a little heavyweight for what it does (built it in C#), but it’s really nice to have a global shortcut that snaps offscreen windows into view.

  62. Its been a while since I have had a chance to update so I’ve got a few things I haven’t had time to post

Comments are closed.