Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

move a window without having to click in the title bar


  • Please log in to reply
2 replies to this topic
brak2718
  • Guests
  • Last active:
  • Joined: --
;; 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

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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):

GetKeyState, state, LButton
if state = D  ; Left mouse button is already down.
{
	MouseClick, left, , , , , U  ; Release it.
	return
}


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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.