Klar, mach ich doch gern. Leider kann ich den Beitrag oben nicht editieren, deswegen stell ichs hier noch mal in voller Pracht zum rauskopieren hin. Habe gleich mal noch etwas reduntanten Code entfernt.
Dresden-Pillnitz
~
Sure, no problem. Unfortunately I can not edit the first post, so I'll paste the whole thing once again. Also I removed some reduntant code.
Code:
; Smart Window Management Script
;
; Erlaubt es, Fenster auf komfortable Weise zu bewegen, zu vergroessern /
; verkleinern, zu minimieren und zu schliessen. Das Skript basiert auf dem
; Easy Window Dragging Script im Showcase
; (http://www.autohotkey.com/docs/scripts/EasyWindowDrag.htm).
; Definierte Tastenkombinationen siehe unten.
; ~
; Allows window moving, resizing, minimizing and closing in a very comfortable
; manner. This script is based on the Easy Window Dragging Script in the
; Showcase (Link above).
;
; Author : Johannes Loehnert
; Contact : a.u.r.e.l.i.a.n@gmx.net
; Last Change: 2005-01-25
; AHK version: 1.0.25
;
; Folgende Tastenkombinationen werden definiert:
; The script establishes the following combinations:
;
; - LWin + LB: Hold and drag to move window / Halten und ziehen, um Fenster zu verschieben
; - TB + LB: same / gleich
; - Lwin + RB: Hold and drag to resize window (resize corner which is closest to cursor) /
; Halten und ziehen, um Groesse zu aendern.
; - TB + RB: same / gleich
; - LCtrl + LWin + LB: Minimize window / Fenster minimieren
; - LCtr + LWin + RB: Close Window / Fenster schliessen
; - TB + MB: click to minimize window, hold for 0.5 sec to close window /
; nur klicken, um Fenster zu minimieren; 0.5 sec halten, um Fenster zu schliessen.
;
; All commands apply to the window under the mouse cursor.
; Abbreviations: LB, MB, RB, TB = left, middle, right, thumb button of mouse.
;
; Alle Kombinationen wirken auf das Fenster, in welchem die Maus sich befindet.
; Abkuerzungen: LB, MB, RB, TB: linke, mittlere, rechte, Daumen-Taste der Maus.
; pass through single clicks of thumb button
~XButton2::
return
;Minimize Window; when held over 0.5 sec: close window
XButton2 & MButton::
CoordMode, Mouse
MouseGetPos, SWM_MouseStartX, SWM_MouseStartY, SWM_MouseWin
SetTimer, SMW_MidButtonClose, 500 ;<-- TIMER FOR TB+MB CLOSE
SMW_MidButtonCloseTimer=1
loop
{
GetKeyState, SMW_MButtonState, MButton, P
if SMW_MidButtonCloseTimer=0
return
if SMW_MButtonState=U
{
SetTimer, SMW_MidButtonClose, Off
WinMinimize, ahk_id %SWM_MouseWin%
SMW_MidButtonCloseTimer=0
return
}
}
SMW_MidButtonClose:
SMW_MidButtonCloseTimer=0
SetTimer, SMW_MidButtonClose, Off
WinClose, ahk_id %SWM_MouseWin%
return
; Move window on Lwin+LB or TB+LB; minimize window on LCtrl+Lwin+LB or LCtrl+TB+LB
XButton2 & LButton::
LWin & LBUtton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, SWM_MouseStartX, SWM_MouseStartY, SWM_MouseWin
GetKeyState, SMW_LCtrlState, LCtrl
if SMW_LCtrlState=D
WinMinimize, ahk_id %SWM_MouseWin%
else
SetTimer, SWM_WatchMouse_Move, 10 ; Track the mouse as the user drags it.
return
; resize window on Lwin+RB or TB+RB; minimize window on LCtrl+Lwin+RB or LCtrl+TB+RB
XButton2 & RButton:: ;resize or close
LWin & RButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, SWM_MouseStartX, SWM_MouseStartY, SWM_MouseWin
WinGetPos, SWM_WinX, SWM_WinY, SWM_WinW, SWM_WinH, ahk_id %SWM_MouseWin%
GetKeyState, SMW_LCtrlState, LCtrl
if SMW_LCtrlState=D
{
WinClose, ahk_id %SWM_MouseWin%
return
}
SWM_ResizeTypeX=0
SWM_ResizeTypeY=0
if (SWM_MouseStartX < SWM_WinX+SWM_WinW/2)
SWM_ResizeTypeX=1
if (SWM_MouseStartY < SWM_WinY+SWM_WinH/2)
SWM_ResizeTypeY=1
SetTimer, SWM_WatchMouse_Resize, 10 ; Track the mouse as the user drags it.
return
SWM_WatchMouse_Move:
GetKeyState, SMW_LButtonState, LButton, P
if SMW_LButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, SWM_WatchMouse_Move, off
return
}
Gosub SWM_GetMouseAndWindowPos
SWM_WinX += %SWM_DeltaX%
SWM_WinY += %SWM_DeltaY%
SetWinDelay, -1 ; Makes the below move faster/smoother.
WinMove, ahk_id %SWM_MouseWin%,, %SWM_WinX%, %SWM_WinY%
return
SWM_WatchMouse_Resize:
GetKeyState, SMW_RButtonState, RButton, P
if SMW_RButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, SWM_WatchMouse_Resize, off
return
}
Gosub SWM_GetMouseAndWindowPos
if SWM_ResizeTypeX
{
SWM_WinX += %SWM_DeltaX%
SWM_WinW -= %SWM_DeltaX%
}
else
SWM_WinW += %SWM_DeltaX%
if SWM_ResizeTypeY
{
SWM_WinY += %SWM_DeltaY%
SWM_WinH -= %SWM_DeltaY%
}
else
SWM_WinH += %SWM_DeltaY%
SetWinDelay, -1 ; Makes the below move faster/smoother.
WinMove, ahk_id %SWM_MouseWin%,, %SWM_WinX%, %SWM_WinY%, %SWM_WinW%, %SWM_WinH%
return
SWM_GetMouseAndWindowPos:
CoordMode, Mouse
MouseGetPos, SWM_MouseX, SWM_MouseY
SWM_DeltaX = %SWM_MouseX%
SWM_DeltaX -= %SWM_MouseStartX%
SWM_DeltaY = %SWM_MouseY%
SWM_DeltaY -= %SWM_MouseStartY%
SWM_MouseStartX = %SWM_MouseX% ; Update for the next timer call to this subroutine.
SWM_MouseStartY = %SWM_MouseY%
WinGetPos, SWM_WinX, SWM_WinY, SWM_WinW, SWM_WinH, ahk_id %SWM_MouseWin%
return
; End of Smart Window Management Script