AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

move a window without having to click in the title bar

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
brak2718
Guest





PostPosted: Mon Mar 29, 2004 2:06 am    Post subject: move a window without having to click in the title bar Reply with quote

;; Move the selected window by moving the mouse into the title bar
;; and do a click&hold. Tested under Win2k, sp4. The window at
;; least has to be active (selected) before the move ... I used the
;; "tweak ui" program from Microsoft to enable the "activation follows
;; mouse feature .. so now to move a window I just put the mouse
;; anywhere in the window and hit #Tab.
;;

#Tab::

;;; be certain we have a regular window selected and not the
;;; root program manager
;;;
WinGetTitle, wtitle, A
if wtitle =
{
return
}
if wtitle = Program Manager
{
return
}

BlockInput, On

;;; temporarily set the window title to something unique. yes, I
;;; know this is a hack. (otherwise we might select the wrong one
;;; if multiple windows have the same title).
;;;
t1 = "{*(.q"
WinSetTitle, A, , %t1%

WinGetPos, wx1, wy1, , , A
wx1 += 40
wy1 += 10
WinActivate, Program Manager
MouseMove, %wx1%, %wy1%, 0 ; the mouse is now on the title bar


;;; make sure window is on top and then restore title
;;;
WinActivate, %t1%
WinSetTitle, A, , %wtitle%

MouseClick, left, , , , , D
BlockInput, Off
return
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Mon Mar 29, 2004 8:08 am    Post subject: Reply with quote

I tried that out, it's pretty nice even without the "activation follows mouse" setting. It's especially good for people who like to keep multiple windows visible simultaneously. You just press Win+tab and then drag the mouse to where the window should go, then click once to "drop" the window.

The following, when added to the top of the hotkey subroutine, might be an improvement since it allows you to press the same hotkey a second time to release the mouse (saves from having to left-click after the move, which some might like):

Code:
GetKeyState, state, LButton
if state = D  ; Left mouse button is already down.
{
   MouseClick, left, , , , , U  ; Release it.
   return
}
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Mon Mar 29, 2004 9:03 am    Post subject: Reply with quote

It looks like a combination of Windows API calls WindowFromPoint() and GetCursorPos() can determine which window is under the mouse. If it would be a significant improvement for you, I can extend one of the existing commands to support this feature.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group