 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SanskritFritz
Joined: 17 Feb 2005 Posts: 280 Location: Hungary, Budapest
|
Posted: Wed Mar 16, 2005 7:12 pm Post subject: Easy Window Dragging - Esc cancels drag |
|
|
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.
| Code: | ; 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 |
_________________ Is there another word for synonym? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Wed Mar 16, 2005 10:35 pm Post subject: |
|
|
Nice improvement. I didn't even know about the ESC trick.
I've applied your change to the showcase version. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 2951 Location: Minnesota
|
Posted: Wed Mar 16, 2005 11:00 pm Post subject: |
|
|
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.  |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 280 Location: Hungary, Budapest
|
Posted: Thu Mar 17, 2005 3:15 pm Post subject: |
|
|
I'm glad you like it. I missed that feature so much, I just had to complement the script
Wow, that is an honor! _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 280 Location: Hungary, Budapest
|
Posted: Mon Sep 25, 2006 9:00 am Post subject: |
|
|
Another very little change: If a window is maximized, it wont budge:
| Code: | 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
|
_________________ Is there another word for synonym? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Tue Sep 26, 2006 11:52 pm Post subject: |
|
|
| It's never appropriate/desirable to move a maximized window, even on a multi-monitor system? |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 280 Location: Hungary, Budapest
|
Posted: Wed Sep 27, 2006 2:23 pm Post subject: |
|
|
| Chris wrote: | | It's never appropriate/desirable to move a maximized window, even on a multi-monitor system? | 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.
 _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|