; Easy Window Dragging (requires XP/2k/NT) ; http://www.autohotkey.com ; Normally, a window can only be dragged by clicking on its title bar. ; This script extends that so that any point inside a window can be dragged. ; To activate this mode, hold down CapsLock or the middle mouse button while ; clicking, then drag the window to a new position. ; Note: You can optionally release Capslock or the middle mouse button after ; the first click rather than holding it down the whole time. ~MButton & LButton:: CapsLock & LButton:: CoordMode, Mouse ; Switch to screen/absolute coordinates. MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin% SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it. return EWD_WatchMouse: GetKeyState, EWD_LButtonState, LButton, P if EWD_LButtonState = U ; Button has been released, so drag is complete. { SetTimer, EWD_WatchMouse, off return } GetKeyState, EWD_EscapeState, Escape, P if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled. { SetTimer, EWD_WatchMouse, off WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY% Return } ; Otherwise, reposition the window to match the change in mouse coordinates ; caused by the user having dragged the mouse: CoordMode, Mouse MouseGetPos, EWD_MouseX, EWD_MouseY EWD_DeltaX = %EWD_MouseX% EWD_DeltaX -= %EWD_MouseStartX% EWD_DeltaY = %EWD_MouseY% EWD_DeltaY -= %EWD_MouseStartY% EWD_MouseStartX = %EWD_MouseX% ; Update for the next timer call to this subroutine. EWD_MouseStartY = %EWD_MouseY% WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin% EWD_WinX += %EWD_DeltaX% EWD_WinY += %EWD_DeltaY% SetWinDelay, -1 ; Makes the below move faster/smoother. WinMove, ahk_id %EWD_MouseWin%,, %EWD_WinX%, %EWD_WinY% return
Easy Window Dragging - Esc cancels drag
Started by
SanskritFritz
, Mar 16 2005 07:12 PM
6 replies to this topic
I allowed myself to enhance the Easy Window Dragging script. I missed the original windows functionality from the script, i.e. when I press Esc during dragging, it cancels the move, thus resetting to the original window position. I changed as little as possible in the original script, only one variable name was changed to conform to the naming convention.
#1
-
Posted 16 March 2005 - 07:12 PM
Is there another word for synonym?
Nice improvement. I didn't even know about the ESC trick.
I've applied your change to the showcase version.
I've applied your change to the showcase version.
#2
-
Posted 16 March 2005 - 10:35 PM
I never knew about that. I love the little "hidden" features of Windows, and this sounds like it'd be a perfect addition to my hotkey list. (The original feature, not the script.)
Btw, good job! I like it when people dare to get dirty and do stuff themselves.
Edit: Heh, dittoing Chris. :roll:
Btw, good job! I like it when people dare to get dirty and do stuff themselves.
Edit: Heh, dittoing Chris. :roll:
#3
-
Posted 16 March 2005 - 11:00 PM
I'm glad you like it. I missed that feature so much, I just had to complement the script :-)
Wow, that is an honor!I've applied your change to the showcase version.
#4
-
Posted 17 March 2005 - 03:15 PM
Is there another word for synonym?
Another very little change: If a window is maximized, it wont budge:
CapsLock & LButton:: CoordMode, Mouse ; Switch to screen/absolute coordinates. MouseGetPos, EWD_StartX, EWD_StartY, EWD_Window WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_Window% WinGet, EWD_WinState, MinMax, ahk_id %EWD_Window% if (EWD_WinState = 0) ; Only if the window isn't maximized SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it. return
#5
-
Posted 25 September 2006 - 09:00 AM
Is there another word for synonym?
It's never appropriate/desirable to move a maximized window, even on a multi-monitor system?
#6
-
Posted 26 September 2006 - 11:52 PM
Well, I have multimonitor, but have you ever tried to fit the window exactly into the available space? It's a matter of personal preference i guess, I personally freaked out whenever i moved a maximized window, so I made that change.It's never appropriate/desirable to move a maximized window, even on a multi-monitor system?
:-)
#7
-
Posted 27 September 2006 - 02:23 PM
Is there another word for synonym?