AutoHotkey Community

It is currently May 27th, 2012, 7:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: March 16th, 2005, 8:12 pm 
Offline

Joined: February 17th, 2005, 10:06 am
Posts: 280
Location: Hungary, Budapest
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2005, 11:35 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nice improvement. I didn't even know about the ESC trick.

I've applied your change to the showcase version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2005, 12:00 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2005, 4:15 pm 
Offline

Joined: February 17th, 2005, 10:06 am
Posts: 280
Location: Hungary, Budapest
I'm glad you like it. I missed that feature so much, I just had to complement the script :-)
Chris wrote:
I've applied your change to the showcase version.
Wow, that is an honor!

_________________
Is there another word for synonym?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2006, 10:00 am 
Offline

Joined: February 17th, 2005, 10:06 am
Posts: 280
Location: Hungary, Budapest
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2006, 12:52 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
It's never appropriate/desirable to move a maximized window, even on a multi-monitor system?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2006, 3:23 pm 
Offline

Joined: February 17th, 2005, 10:06 am
Posts: 280
Location: Hungary, Budapest
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?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: nothing and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group