Keyboard shortcut for moving a window to another screen

20

10

When working with two (or more screens), a common problem is that launched applications appear on the "wrong" screen. I especially find this annoying when launching a text editor from the command line, because I have to leave the home row with my right hand in order to drag the window to the "right" screen before I can continue typing.

Is it possible to define a keyboard shortcut which moves the current application to the other/next screen?

Edit: I'm using Windows XP, but it's good to know that the feature already exists in Windows 7.


Edit2: I went for the autohotkey script. This adaptation works for me:
#q::
WinGetPos, winx, winy,,, A
WinGet, mm, MinMax, A
WinRestore, A
If (winx > 1270)
{
    newx := winx-1270
    OutputDebug, Moving left from %winx% to %newx%
}
else
{
    newx := winx+1270
    OutputDebug, Moving right from %winx% to %newx%
}

WinMove, A,, newx, winy

if mm=1
    WinMaximize, A
Return

I did have to make use of the OutputDebug statements and dbgview to discover the proper threshold value 1270 for moving left or right. The exact threshold is especially important when moving maximized windows to the left.

wcoenen

Posted 2009-10-29T15:23:17.377

Reputation: 2 060

Answers

4

Autohotkey! This'll move between the monitors (two 1680x1050 monitors, set the value after Loop, to be each monitor's screen resolution/10 if you're different) on winkey (#) and q. Control is ^, alt is !, shift is +, and letters are letters. You can use combinations of the modifiers, too.

#z:: ;Move the active window to the other monitor.
WinGetPos, winx, winy,,, A
WinGet, oldWin,ID,A
WinActivate, A
WinGet, mm, MinMax, A
WinRestore, A
If winx+5 >= 0 then
    mult=1
else
    mult=-1
WinMove,A,, winx-(1680*mult), winy
if mm=1
    WinMaximize, A
Return

Phoshi

Posted 2009-10-29T15:23:17.377

Reputation: 22 001

1This is promising, but the loop is really slow. The window crawled over my desktop at a snail's pace :-) – wcoenen – 2009-10-29T15:59:03.670

The script also moves the window under the mouse pointer, instead of the currently active one. – wcoenen – 2009-10-29T16:03:05.690

Whoops! I have it on mouse 4 and double click, so under mouse is better for me, and the crawling thing is because XP was slow at redrawing windows. It's fine on Vista and above. One moment, please :) – Phoshi – 2009-10-29T16:11:27.077

Right, edited the script there, try that :) – Phoshi – 2009-10-29T16:14:22.220

58

What version of Windows are you using? Windows 7 comes with native support for exactly this.

Win+Shift+left: Move focussed window one monitor to the left

Win+Shift+right: Move focussed window one monitor to the right

EDIT: For XP you could try out UltraMon. Amongst other things it will allow you to define hotkeys for "Move window to next monitor" and "Move window to previous Monitor".

BenA

Posted 2009-10-29T15:23:17.377

Reputation: 5 245

2THIS should have been picked as the answer. Glad I found this. – Bless Yahu – 2012-07-16T18:30:06.387

This behaviour is only true for my right windows key and not my left windows key. The choice of my left or right shift key is irrelevant. Can anyone else confirm this behaviour? If I use my left windows key then the window resizes instead of moving to the other monitor. – Tim Partridge – 2012-11-28T16:26:56.553

1I feel like a newb for not knowing that +1 – Ivo Flipse – 2009-10-29T15:30:38.313

Off topic, but how did you make those "buttons"? – sYnfo – 2009-10-29T15:30:45.663

2@sYnfo wrap the "button" in a <kbd></kbd> tag – BenA – 2009-10-29T15:32:55.737

+1, thanks for that. I was using Ultramon previously, no longer need it with this. – Pauk – 2009-10-29T15:34:43.453

Ultramon is expensive, but IMO well worth the price. – Phoshi – 2009-10-29T15:51:56.367

3

in other versions of windows, you can right click on the taskbar, select "move" and then use the arrow keys to move the window across to the correct window... I only mention this because every now and then, I accidentally leave a window on the wrong monitor and then when I use my laptop at home, I can't see the window because it's off monitor. Took me a while to figure this out!

Bluesbrkr

Posted 2009-10-29T15:23:17.377

Reputation:

Correction: In Windows 7, you can move from the taskbar - Use Shift + Right Click – Amit Naidu – 2017-11-11T22:09:05.380

1

Though under Windows7 You cannot move from the taskbar menu, You still can move the windows using shortcut keys:

Ctrl+Space and then M, arrow keys, finally Enter.

http://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts#Window_management

– Roland Pihlakas – 2013-07-07T17:50:56.627

1

If you don't have Windows 7, you may want to try DisplayFusion. The free version allows you to configure hotkeys to move windows to the next monitor, and several other goodies.

Charles Savoie

Posted 2009-10-29T15:23:17.377

Reputation: 11