But first some quick
Background:
========
Do you ever work with multiple monitors? If you do, you probably have to move windows from one screen to the other quite a lot. Did it ever happen to you that one window for some reason managed to appear off-screen, so you couldn't grab the title bar anymore?
It happened to me last Friday...
I had to laugh out loud when I learned what loops you have to jump through in WindowsXP to remedy this situation.
Get this:
- You have to hover your mouse cursor on the window you want to move.
- Then you have to press [Alt]+[SPACE] to trigger the window menu
- Next you press [M] for move. (Warning: This key is localized, [V] in a German Windows version for example (yeah, I'm forced to use this version at work ))
- Now you can use your keyboard (!) cursor keys [UP],[DOWN],[LEFT],[RIGHT] to move the window around.
Yeah, right.... :roll: Well, I already knew AutoHotKey from my recent Umlaute Convenience script so it didn't take me long to glimpse at AutoHotKeys' features to capture mouse input and to move windows around. Well it can do all that, too.
Idea:
===
I have worked with KDE on top of Linux a number of times and really liked their solution to move windows around. Here you press [ALT] and click ANYWHERE within ANY window and just start dragging it around with your mouse. Just release [ALT] when you are done.
Well, my idea was to re-produce this behavior in Windows XP.
In this script, I also stumbled upon one minor AutoHotKey (or rather Windows API probably) limitation.
You will notice this when moving maximized windows. I will not go into more details here. See my posting "minor request: ToggleWindowFlags" in the "Wish List" sub forum.
Oh, btw. this script has one unexpected positive side effect. Sometimes windows freeze on me (due to network latencies) for an arbitrary amount of time. Moving these windows around with the AutoHotKey script immediately unfreezes them.
Enjoy:
Script:
====
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; KDE-Style Alt-Grab Window Move Convenience Script ;; ;; ;; ;; version 0.1 - 07/24/04 ;; ;; ck <use www.autohotkey.com forum to contact me> ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Usage Instructions: ;; ------------------- ;; Load Script into AutoHotKey (only verified to work properly with 1.0.16 and Windows XP) ;; - Hold down the Alt key and lef-click anywhere in a window to move the window LAlt & LButton:: ; If this command isn't used, all commands except those documented otherwise (e.g. WinMove and InputBox) ; use coordinates that are relative to the active window CoordMode, Mouse, Screen ; speed things up SetWinDelay, 0 ; get current mouse position MouseGetPos, OLDmouseX, OLDmouseY, WindowID ; get the postition and ID of the window under the mouse cursor WinGetPos, winX, winY, winW, winH ,ahk_id %WindowID% ; Turn off Window Animation ;RegRead, BoolMinAni, HKEY_CURRENT_USER,Control Panel\Desktop\WindowMetrics, MinAnimate ;if BoolMinAni = 1 ;{ ; ; this has no effect until it's reloaded / re-logon... (-> disabled code) ; RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop\WindowMetrics, MinAnimate, 0 ;} ; this restore (= undo max or min) call tells the OS that originally ; maximized windows are now restored/normal and can be moved even after this script takes off ; this is absolutely mandatory for windows which remember their last location like IE windows ; otherwise you cannot properly maximize them anymore ;WinHide, ahk_id %WindowID% WinRestore, ahk_id %WindowID% WinMove, ahk_id %WindowID%,,%winX%,%winY%,%winW%,%winH% ;WinShow, ahk_id %WindowID% Loop { ; is the User still keeping that Alt key down? GetKeyState, AltKeyState, Alt, P if AltKeyState = U ; key has been released { break } ; get new mouse position MouseGetPos, newMouseX, newMouseY ; get relative mouse X movement if newMouseX < %OLDmouseX% { ; mouse was moved to the left Xdistance = %OLDmouseX% EnvSub, Xdistance, %newMouseX% EnvSub, winX, %Xdistance% } else if newMouseX > %OLDmouseX% { ; mouse was moved to the right Xdistance = %newMouseX% EnvSub, Xdistance, %OLDmouseX% EnvAdd, winX, %Xdistance% } else { ; mouse X coordinate wasn't changed } ; set OLDmouseX OLDmouseX = %newMouseX% ; repeat the same stuff for the Y-axis if newMouseY < %OLDmouseY% { Ydistance = %OLDmouseY% EnvSub, Ydistance, %newMouseY% EnvSub, winY, %Ydistance% } else if newMouseY > %OLDmouseY% { Ydistance = %newMouseY% EnvSub, Ydistance, %OLDmouseY% EnvAdd, winY, %Ydistance% } else { } OLDmouseY = %newMouseY% ; move Window accordingly WinMove, ahk_id %WindowID%,,%winX%,%winY% } return