With the help of your ideas, I made a new version with the following changes:
- Inactive windows are send to the background as well, see the first script by skrommel. I left out the check for the class WorkerW; what is this? This should also fix TeknoMusicMan's problem cycling through the windows. I did not know how to activate the topmost window anyway (unless it is for sure under the cursor which it is not always).
- Dragging with the right mouse button should work. This should also fix some of TeknoMusicMan's gesture problems though for sure not all.
This is similar to skrommel's second script above but does not use $RButton and it fixes an issue (which I did not completly understand) I had with releasing the button. Frankly, by now the script has so many cases to take into account that I will probably stick with my patched version of Winroll.
Any further suggestions for improvments and simplifications are welcome anyway.
Bernd
; ---------------------------------------------------------------------
; Name: TitleBack v0.3
; Author: Bernd Schandl
; Date: 05.05.2005
;
; Explanation:
; ---------------------------------------------------------------------
; When the title bar of a window is clicked with the right
; mouse button, the window is sent to the background.
; get height of title bar (4 is SM_CYCAPTION)
SysGet, TB_TitleBarHeight, 4
RButton::
; get mouse coordinates relative to the screen for this hotkey
CoordMode, Mouse, Screen
; get mouse position relative to the screen
MouseGetPos, TB_X1, TB_Y1
Loop
{
; give time to others
Sleep, 20
; get state of right mouse button
GetKeyState, TB_State, RButton, P
; get new position of the cursor and the window underneath
MouseGetPos, TB_X2, TB_Y2, TB_ID
; check whether mouse has moved
TB_HasMoved := TB_X1 <> TB_X2 or TB_Y1 <> TB_Y2
if ( TB_State = "D" && not TB_HasMoved )
; keep waiting for change
continue
if ( TB_State = "D" && TB_HasMoved )
{
; right drag
TB_Dragging := true
HotKey, Rbutton, off
MouseClick, Right, TB_X1, TB_Y1,, 0, D
Break
}
if ( TB_State = "U" && not TB_HasMoved )
{
; right click
; get the class of the window under the cursor
WinGetClass, TB_Class, ahk_id %TB_ID%
; stop if in task bar or on desktop
if ( TB_Class = "Shell_TrayWnd" or TB_Class = "Progman" )
{
MouseClick, Right, TB_X1, TB_Y1,, 0
Break
}
; get the position of the window under the cursor
WinGetPos,, TB_WinY,,, ahk_id %TB_ID%
; calculate TB_Y1 relative to window
TB_Y1 -= %TB_WinY%
; to background if in title bar
if TB_Y1 <= %TB_TitleBarHeight%
WinSet, Bottom,, ahk_id %TB_ID%
else
MouseClick, Right, TB_X1, TB_Y1,, 0
Break
}
if ( TB_State = "U" && TB_HasMoved )
{
; click and move
MouseClick, Right, TB_X1, TB_Y1,, 0
Break
}
}
Return
RButton Up::
if TB_Dragging
{
; turn off dragging
TB_Dragging := false
; re-enable hotkey
HotKey, RButton, on
; release the key
MouseClick, Right,,,, 0, U
}
return