;NeatKeys ;Author: Sean Ockert 2008 ;A compilation of scripts - Nifty Windows functions (drag 'n resize, change opacity, right-click task switcher), Hide the titlebar, minimise windows, open the command prompt (tilde key), open drives by letter, colour picker, thought diary, html tags prefill, taskbar closer, remap backspace (like in Colemak) ;Initialise the script #SingleInstance force #HotkeyInterval 1000 #MaxHotkeysPerInterval 100 #NoTrayIcon SendMode Input #NoEnv Process, Priority, , HIGH SetBatchLines, -1 SetKeyDelay, 0, 0 SetMouseDelay, 0 SetDefaultMouseSpeed, 0 SetWinDelay, 0 SetControlDelay, 0 ;Hides the window titlebar #Space:: WinSet, Style, ^0xC00000, A ;Use Alt+Capslock to minimize Window !Capslock::WinMinimize,A ;Map Backspace to capslock Capslock::Backspace ;Map Capslock to Ctrl+Capslock ^Capslock::Capslock ;Open Drives by win-shift-drive-letter #+c::run c:\ #+d::run d:\ #+e::run e:\ #+f::run f:\ #+g::run g:\ #+h::run h:\ ;Run program commands by alt+ctrl+letter ^!f::Run "C:\Program Files\Mozilla Firefox\firefox.exe" ; Run Firefox ^!w::Run "C:\Program Files\Winamp\winamp.exe" ; Run Winamp ^!x::Run "C:\xampp\xampp_start.exe" ; Run XAMPP stack ^!m::Run "C:\Program Files\MSN Messenger\msnmsgr.exe" ; Run MSN ^!Space::Run::{450d8fba-ad25-11d0-98a8-0800361b1103} ; Open My Documents ^!h::Run "C:\xampp\htdocs" ; Open htdocs folder ;Open the command prompt by ctrl+~ ^`::Run "C:\WINDOWS\system32\cmd.exe" /k "cd c:\" ;ColourCursor ;win+C displays the hex color below the cursor #C:: Loop { Sleep,100 MouseGetPos,x,y PixelGetColor,rgb,x,y,RGB StringTrimLeft,rgb,rgb,2 ToolTip,%rgb% GetKeyState, state, esc if state = D break } ToolTip return ; Don't need the middle mouse button to be binded - causes problems with opening/closing Firefox tabs /** * CFG_MiddleMouseButtonHookStr = Off * Hotkey, #MButton, %CFG_MiddleMouseButtonHookStr% * Hotkey, #^MButton, %CFG_MiddleMouseButtonHookStr% * Hotkey, $MButton, %CFG_MiddleMouseButtonHookStr% * Hotkey, $^MButton, %CFG_MiddleMouseButtonHookStr% */ ; Bind closing a program in the taskbar to middle click MButton:: SetBatchLines, -1 CoordMode, Mouse, Screen SetMouseDelay, -1 ; no pause after mouse clicks SetKeyDelay, -1 ; no pause after keys sent MouseGetPos, ClickX, ClickY, WindowUnderMouseID WinActivate, ahk_id %WindowUnderMouseID% ; Close taskbar program click IfWinActive, ahk_class Shell_TrayWnd { MouseClick, Right, %ClickX%, %ClickY% Sleep, 50 Send, c WinWaitNotActive, ahk_class Shell_TrayWnd,, 0.5 ; wait for save dialog, etc If ErrorLevel =1 Send, !{Tab} Return } ; else send normal middle click If GetKeyState("MButton", "P") ; The middle button is physically down MouseClick, Middle, %ClickX%, %ClickY%,, Down Else MouseClick, Middle, %ClickX%, %ClickY% Return ;Add auto-insert html tags when writing eg. press p + enter gives you

#Hotstring r EndChars `n :oc:href::{Left}{Left}{Left}{Left} :oc:ul::{Up} :oc:ol::
    {Enter}{Enter}
{Up} :oc:li::
  • {Left}{Left}{Left}{Left}{Left} :oc:co::{Left}{Left}{Left}{Left}{Left}{Left}{Left} :oc:p::

    {Left}{Left}{Left}{Left} :oc:bk::
    ^v
    :oc:img:: :oc:str::{Left}{Left}{Left}{Left}{Left}{Left}{Left}{Left}{Left} :oc:em::{Left}{Left}{Left}{Left}{Left} :oc:h1::

    {Left}{Left}{Left}{Left}{Left} :oc:h2::

    {Left}{Left}{Left}{Left}{Left} :oc:h3::

    {Left}{Left}{Left}{Left}{Left} :oc:h4::

    {Left}{Left}{Left}{Left}{Left} :oc:html::{Enter}{Enter}{Up} :oc:head::{Enter}{Enter}{Up} :oc:body::{Enter}{Enter}{Up} :oc:br::
    :oc:mail::{Left}{Left}{Left}{Left} :oc:div::
    {Left}{Left}{Left}{Left}{Left}{Left} :oc:cmt::<{!}-- -->{Left}{Left}{Left}{Left} :oc:hr::
    ; tables :oc:tab::{Enter}{Enter}
    {Up} :oc:tr::{Enter}{Enter}{Up} :oc:td::{Left}{Left}{Left}{Left}{Left} :oc:skel::{Enter}{Enter}{Enter}{Enter}{Enter}{Enter}{Enter} ;A diary for recording random thoughts and links. Saves a text file to C:/Diary.txt with the date and time ^!A:: ; Show the Input Box to the user. inputbox, text, Diary,,,300,100 if ErrorLevel = 0 UpdateDiary(text) return UpdateDiary(text) { ; Format the time-stamp. current=%A_DD%/%A_MM%/%A_YYYY%, %A_Hour%:%A_Min% ; Write this data to the diary.txt file. fileappend, %current% - %text%`n, C:/Diary.txt return } ;[NWD] nifty window dragging /** * This is the most powerful feature of NiftyWindows. The area of every window * is tiled in a virtual 9-cell grid with three columns and rows. The center * cell is the largest one and you can grab and move a window around by clicking * and holding it with the right mouse button. The other eight corner cells are * used to resize a resizable window in the same manner. */ $RButton:: $+RButton:: $+!RButton:: $+^RButton:: $+#RButton:: $+!^RButton:: $+!#RButton:: $+^#RButton:: $+!^#RButton:: $!RButton:: $!^RButton:: $!#RButton:: $!^#RButton:: $^RButton:: $^#RButton:: $#RButton:: NWD_ResizeGrids = 5 CoordMode, Mouse, Screen MouseGetPos, NWD_MouseStartX, NWD_MouseStartY, NWD_WinID If ( !NWD_WinID ) Return WinGetPos, NWD_WinStartX, NWD_WinStartY, NWD_WinStartW, NWD_WinStartH, ahk_id %NWD_WinID% WinGet, NWD_WinMinMax, MinMax, ahk_id %NWD_WinID% WinGet, NWD_WinStyle, Style, ahk_id %NWD_WinID% WinGetClass, NWD_WinClass, ahk_id %NWD_WinID% GetKeyState, NWD_CtrlState, Ctrl, P ; the and'ed condition checks for popup window: ; (WS_POPUP) and !(WS_DLGFRAME | WS_SYSMENU | WS_THICKFRAME) If ( (NWD_WinClass = "Progman") or ((NWD_CtrlState = "U") and (((NWD_WinStyle & 0x80000000) and !(NWD_WinStyle & 0x4C0000)) or (NWD_WinClass = "ExploreWClass") or (NWD_WinClass = "CabinetWClass") or (NWD_WinClass = "IEFrame") or (NWD_WinClass = "MozillaWindowClass") or (NWD_WinClass = "OpWindow") or (NWD_WinClass = "ATL:ExplorerFrame") or (NWD_WinClass = "ATL:ScrapFrame"))) ) { NWD_ImmediateDownRequest = 1 NWD_ImmediateDown = 0 NWD_PermitClick = 1 } Else { NWD_ImmediateDownRequest = 0 NWD_ImmediateDown = 0 NWD_PermitClick = 1 } NWD_Dragging := (NWD_WinClass != "Progman") and ((NWD_CtrlState = "D") or ((NWD_WinMinMax != 1) and !NWD_ImmediateDownRequest)) ; checks wheter the window has a sizing border (WS_THICKFRAME) If ( (NWD_CtrlState = "D") or (NWD_WinStyle & 0x40000) ) { If ( (NWD_MouseStartX >= NWD_WinStartX + NWD_WinStartW / NWD_ResizeGrids) and (NWD_MouseStartX <= NWD_WinStartX + (NWD_ResizeGrids - 1) * NWD_WinStartW / NWD_ResizeGrids) ) NWD_ResizeX = 0 Else If ( NWD_MouseStartX > NWD_WinStartX + NWD_WinStartW / 2 ) NWD_ResizeX := 1 Else NWD_ResizeX := -1 If ( (NWD_MouseStartY >= NWD_WinStartY + NWD_WinStartH / NWD_ResizeGrids) and (NWD_MouseStartY <= NWD_WinStartY + (NWD_ResizeGrids - 1) * NWD_WinStartH / NWD_ResizeGrids) ) NWD_ResizeY = 0 Else If ( NWD_MouseStartY > NWD_WinStartY + NWD_WinStartH / 2 ) NWD_ResizeY := 1 Else NWD_ResizeY := -1 } Else { NWD_ResizeX = 0 NWD_ResizeY = 0 } If ( NWD_WinStartW and NWD_WinStartH ) NWD_WinStartAR := NWD_WinStartW / NWD_WinStartH Else NWD_WinStartAR = 0 ; TODO : this is a workaround (checks for popup window) for the activation ; bug of AutoHotkey -> can be removed as soon as the known bug is fixed If ( !((NWD_WinStyle & 0x80000000) and !(NWD_WinStyle & 0x4C0000)) ) IfWinNotActive, ahk_id %NWD_WinID% WinActivate, ahk_id %NWD_WinID% ; TODO : the hotkeys must be enabled in the 2nd block because the 1st block ; activates them only for the first call (historical problem of AutoHotkey) Hotkey, Shift, NWD_IgnoreKeyHandler Hotkey, Ctrl, NWD_IgnoreKeyHandler Hotkey, Alt, NWD_IgnoreKeyHandler Hotkey, LWin, NWD_IgnoreKeyHandler Hotkey, RWin, NWD_IgnoreKeyHandler Hotkey, Shift, On Hotkey, Ctrl, On Hotkey, Alt, On Hotkey, LWin, On Hotkey, RWin, On SetTimer, NWD_IgnoreKeyHandler, 100 SetTimer, NWD_WindowHandler, 10 Return NWD_SetDraggingOff: NWD_Dragging = 0 Return NWD_SetClickOff: NWD_PermitClick = 0 NWD_ImmediateDownRequest = 0 Return NWD_SetAllOff: Gosub, NWD_SetDraggingOff Gosub, NWD_SetClickOff Return NWD_IgnoreKeyHandler: GetKeyState, NWD_RButtonState, RButton, P GetKeyState, NWD_ShiftState, Shift, P GetKeyState, NWD_CtrlState, Ctrl, P GetKeyState, NWD_AltState, Alt, P ; TODO : unlike the other modifiers, Win does not exist ; as a virtual key (but Ctrl, Alt and Shift do) GetKeyState, NWD_LWinState, LWin, P GetKeyState, NWD_RWinState, RWin, P If ( (NWD_LWinState = "D") or (NWD_RWinState = "D") ) NWD_WinState = D Else NWD_WinState = U If ( (NWD_RButtonState = "U") and (NWD_ShiftState = "U") and (NWD_CtrlState = "U") and (NWD_AltState = "U") and (NWD_WinState = "U") ) { SetTimer, NWD_IgnoreKeyHandler, Off Hotkey, Shift, Off Hotkey, Ctrl, Off Hotkey, Alt, Off Hotkey, LWin, Off Hotkey, RWin, Off } Return NWD_WindowHandler: SetWinDelay, -1 CoordMode, Mouse, Screen MouseGetPos, NWD_MouseX, NWD_MouseY WinGetPos, NWD_WinX, NWD_WinY, NWD_WinW, NWD_WinH, ahk_id %NWD_WinID% GetKeyState, NWD_RButtonState, RButton, P GetKeyState, NWD_ShiftState, Shift, P GetKeyState, NWD_AltState, Alt, P ; TODO : unlike the other modifiers, Win does not exist ; as a virtual key (but Ctrl, Alt and Shift do) GetKeyState, NWD_LWinState, LWin, P GetKeyState, NWD_RWinState, RWin, P If ( (NWD_LWinState = "D") or (NWD_RWinState = "D") ) NWD_WinState = D Else NWD_WinState = U If ( NWD_RButtonState = "U" ) { SetTimer, NWD_WindowHandler, Off If ( NWD_ImmediateDown ) MouseClick, RIGHT, %NWD_MouseX%, %NWD_MouseY%, , , U Else If ( NWD_PermitClick and (!NWD_Dragging or ((NWD_MouseStartX = NWD_MouseX) and (NWD_MouseStartY = NWD_MouseY))) ) { MouseClick, RIGHT, %NWD_MouseStartX%, %NWD_MouseStartY%, , , D MouseClick, RIGHT, %NWD_MouseX%, %NWD_MouseY%, , , U } Gosub, NWD_SetAllOff NWD_ImmediateDown = 0 } Else { NWD_MouseDeltaX := NWD_MouseX - NWD_MouseStartX NWD_MouseDeltaY := NWD_MouseY - NWD_MouseStartY If ( NWD_MouseDeltaX or NWD_MouseDeltaY ) { If ( NWD_ImmediateDownRequest and !NWD_ImmediateDown ) { MouseClick, RIGHT, %NWD_MouseStartX%, %NWD_MouseStartY%, , , D MouseMove, %NWD_MouseX%, %NWD_MouseY% NWD_ImmediateDown = 1 NWD_PermitClick = 0 } If ( NWD_Dragging ) { If ( !NWD_ResizeX and !NWD_ResizeY ) { NWD_WinNewX := NWD_WinStartX + NWD_MouseDeltaX NWD_WinNewY := NWD_WinStartY + NWD_MouseDeltaY NWD_WinNewW := NWD_WinStartW NWD_WinNewH := NWD_WinStartH } Else { NWD_WinDeltaW = 0 NWD_WinDeltaH = 0 If ( NWD_ResizeX ) NWD_WinDeltaW := NWD_ResizeX * NWD_MouseDeltaX If ( NWD_ResizeY ) NWD_WinDeltaH := NWD_ResizeY * NWD_MouseDeltaY If ( NWD_WinState = "D" ) { If ( NWD_ResizeX ) NWD_WinDeltaW *= 2 If ( NWD_ResizeY ) NWD_WinDeltaH *= 2 } NWD_WinNewW := NWD_WinStartW + NWD_WinDeltaW NWD_WinNewH := NWD_WinStartH + NWD_WinDeltaH If ( NWD_WinNewW < 0 ) If ( NWD_WinState = "D" ) NWD_WinNewW *= -1 Else NWD_WinNewW := 0 If ( NWD_WinNewH < 0 ) If ( NWD_WinState = "D" ) NWD_WinNewH *= -1 Else NWD_WinNewH := 0 If ( (NWD_AltState = "D") and NWD_WinStartAR ) { NWD_WinNewARW := NWD_WinNewH * NWD_WinStartAR NWD_WinNewARH := NWD_WinNewW / NWD_WinStartAR If ( NWD_WinNewW < NWD_WinNewARW ) NWD_WinNewW := NWD_WinNewARW If ( NWD_WinNewH < NWD_WinNewARH ) NWD_WinNewH := NWD_WinNewARH } NWD_WinDeltaX = 0 NWD_WinDeltaY = 0 If ( NWD_WinState = "D" ) { NWD_WinDeltaX := NWD_WinStartW / 2 - NWD_WinNewW / 2 NWD_WinDeltaY := NWD_WinStartH / 2 - NWD_WinNewH / 2 } Else { If ( NWD_ResizeX = -1 ) NWD_WinDeltaX := NWD_WinStartW - NWD_WinNewW If ( NWD_ResizeY = -1 ) NWD_WinDeltaY := NWD_WinStartH - NWD_WinNewH } NWD_WinNewX := NWD_WinStartX + NWD_WinDeltaX NWD_WinNewY := NWD_WinStartY + NWD_WinDeltaY } If ( NWD_ShiftState = "D" ) NWD_WinNewRound = -1 Else NWD_WinNewRound = 0 Transform, NWD_WinNewX, Round, %NWD_WinNewX%, %NWD_WinNewRound% Transform, NWD_WinNewY, Round, %NWD_WinNewY%, %NWD_WinNewRound% Transform, NWD_WinNewW, Round, %NWD_WinNewW%, %NWD_WinNewRound% Transform, NWD_WinNewH, Round, %NWD_WinNewH%, %NWD_WinNewRound% If ( (NWD_WinNewX != NWD_WinX) or (NWD_WinNewY != NWD_WinY) or (NWD_WinNewW != NWD_WinW) or (NWD_WinNewH != NWD_WinH) ) { WinMove, ahk_id %NWD_WinID%, , %NWD_WinNewX%, %NWD_WinNewY%, %NWD_WinNewW%, %NWD_WinNewH% } } } } Return ; [MIW {NWD}] minimize/roll on right + left mouse button /** * Minimizes the selected window (if minimizable) to the task bar. If you press * the left button over the titlebar the selected window will be rolled up * instead of being minimized. You have to apply this action again to roll the * window back down. */ $LButton:: $^LButton:: GetKeyState, MIW_RButtonState, RButton, P If ( (MIW_RButtonState = "D") and (!NWD_ImmediateDown) and (NWD_WinClass != "Progman") ) { GetKeyState, MIW_CtrlState, Ctrl, P WinGet, MIW_WinStyle, Style, ahk_id %NWD_WinID% SysGet, MIW_CaptionHeight, 4 ; SM_CYCAPTION SysGet, MIW_BorderHeight, 7 ; SM_CXDLGFRAME MouseGetPos, , MIW_MouseY If ( MIW_MouseY <= MIW_CaptionHeight + MIW_BorderHeight ) { ; checks wheter the window has a sizing border (WS_THICKFRAME) If ( (MIW_CtrlState = "D") or (MIW_WinStyle & 0x40000) ) { Gosub, NWD_SetAllOff ROL_WinID = %NWD_WinID% Gosub, ROL_RollToggle } } Else { ; the second condition checks for minimizable window: ; (WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX) If ( (MIW_CtrlState = "D") or (MIW_WinStyle & 0xCA0000 = 0xCA0000) ) { Gosub, NWD_SetAllOff WinMinimize, ahk_id %NWD_WinID% } } } Else { ; this feature should be implemented by using a timer because ; AutoHotkeys threading blocks the first thread if another ; one is started (until the 2nd is stopped) Thread, priority, 1 MouseClick, LEFT, , , , , D KeyWait, LButton MouseClick, LEFT, , , , , U } Return ; [TSM {NWD}] toggles windows start menu || moves window to previous display || maximize to multiple windows on the left /** * This additional button is used to toggle the windows start menu. */ $XButton1:: $^XButton1:: If ( NWD_ImmediateDown ) Return GetKeyState, TSM_RButtonState, RButton, P If ( TSM_RButtonState = "U" ) { Send, {LWin} } Else IfWinActive, A { WinGet, TSM_WinID, ID If ( !TSM_WinID ) Return WinGetClass, TSM_WinClass, ahk_id %TSM_WinID% If ( TSM_WinClass != "Progman" ) { Gosub, NWD_SetAllOff GetKeyState, TSM_CtrlState, Ctrl, P If ( TSM_CtrlState = "U" ) { Send, ^< } ; Else ; TODO : maximize to multiple displays on the left (planned feature) } } Return ; [MAW {NWD}] toggles window maximizing || moves window to next display || maximize to multiple windows on the right /** * This additional button is used to toggle the maximize state of the active * window (if maximizable). */ $XButton2:: $^XButton2:: If ( NWD_ImmediateDown ) Return IfWinActive, A { WinGet, MAW_WinID, ID If ( !MAW_WinID ) Return WinGetClass, MAW_WinClass, ahk_id %MAW_WinID% If ( MAW_WinClass = "Progman" ) Return GetKeyState, MAW_RButtonState, RButton, P If ( MAW_RButtonState = "U" ) { GetKeyState, MAW_CtrlState, Ctrl, P WinGet, MAW_WinStyle, Style ; the second condition checks for maximizable window: ; (WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX) If ( (MAW_CtrlState = "D") or (MAW_WinStyle & 0xC90000 = 0xC90000) ) { WinGet, MAW_MinMax, MinMax If ( MAW_MinMax = 0 ) { WinMaximize } Else If ( MAW_MinMax = 1 ) { WinRestore } } } Else { Gosub, NWD_SetAllOff GetKeyState, MAW_CtrlState, Ctrl, P If ( MAW_CtrlState = "U" ) { Send, ^> } ; Else ; TODO : maximize to multiple displays on the right (planned feature) } } Return ; [TSW {NWD}] provides alt-tab-menu to the right mouse button + mouse wheel /** * Provides a quick task switcher (alt-tab-menu) controlled by the mouse wheel. */ WheelDown:: GetKeyState, TSW_RButtonState, RButton, P If ( (TSW_RButtonState = "D") and (!NWD_ImmediateDown) ) { ; TODO : this is a workaround because the original tabmenu ; code of AutoHotkey is buggy on some systems GetKeyState, TSW_LAltState, LAlt If ( TSW_LAltState = "U" ) { Gosub, NWD_SetAllOff Send, {LAlt down}{Tab} SetTimer, TSW_WheelHandler, 1 } Else Send, {Tab} } Else Send, {WheelDown} Return WheelUp:: GetKeyState, TSW_RButtonState, RButton, P If ( (TSW_RButtonState = "D") and (!NWD_ImmediateDown) ) { ; TODO : this is a workaround because the original tabmenu ; code of AutoHotkey is buggy on some systems GetKeyState, TSW_LAltState, LAlt If ( TSW_LAltState = "U" ) { Gosub, NWD_SetAllOff Send, {LAlt down}+{Tab} SetTimer, TSW_WheelHandler, 1 } Else Send, +{Tab} } Else Send, {WheelUp} Return TSW_WheelHandler: GetKeyState, TSW_RButtonState, RButton, P If ( TSW_RButtonState = "U" ) { SetTimer, TSW_WheelHandler, Off GetKeyState, TSW_LAltState, LAlt If ( TSW_LAltState = "D" ) Send, {LAlt up} } Return AOT_SetOn: Gosub, AOT_CheckWinIDs SetWinDelay, -1 IfWinNotExist, ahk_id %AOT_WinID% Return IfNotInString, AOT_WinIDs, |%AOT_WinID% AOT_WinIDs = %AOT_WinIDs%|%AOT_WinID% WinSet, AlwaysOnTop, On, ahk_id %AOT_WinID% Return AOT_SetOff: Gosub, AOT_CheckWinIDs SetWinDelay, -1 IfWinNotExist, ahk_id %AOT_WinID% Return StringReplace, AOT_WinIDs, AOT_WinIDs, |%A_LoopField%, , All WinSet, AlwaysOnTop, Off, ahk_id %AOT_WinID% Return AOT_SetAllOff: Gosub, AOT_CheckWinIDs Loop, Parse, AOT_WinIDs, | If ( A_LoopField ) { AOT_WinID = %A_LoopField% Gosub, AOT_SetOff } Return #^SC029:: Gosub, AOT_SetAllOff Return AOT_CheckWinIDs: DetectHiddenWindows, On Loop, Parse, AOT_WinIDs, | If ( A_LoopField ) IfWinNotExist, ahk_id %A_LoopField% StringReplace, AOT_WinIDs, AOT_WinIDs, |%A_LoopField%, , All Return AOT_ExitHandler: Gosub, AOT_SetAllOff Return ; [ROL] rolls up/down a window to/from its title bar ROL_RollToggle: Gosub, ROL_CheckWinIDs SetWinDelay, -1 IfWinNotExist, ahk_id %ROL_WinID% Return WinGetClass, ROL_WinClass, ahk_id %ROL_WinID% If ( ROL_WinClass = "Progman" ) Return IfNotInString, ROL_WinIDs, |%ROL_WinID% { Gosub, ROL_RollUp } Else { WinGetPos, , , , ROL_WinHeight, ahk_id %ROL_WinID% If ( ROL_WinHeight = ROL_WinRolledHeight%ROL_WinID% ) { Gosub, ROL_RollDown } Else { Gosub, ROL_RollUp } } Return ROL_RollUp: Gosub, ROL_CheckWinIDs SetWinDelay, -1 IfWinNotExist, ahk_id %ROL_WinID% Return WinGetClass, ROL_WinClass, ahk_id %ROL_WinID% If ( ROL_WinClass = "Progman" ) Return WinGetPos, , , , ROL_WinHeight, ahk_id %ROL_WinID% IfInString, ROL_WinIDs, |%ROL_WinID% If ( ROL_WinHeight = ROL_WinRolledHeight%ROL_WinID% ) Return SysGet, ROL_CaptionHeight, 4 ; SM_CYCAPTION SysGet, ROL_BorderHeight, 7 ; SM_CXDLGFRAME If ( ROL_WinHeight > (ROL_CaptionHeight + ROL_BorderHeight) ) { IfNotInString, ROL_WinIDs, |%ROL_WinID% ROL_WinIDs = %ROL_WinIDs%|%ROL_WinID% ROL_WinOriginalHeight%ROL_WinID% := ROL_WinHeight WinMove, ahk_id %ROL_WinID%, , , , , (ROL_CaptionHeight + ROL_BorderHeight) WinGetPos, , , , ROL_WinRolledHeight%ROL_WinID%, ahk_id %ROL_WinID% } Return ROL_RollDown: Gosub, ROL_CheckWinIDs SetWinDelay, -1 If ( !ROL_WinID ) Return IfNotInString, ROL_WinIDs, |%ROL_WinID% Return WinGetPos, , , , ROL_WinHeight, ahk_id %ROL_WinID% If( ROL_WinHeight = ROL_WinRolledHeight%ROL_WinID% ) WinMove, ahk_id %ROL_WinID%, , , , , ROL_WinOriginalHeight%ROL_WinID% StringReplace, ROL_WinIDs, ROL_WinIDs, |%ROL_WinID%, , All ROL_WinOriginalHeight%ROL_WinID% = ROL_WinRolledHeight%ROL_WinID% = Return ROL_RollDownAll: Gosub, ROL_CheckWinIDs Loop, Parse, ROL_WinIDs, | If ( A_LoopField ) { ROL_WinID = %A_LoopField% Gosub, ROL_RollDown } Return #^r:: Gosub, ROL_RollDownAll Return ROL_CheckWinIDs: DetectHiddenWindows, On Loop, Parse, ROL_WinIDs, | If ( A_LoopField ) IfWinNotExist, ahk_id %A_LoopField% { StringReplace, ROL_WinIDs, ROL_WinIDs, |%A_LoopField%, , All ROL_WinOriginalHeight%A_LoopField% = ROL_WinRolledHeight%A_LoopField% = } Return ROL_ExitHandler: Gosub, ROL_RollDownAll Return ; [TRA] provides window transparency /** * Adjusts the transparency of the active window in ten percent steps * (opaque = 100%) which allows the contents of the windows behind it to shine * through. If the window is completely transparent (0%) the window is still * there and clickable. If you loose a transparent window it will be extremly * complicated to find it again because it's invisible (see the first hotkey * in this list for emergency help in such situations). */ #WheelUp:: #+WheelUp:: #WheelDown:: #+WheelDown:: Gosub, TRA_CheckWinIDs SetWinDelay, -1 IfWinActive, A { WinGet, TRA_WinID, ID If ( !TRA_WinID ) Return WinGetClass, TRA_WinClass, ahk_id %TRA_WinID% If ( TRA_WinClass = "Progman" ) Return IfNotInString, TRA_WinIDs, |%TRA_WinID% TRA_WinIDs = %TRA_WinIDs%|%TRA_WinID% TRA_WinAlpha := TRA_WinAlpha%TRA_WinID% TRA_PixelColor := TRA_PixelColor%TRA_WinID% IfInString, A_ThisHotkey, + TRA_WinAlphaStep := 255 * 0.01 ; 1 percent steps Else TRA_WinAlphaStep := 255 * 0.1 ; 10 percent steps If ( TRA_WinAlpha = "" ) TRA_WinAlpha = 255 IfInString, A_ThisHotkey, WheelDown TRA_WinAlpha -= TRA_WinAlphaStep Else TRA_WinAlpha += TRA_WinAlphaStep If ( TRA_WinAlpha > 255 ) TRA_WinAlpha = 255 Else If ( TRA_WinAlpha < 0 ) TRA_WinAlpha = 0 If ( !TRA_PixelColor and (TRA_WinAlpha = 255) ) { Gosub, TRA_TransparencyOff } Else { TRA_WinAlpha%TRA_WinID% = %TRA_WinAlpha% If ( TRA_PixelColor ) WinSet, TransColor, %TRA_PixelColor% %TRA_WinAlpha%, ahk_id %TRA_WinID% Else WinSet, Transparent, %TRA_WinAlpha%, ahk_id %TRA_WinID% } } Return TRA_TransparencyOff: Gosub, TRA_CheckWinIDs SetWinDelay, -1 If ( !TRA_WinID ) Return IfNotInString, TRA_WinIDs, |%TRA_WinID% Return StringReplace, TRA_WinIDs, TRA_WinIDs, |%TRA_WinID%, , All TRA_WinAlpha%TRA_WinID% = TRA_PixelColor%TRA_WinID% = ; TODO : must be set to 255 first to avoid the black-colored-window problem WinSet, Transparent, 255, ahk_id %TRA_WinID% WinSet, TransColor, OFF, ahk_id %TRA_WinID% WinSet, Transparent, OFF, ahk_id %TRA_WinID% WinSet, Redraw, , ahk_id %TRA_WinID% Return TRA_TransparencyAllOff: Gosub, TRA_CheckWinIDs Loop, Parse, TRA_WinIDs, | If ( A_LoopField ) { TRA_WinID = %A_LoopField% Gosub, TRA_TransparencyOff } Return #^t:: Gosub, TRA_TransparencyAllOff Return TRA_CheckWinIDs: DetectHiddenWindows, On Loop, Parse, TRA_WinIDs, | If ( A_LoopField ) IfWinNotExist, ahk_id %A_LoopField% { StringReplace, TRA_WinIDs, TRA_WinIDs, |%A_LoopField%, , All TRA_WinAlpha%A_LoopField% = TRA_PixelColor%A_LoopField% = } Return TRA_ExitHandler: Gosub, TRA_TransparencyAllOff Return ; [SIZ {NWD}] provides several size adjustments to windows /** * Adjusts the transparency of the active window in ten percent steps * (opaque = 100%) which allows the contents of the windows behind it to shine * through. If the window is completely transparent (0%) the window is still * there and clickable. If you loose a transparent window it will be extremly * complicated to find it again because it's invisible (see the first hotkey in * this list for emergency help in such situations). */ !WheelUp:: !+WheelUp:: !^WheelUp:: !#WheelUp:: !+^WheelUp:: !+#WheelUp:: !^#WheelUp:: !+^#WheelUp:: !WheelDown:: !+WheelDown:: !^WheelDown:: !#WheelDown:: !+^WheelDown:: !+#WheelDown:: !^#WheelDown:: !+^#WheelDown:: ; TODO : the following code block is a workaround to handle ; virtual ALT calls in WheelDown/Up functions GetKeyState, SIZ_AltState, Alt, P If ( SIZ_AltState = "U" ) { IfInString, A_ThisHotkey, WheelDown Gosub, WheelDown Else Gosub, WheelUp Return } If ( NWD_Dragging or NWD_ImmediateDown ) Return SetWinDelay, -1 CoordMode, Mouse, Screen IfWinActive, A { WinGet, SIZ_WinID, ID If ( !SIZ_WinID ) Return WinGetClass, SIZ_WinClass, ahk_id %SIZ_WinID% If ( SIZ_WinClass = "Progman" ) Return GetKeyState, SIZ_CtrlState, Ctrl, P WinGet, SIZ_WinMinMax, MinMax, ahk_id %SIZ_WinID% WinGet, SIZ_WinStyle, Style, ahk_id %SIZ_WinID% ; checks wheter the window isn't maximized and has a sizing border (WS_THICKFRAME) If ( (SIZ_CtrlState = "D") or ((SIZ_WinMinMax != 1) and (SIZ_WinStyle & 0x40000)) ) { WinGetPos, SIZ_WinX, SIZ_WinY, SIZ_WinW, SIZ_WinH, ahk_id %SIZ_WinID% If ( SIZ_WinW and SIZ_WinH ) { SIZ_AspectRatio := SIZ_WinW / SIZ_WinH IfInString, A_ThisHotkey, WheelDown SIZ_Direction = 1 Else SIZ_Direction = -1 IfInString, A_ThisHotkey, + SIZ_Factor = 0.01 Else SIZ_Factor = 0.1 SIZ_WinNewW := SIZ_WinW + SIZ_Direction * SIZ_WinW * SIZ_Factor SIZ_WinNewH := SIZ_WinH + SIZ_Direction * SIZ_WinH * SIZ_Factor IfInString, A_ThisHotkey, # { SIZ_WinNewX := SIZ_WinX + (SIZ_WinW - SIZ_WinNewW) / 2 SIZ_WinNewY := SIZ_WinY + (SIZ_WinH - SIZ_WinNewH) / 2 } Else { SIZ_WinNewX := SIZ_WinX SIZ_WinNewY := SIZ_WinY } If ( SIZ_WinNewW > A_ScreenWidth ) { SIZ_WinNewW := A_ScreenWidth SIZ_WinNewH := SIZ_WinNewW / SIZ_AspectRatio } If ( SIZ_WinNewH > A_ScreenHeight ) { SIZ_WinNewH := A_ScreenHeight SIZ_WinNewW := SIZ_WinNewH * SIZ_AspectRatio } Transform, SIZ_WinNewX, Round, %SIZ_WinNewX% Transform, SIZ_WinNewY, Round, %SIZ_WinNewY% Transform, SIZ_WinNewW, Round, %SIZ_WinNewW% Transform, SIZ_WinNewH, Round, %SIZ_WinNewH% WinMove, ahk_id %SIZ_WinID%, , SIZ_WinNewX, SIZ_WinNewY, SIZ_WinNewW, SIZ_WinNewH } } } Return !NumpadAdd:: !^NumpadAdd:: !#NumpadAdd:: !^#NumpadAdd:: !NumpadSub:: !^NumpadSub:: !#NumpadSub:: !^#NumpadSub:: If ( NWD_Dragging or NWD_ImmediateDown ) Return SetWinDelay, -1 CoordMode, Mouse, Screen IfWinActive, A { WinGet, SIZ_WinID, ID If ( !SIZ_WinID ) Return WinGetClass, SIZ_WinClass, ahk_id %SIZ_WinID% If ( SIZ_WinClass = "Progman" ) Return GetKeyState, SIZ_CtrlState, Ctrl, P WinGet, SIZ_WinMinMax, MinMax, ahk_id %SIZ_WinID% WinGet, SIZ_WinStyle, Style, ahk_id %SIZ_WinID% ; checks wheter the window isn't maximized and has a sizing border (WS_THICKFRAME) If ( (SIZ_CtrlState = "D") or ((SIZ_WinMinMax != 1) and (SIZ_WinStyle & 0x40000)) ) { WinGetPos, SIZ_WinX, SIZ_WinY, SIZ_WinW, SIZ_WinH, ahk_id %SIZ_WinID% IfInString, A_ThisHotkey, NumpadAdd If ( SIZ_WinW < 160 ) SIZ_WinNewW = 160 Else If ( SIZ_WinW < 320 ) SIZ_WinNewW = 320 Else If ( SIZ_WinW < 640 ) SIZ_WinNewW = 640 Else If ( SIZ_WinW < 800 ) SIZ_WinNewW = 800 Else If ( SIZ_WinW < 1024 ) SIZ_WinNewW = 1024 Else If ( SIZ_WinW < 1152 ) SIZ_WinNewW = 1152 Else If ( SIZ_WinW < 1280 ) SIZ_WinNewW = 1280 Else If ( SIZ_WinW < 1400 ) SIZ_WinNewW = 1400 Else If ( SIZ_WinW < 1600 ) SIZ_WinNewW = 1600 Else SIZ_WinNewW = 1920 Else If ( SIZ_WinW <= 320 ) SIZ_WinNewW = 160 Else If ( SIZ_WinW <= 640 ) SIZ_WinNewW = 320 Else If ( SIZ_WinW <= 800 ) SIZ_WinNewW = 640 Else If ( SIZ_WinW <= 1024 ) SIZ_WinNewW = 800 Else If ( SIZ_WinW <= 1152 ) SIZ_WinNewW = 1024 Else If ( SIZ_WinW <= 1280 ) SIZ_WinNewW = 1152 Else If ( SIZ_WinW <= 1400 ) SIZ_WinNewW = 1280 Else If ( SIZ_WinW <= 1600 ) SIZ_WinNewW = 1400 Else If ( SIZ_WinW <= 1920 ) SIZ_WinNewW = 1600 Else SIZ_WinNewW = 1920 If ( SIZ_WinNewW > A_ScreenWidth ) SIZ_WinNewW := A_ScreenWidth SIZ_WinNewH := 3 * SIZ_WinNewW / 4 If ( SIZ_WinNewW = 1280 ) SIZ_WinNewH := 1024 IfInString, A_ThisHotkey, # { SIZ_WinNewX := SIZ_WinX + (SIZ_WinW - SIZ_WinNewW) / 2 SIZ_WinNewY := SIZ_WinY + (SIZ_WinH - SIZ_WinNewH) / 2 } Else { SIZ_WinNewX := SIZ_WinX SIZ_WinNewY := SIZ_WinY } Transform, SIZ_WinNewX, Round, %SIZ_WinNewX% Transform, SIZ_WinNewY, Round, %SIZ_WinNewY% Transform, SIZ_WinNewW, Round, %SIZ_WinNewW% Transform, SIZ_WinNewH, Round, %SIZ_WinNewH% WinMove, ahk_id %SIZ_WinID%, , SIZ_WinNewX, SIZ_WinNewY, SIZ_WinNewW, SIZ_WinNewH } } Return