I discovered AHK few days ago, but I am already amazed how mighty this handy little tool is. Here is part of my Init script that I thought you might be interested in. I know such stuff has been posted before, but maybe you want to give it a try. :-)
; Smart Window Management Script ; This script is based on the Easy Window Dragging Script in the Showcase ; (http://www.autohotkey.com/docs/scripts/EasyWindowDrag.htm), ; but goes much further. Of course you are free to change the combinations to ; anything you like. ; ; Author: Johannes Loehnert ; Contact: [email protected] ; Last Change: 2005-01-25 ; AHK version: 1.0.25 ; ; The script establishes the following combinations: ; - Lwin + LB: Hold and drag to move window ; - TB + LB: same ; - Lwin + RB: Hold and drag to resize window (resize corner which is closest to cursor) ; - TB + RB: same ; - LCtrl + LWin + LB: Minimize window ; - LCtr + LWin + RB: Close Window ; - TB + MB: click to minimize window, hold for 0.5 sec to close window ; All commands apply to the window under the mouse cursor. ; Abbreviations: LB, MB, RB, TB = left, middle, right, thumb button of mouse. ; ; Flaws so far: ; - Thumb button stops working in normal way; disable TB combinations if you need. ; - Code might be prettier :-) ;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 } ; Otherwise, reposition the window to match the change in mouse coordinates ; caused by the user having dragged the mouse: 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,,, ahk_id %SWM_MouseWin% 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 } ; Otherwise, resize the window to match the change in mouse coordinates ; caused by the user having dragged the mouse: 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% 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 ; End of Smart Window Management Script
Hope somebody may find it helpful, and looking forward to feedback :-)
cu, aurelian