' wanted to share this one: dWm - dynamic window management
function
(1) "tiling window management" by positioning and sizing windows according to a specified layout selected by key stroke
(2) "virtual desktops" with the slightly different concept of tagging windows and restricting the view to windows with the same tag
download
dWm 0.3.5
known bug
If windows are resized and positioned automatically (autoResizeAndPositionWindowsFlag := true), this is triggered by shell messages (HSHELL_WINDOWCREATED and HSHELL_WINDOWDESTROYED). Sometimes this happens unexpectedly, if an application in systray pops up (in my case it seems to be the commodo firewall) or in firefox with popup blocker and an according website or with windows explorer and its child windows.
history
Most times I use linux for my "personal computer experience" and became addicted to tiling window management in form of dwm and wmii. So I wanted to have something similar when working with windows, but could not find anything usable - no shell replacement seems to do this and none of these seems to be up to date for windows vista, the only thing I found was "siaynoq" :shock: . Finally I found GridMove and with this in mind and a lot of forum search I assembled all to fit in dWm
I have listed the whole code below for direct review and forum search.
dWm.ahk
/*
title: dWm (dynamic window managment for Windows)
author: joten
version: 0.3.5
date: 27.06.2008
function: "tiling window management" by positioning and sizing windows according to a specified layout selected by key stroke
"virtual desktops" with the slightly different concept of tagging windows and restricting the view to windows with the same tag
comment: first impression of dynamic (tiling) window management: http://www.suckless.org/wiki/dwm
hints at implementing window management with AutoHotkey: http://jgpaiva.donationcoders.com/gridmove.html (no code copied)
source for virtual desktops (tagging): http://www.autohotkey.com/forum/topic6182.html (code copied, but mostly rewritten to support arrays storing the window ids)
source for array handling (AHKArray): http://www.autohotkey.com/forum/topic14881.html (olegbl)
If code was copied AutoHotkey from the forum, it has been commented at the end of the code snippet.
license: The code written by joten is licensed under the GPL (version 2) like AutoHotkey itself (see license.txt).
*/
; <init (editable in parts)>
OnExit, CleanUp ; clean up (virtual desktops) in particular in case of an error (otherwise some windows might get lost) and show the window titlebars
SetBatchLines, -1
SetWinDelay, 0
IfExist %A_ScriptDir%\images\dWm.ico
Menu, Tray, Icon, %A_ScriptDir%\images\dWm.ico
; <options (editable)>
maxViewNumber := 4
autoDisplayViewNumberFlag := true
OSDFontName := "Tahoma"
OSDFontColor := "FF8000"
OSDFontFormat = 600
OSDOpacity := 70
layoutMode = s ; m/b/s
numberOfAreas := 1 ; < 9
splitLayout = v ; v/h
splitRatio := 0.5 ; <= 1
hideTitlebarFlag := true
autoResizeAndPositionWindowsFlag := true
autoDisplayLayoutGridFlag := true
exceptions = Button,Shell_TrayWnd,WindowsForms10.Window.8.app.0.3d893c,#32770
; </options>
activeView := 1
noViewAction := true ; "autoResizeAndPositionWindows" does not work together with the tagging/view functions, because after a reload of the script and switching the view or tagging a window, HSHELL_WINDOWDESTROYED or HSHELL_WINDOWCREATED are detected and the "windows" array is rewritten, while windows are hidden or shown.
viewWindows := AHKANewArray()
windows := AHKANewArray()
Loop, %maxViewNumber%
windows := AHKAAdd(windows, viewWindows)
If hideTitlebarFlag
hideTitlebars(true)
getWorkingAreaSizeAndPosition()
resizeAndPositionWindows()
; </init>
; <main>
Gui +LastFound
hWnd := WinExist()
DllCall("RegisterShellHookWindow", UInt, hWnd)
MsgNum := DllCall("RegisterWindowMessage", Str, "SHELLHOOK")
OnMessage(MsgNum, "ShellMessage")
; Return ; End of Auto-Execute Section
; source: http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323 (SKAN)
; </main>
; <hotkeys (editable in parts)>
Loop, %maxViewNumber%
Hotkey, !%A_Index%, switchToView
Hotkey, !-, displayViewNumber ; editable
Hotkey, !0, displayOverView ; editable
Loop, 9
Hotkey, #%A_Index%, setNumberOfAreas
Hotkey, #0, setNumberOfAreas ; editable
Hotkey, #m, setLayoutMode
Hotkey, #b, setLayoutMode
Hotkey, #s, setLayoutMode
Hotkey, #v, setSplitLayout
Hotkey, #h, setSplitLayout
Hotkey, IfWinActive
Loop, %maxViewNumber%
{
Hotkey, ^!%A_Index%, setTagOfActiveWindow
Hotkey, ^+!%A_Index%, addTagToActiveWindow
}
#BS::Reload ; editable
#Esc::ExitApp ; editable
LWin & Right::AltTab ; editable
LWin & Left::ShiftAltTab ; editable
#g::displayLayoutGrid()
;<shortcuts (editable)>
#F1::Run, Firefox
;</shortcuts>
#IfWinActive
#c::closeWindow() ; editable
; </hotkeys>
; <functions>
getWindows(view) {
Global
WinGet, windowList, List,,, Program Manager
viewWindows := AHKANewArray()
Loop, %windowList% { ; write the list to an array and remove the task bar window id
id := windowList%A_Index%
WinGetClass, windowClass, ahk_id %id%
If windowClass in %exceptions%
Continue
Else
viewWindows := AHKAAdd(viewWindows, id)
}
windows := AHKASet(windows, viewWindows, view)
}
ShellMessage(wParam, lParam) {
Global
If ( hideTitlebarFlag and (wParam = 1) ) { ; HSHELL_WINDOWCREATED = 1
WinSet, Style, -0xC00000, ahk_id %lParam%,
}
If ( autoResizeAndPositionWindowsFlag and noViewAction and ( (wParam = 1) or (wParam = 2) ) ) { ; HSHELL_WINDOWCREATED = 1, HSHELL_WINDOWDESTROYED = 2
autoResizeAndPositionWindows()
}
}
autoResizeAndPositionWindows() {
Global
getWindows(activeView)
viewWindows := AHKAGet(windows, activeView)
numberOfAreas := AHKASize(viewWindows)
resizeAndPositionWindows()
}
#include functions\AHKArray.ahk
#include functions\tagging.ahk
#include functions\window_management.ahk
#include functions\OSD.ahk
; </functions>
CleanUp: ; show all windows from all desktops and the according titlebars on exit
Loop, %maxViewNumber%
showWindows(A_Index, true)
hideTitlebars(false)
ExitApp
window_management.ahk/*
title: dWm (dynamic window managment for Windows)
author: joten
version: 0.3.5
date: 27.06.2008
comment: If code was copied from the AutoHotkey forum, it has been commented at the end of the code snippet.
license: The code written by joten is licensed under the GPL (version 2) like AutoHotkey itself (see license.txt).
*/
getWorkingAreaSizeAndPosition() {
Global
getTaskbarSizeAndPosition()
SysGet, monitor, Monitor
If ( (taskbarPosition = "top") or (taskbarPosition = "bottom") ) {
workingAreaWidth := monitorRight - monitorLeft
workingAreaHeight := monitorBottom - monitorTop - taskbarHeight
workingAreaX := monitorLeft
If (taskbarPosition = "top") {
workingAreaY := monitorTop + taskbarHeight
} Else {
workingAreaY := monitorTop
}
} Else {
workingAreaWidth := monitorRight - monitorLeft - taskbarWidth
workingAreaHeight := monitorBottom - monitorTop
workingAreaY := monitorTop
If (taskbarPosition = "left") {
workingAreaX := monitorLeft + taskbarWidth
} Else {
workingAreaX := monitorLeft
}
}
}
getTaskbarSizeAndPosition() {
Global
; get dimensions and position of taskbar (specialcase autohide ?)
WinGetPos, taskbarX, taskbarY, taskbarWidth, taskbarHeight, ahk_class Shell_TrayWnd
taskbarWidth += taskbarX
taskbarHeight += taskbarY
; find out if its on top/left/bottom/right with its x,y
; x0,y0 ( width < height ) means its on top
if ( taskbarX < 10 and taskbarWidth < taskbarHeight )
taskbarPosition = left
; x0,y0 ( width >= height ) means its on left
if ( taskbarX < 10 and taskbarWidth >= taskbarHeight )
taskbarPosition = top
; x+,y0 means its on right
if ( taskbarX > 10 )
taskbarPosition = right
; x0,y+ means its on bottom
if ( taskbarY > 10 )
taskbarPosition = bottom
Return
}
; source: http://www.autohotkey.com/forum/topic8597.html (holomind)
resizeAndPositionWindows() {
Global
getSizesAndPositions()
viewWindows := AHKAGet(windows, activeView)
viewWindowsTotal := AHKASize(viewWindows)
Loop, %viewWindowsTotal%
{
id := AHKAGet(viewWindows, A_Index)
If (layoutMode = "m") {
If ( (numberOfAreas = 1) or (A_Index = 1) ) {
index := 1
} Else {
index := Mod(A_Index - 1, numberOfAreas - 1) + 1
If index = 1
index := numberOfAreas
}
} Else If (layoutMode = "b") {
If ( (numberOfAreas = 1) or (A_Index = 1) ) {
index := 1
} Else If ( (numberOfAreas = 2) or (A_index = 2) ) {
index := 2
} Else {
index := Mod(A_Index - 2, numberOfAreas - 2) + 2
If index = 2
index := numberOfAreas
}
} Else If (layoutMode = "s") {
index := Mod(A_Index, numberOfAreas)
If index = 0
index := numberOfAreas
}
x := AHKAGet(positionsX, index)
y := AHKAGet(positionsY, index)
width := AHKAGet(sizesWidth, index)
height := AHKAGet(sizesHeight, index)
WinMove, ahk_id %id%, , %x%, %y%, %width%, %height%
}
}
getSizesAndPositions() {
Global
positionsX := AHKANewArray()
positionsY := AHKANewArray()
sizesWidth := AHKANewArray()
sizesHeight := AHKANewArray()
If (layoutMode = "m") {
positionsX := AHKAAdd(positionsX, workingAreaX)
positionsY := AHKAAdd(positionsY, workingAreaY)
If (splitLayout = "v") {
sizeWidth := workingAreaWidth/(1+splitRatio)
sizesWidth :=AHKAAdd(sizesWidth, sizeWidth)
sizesHeight :=AHKAAdd(sizesHeight, workingAreaHeight)
positionX := workingAreaX+workingAreaWidth/(1+splitRatio)
positionY := workingAreaY
sizeWidth := splitRatio/(1+splitRatio)*workingAreaWidth
sizeHeight := Round(workingAreaHeight/(numberOfAreas-1))
Loop, % numberOfAreas-1
{
positionsX := AHKAAdd(positionsX, positionX)
positionsY := AHKAAdd(positionsY, positionY)
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionY += sizeHeight
}
} Else If (splitLayout = "h") {
sizesWidth :=AHKAAdd(sizesWidth, workingAreaWidth)
sizeHeight := workingAreaHeight/(1+splitRatio)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionX := workingAreaX
positionY := workingAreaY+workingAreaHeight/(1+splitRatio)
sizeWidth := Round(workingAreaWidth/(numberOfAreas-1))
sizeHeight := splitRatio/(1+splitRatio)*workingAreaHeight
Loop, % numberOfAreas-1
{
positionsX := AHKAAdd(positionsX, positionX)
positionsY := AHKAAdd(positionsY, positionY)
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionX += sizeWidth
}
}
} Else If (layoutMode = "b") {
positionsX := AHKAAdd(positionsX, workingAreaX)
positionsY := AHKAAdd(positionsY, workingAreaY)
If (splitLayout = "v") {
sizeWidth := workingAreaWidth/(1+splitRatio)
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizeHeight := workingAreaHeight/2
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionsX := AHKAAdd(positionsX, workingAreaX)
positionY := workingAreaY+sizeHeight
positionsY := AHKAAdd(positionsY, positionY)
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionX := workingAreaX+workingAreaWidth/(1+splitRatio)
positionY := workingAreaY
sizeWidth := splitRatio/(1+splitRatio)*workingAreaWidth
sizeHeight := Round(workingAreaHeight/(numberOfAreas-2))
Loop, % numberOfAreas-2
{
positionsX := AHKAAdd(positionsX, positionX)
positionsY := AHKAAdd(positionsY, positionY)
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionY += sizeHeight
}
} Else If (splitLayout = "h") {
sizeWidth := workingAreaWidth/2
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizeHeight := workingAreaHeight/(1+splitRatio)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionX := workingAreaX+sizeWidth
positionsX := AHKAAdd(positionsX, positionX)
positionsY := AHKAAdd(positionsY, workingAreaY)
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionX := workingAreaX
positionY := workingAreaY+workingAreaHeight/(1+splitRatio)
sizeWidth := Round(workingAreaWidth/(numberOfAreas-2))
sizeHeight := splitRatio/(1+splitRatio)*workingAreaHeight
Loop, % numberOfAreas-2
{
positionsX := AHKAAdd(positionsX, positionX)
positionsY := AHKAAdd(positionsY, positionY)
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionX += sizeWidth
}
}
} Else If (layoutMode = "s") {
If (splitLayout = "v") {
positionX := workingAreaX
sizeWidth := Round(workingAreaWidth/numberOfAreas)
Loop, %numberOfAreas%
{
positionsX := AHKAAdd(positionsX, positionX)
positionsY := AHKAAdd(positionsY, workingAreaY)
sizesWidth := AHKAAdd(sizesWidth, sizeWidth)
sizesHeight := AHKAAdd(sizesHeight, workingAreaHeight)
positionX += sizeWidth
}
} Else If (splitLayout = "h") {
positionY := workingAreaY
sizeHeight := Round(workingAreaHeight/numberOfAreas)
Loop, %numberOfAreas%
{
positionsX := AHKAAdd(positionsX, workingAreaX)
positionsY := AHKAAdd(positionsY, positionY)
sizesWidth := AHKAAdd(sizesWidth, workingAreaWidth)
sizesHeight := AHKAAdd(sizesHeight, sizeHeight)
positionY += sizeHeight
}
}
}
}
setNumberOfAreas:
StringReplace, numberOfAreas, A_ThisHotkey, #,
getWindows(activeView)
If (numberOfAreas+0 = 0) {
viewWindows := AHKAGet(windows, activeView)
numberOfAreas := AHKASize(viewWindows)
}
resizeAndPositionWindows()
If autoDisplayLayoutGridFlag
displayLayoutGrid()
Return
setLayoutMode:
StringReplace, layoutMode, A_ThisHotkey, #,
getWindows(activeView)
resizeAndPositionWindows()
If autoDisplayLayoutGridFlag
displayLayoutGrid()
Return
setSplitLayout:
StringReplace, splitLayout, A_ThisHotkey, #,
getWindows(activeView)
resizeAndPositionWindows()
If autoDisplayLayoutGridFlag
displayLayoutGrid()
Return
activateWindow(index) {
Global
getWindows(activeView)
viewWindows := AHKAGet(windows, activeView)
id := AHKAGet(viewWindows, index)
WinActivate, ahk_id %id%
}
closeWindow() {
WinGet, id, ID, A
WinClose, ahk_id %id%
}
hideTitlebars(hide) {
Global
getWindows(activeView)
viewWindows := AHKAGet(windows, activeView)
viewWindowsTotal := AHKASize(viewWindows)
If (hide) {
Loop, %viewWindowsTotal%
{
id := AHKAGet(viewWindows, A_Index)
WinSet, Style, -0xC00000, ahk_id %id%,
}
} Else {
Loop, %viewWindowsTotal%
{
id := AHKAGet(viewWindows, A_Index)
WinSet, Style, +0xC00000, ahk_id %id%,
}
}
}tagging.ahk/*
title: dWm (dynamic window managment for Windows)
author: joten
version: 0.3.5
date: 27.06.2008
comment: If code was copied from the AutoHotkey forum, it has been commented at the end of the code snippet.
license: The code written by joten is licensed under the GPL (version 2) like AutoHotkey itself (see license.txt).
*/
switchToView:
StringReplace, newView, A_ThisHotkey, !,
If (activeView <> newView+0) {
getWindows(activeView)
showWindows(activeView, false)
showWindows(newView, true)
activeView := newView
activateLastActiveWindow(activeView)
If autoResizeAndPositionWindowsFlag
autoResizeAndPositionWindows()
If autoDisplayViewNumberFlag
OSD(activeView)
}
Return
showWindows(view, show) { ; if show is true then the windows with the tag %view% are shown, else hidden
Global
noViewAction := false
viewWindows := AHKAGet(windows, view)
viewWindowsTotal := AHKASize(viewWindows)
Loop, %viewWindowsTotal% {
id := AHKAGet(viewWindows, A_Index)
If (show) {
WinShow, ahk_id %id%
} Else {
WinHide, ahk_id %id%
}
}
noViewAction := true
}
activateLastActiveWindow(view) {
Global
viewWindows := AHKAGet(windows, view)
id := AHKAGet(viewWindows, 1)
WinActivate, ahk_id %id%
}
setTagOfActiveWindow:
StringReplace, newTag, A_ThisHotkey, ^!,
WinGet, id, ID, A
removeWindowTags(id)
addWindowTag(id, newTag)
noViewAction := false
If newTag+0 <> activeView
WinHide, ahk_id %id%
noViewAction := true
activateLastActiveWindow(activeView)
If autoResizeAndPositionWindowsFlag
autoResizeAndPositionWindows()
Return
removeWindowTags(id) {
Global
Loop, %maxViewNumber% {
viewWindows := AHKAGet(windows, A_Index)
index := AHKAFind(viewWindows, id, 1)
If index > 0
viewWindows := AHKARemove(viewWindows, index)
windows := AHKASet(windows, viewWindows, A_Index)
}
}
addWindowTag(id, newTag) {
Global
viewWindows := AHKAGet(windows, newTag)
viewWindows := AHKAAdd(viewWindows, id)
windows := AHKASet(windows, viewWindows, newTag)
}
addTagToActiveWindow:
StringReplace, newTag, A_ThisHotkey, ^+!,
WinGet, id, ID, A
addWindowTag(id, newTag+0)
Return
OSD.ahk/*
title: dWm (dynamic window managment for Windows)
author: joten
version: 0.3.5
date: 27.06.2008
comment: If code was copied from the AutoHotkey forum, it has been commented at the end of the code snippet.
license: The code written by joten is licensed under the GPL (version 2) like AutoHotkey itself (see license.txt).
*/
displayViewNumber:
OSD(activeView)
Return
OSD(text, OSDFontSize=80, time=500) {
Global OSDFontName, OSDFontColor, OSDOpacity, OSDFontFormat
Gui, 2: Default
wndTitle = "blkOsdWnd2"
If (wndTitle) {
IfWinExist, %wndTitle%
WinClose
Gui, Destroy
}
Gui, +LastFound +AlwaysOnTop +ToolWindow -Caption
Gui, Margin, 0, 0 ; pixels of space to leave at the left/right and top/bottom sides of the window when auto-positioning.
Gui, Color, ffffff ; background color
Gui, Font, c%OSDFontColor% s%OSDFontSize% w%OSDFontFormat%, %OSDFontName%
Gui, Add, Text, +0x80 v & "blkOsdCtrlName2", %text% ; 0x80 = SS_NOPREFIX -> Ampersand (&) is shown instead of underline one letter for Alt+letter navigation
WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT -> mouse klickthrough
opacity := OSDOpacity * 255 / 100
WinSet, TransColor, ffffff %opacity%
Gui, Show, xCenter yCenter +NoActivate, %wndTitle%
Sleep, %time%
Gui, Destroy
}
; source: http://www.autohotkey.com/forum/topic8959.html
displayOverView:
wndTitle = "blkOsdWnd3"
If (wndTitle) {
Gui, 3: Default
IfWinExist, %wndTitle%
{
WinClose
Gui, Destroy
} Else {
OSDFontSize := 16
rows := Round(workingAreaHeight/OSDFontSize*0.4)
width := Round(workingAreaWidth*0.7)
Gui, +LastFound +AlwaysOnTop +ToolWindow -Caption
Gui, Margin, 0, 0
Gui, Color, ffffff
Gui, Font, c%OSDFontColor% s%OSDFontSize% w%OSDFontFormat%, %OSDFontName%
Gui, Add, ListView, r%rows% w%width%, View|Window Title
DetectHiddenWindows, on
Loop, %maxViewNumber%
{
viewNumber := A_Index
viewWindows := AHKAGet(windows, viewNumber)
viewWindowsTotal := AHKASize(viewWindows)
Loop, %viewWindowsTotal%
{
id := AHKAGet(viewWindows, A_Index)
WinGetTitle, windowTitle, ahk_id %id%
If (A_Index = 1) {
LV_Add("", viewNumber, windowTitle)
} Else {
LV_Add("", "", windowTitle)
}
}
}
DetectHiddenWindows, off
LV_ModifyCol(2) ; Auto-size each column to fit its contents.
; WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT -> mouse klickthrough
opacity := OSDOpacity * 255 / 100
WinSet, TransColor, ffffff %opacity%
Gui, Show, xCenter yCenter +NoActivate, %wndTitle%
}
}
Return
displayLayoutGrid() {
Global
wndTitle = "blkOsdWnd4"
If (wndTitle) {
Gui, 4: Default
IfWinExist, %wndTitle%
{
WinClose
Gui, Destroy
} Else {
OSDFontSize := 24
thickness := 2
Gui, +LastFound +AlwaysOnTop +ToolWindow -Caption
Gui, Margin, 0, 0
Gui, Color, ffffff
Gui, Font, c%OSDFontColor% s%OSDFontSize% w%OSDFontFormat%, %OSDFontName%
getSizesAndPositions()
Loop, %numberOfAreas%
{
x := AHKAGet(positionsX, A_Index)
y := AHKAGet(positionsY, A_Index)
width := AHKAGet(sizesWidth, A_Index)
height := AHKAGet(sizesHeight, A_Index)
x1 := x, y1 := y, w1 := width, h1 := thickness
x2 := x, y2 := y, w2 := thickness, h2 := height
x3 := x+width-thickness, y3 := y, w3 := thickness, h3 := height
x4 := x, y4 := y+height-thickness, w4 := width, h4 := thickness
cx := x+(width-OSDFontSize)/2, cy := y+(height-OSDFontSize)/2
Gui, Add, Picture, w%w1% h%h1% x%x1% y%y1%, images\grid.bmp
Gui, Add, Picture, w%w2% h%h2% x%x2% y%y2%, images\grid.bmp
Gui, Add, Picture, w%w3% h%h3% x%x3% y%y3%, images\grid.bmp
Gui, Add, Picture, w%w4% h%h4% x%x4% y%y4%, images\grid.bmp
Gui, Add, Text, x%cx% y%cy% +0x80 v & "blkOsdCtrlName2", %A_Index%
}
WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT -> mouse klickthrough
opacity := OSDOpacity * 255 / 100
WinSet, TransColor, ffffff %opacity%
GUIWidth = %A_ScreenWidth%
GUIHeight = %A_ScreenHeight%
Gui, Show, x0 y0 w%GUIWidth% h%GUIHeight% +NoActivate, %wndTitle%
Sleep, 1000
Gui, Destroy
}
}
}help.txt=====================
= About =
=====================
title: dWm (dynamic window managment for Windows)
author: joten
version: 0.3.5
date: 27.06.2008
function: "tiling window management" by positioning and sizing windows according to a specified layout selected by key stroke
"virtual desktops" with the slightly different concept of tagging windows and restricting the view to windows with the same tag
comment: first impression of dynamic (tiling) window management: http://www.suckless.org/wiki/dwm
hints at implementing window management with AutoHotkey: http://jgpaiva.donationcoders.com/gridmove.html (no code copied)
source for virtual desktops (tagging): http://www.autohotkey.com/forum/topic6182.html (code copied, but mostly rewritten to support arrays storing the window ids)
source for array handling (AHKArray): http://www.autohotkey.com/forum/topic14881.html (olegbl)
If code was copied AutoHotkey from the forum, it has been commented at the end of the code snippet.
license: The code written by joten is licensed under the GPL (version 2) like AutoHotkey itself (see license.txt).
=====================
= Options =
=====================
maxViewNumber : Maximum number of views/tags; the absolute maximum is 9
autoDisplayViewNumberFlag : If set to true, the view number is displayed when switching the view.
OSDFontName : The font name for the OSD (on screen display)
OSDFontColor : The font color for the OSD (on screen display)
OSDFontFormat : The font format (boldness) for the OSD (on screen display)
OSDOpacity : The opacity of the OSD (on screen display)
layoutMode : Default value for the layout mode
m = mono or master (one window in a master area, the other in a stacking area)
b = bi (two windows in a splitted master area, the other in a stacking area)
s = stack (no master, all windows are in teh stacking area)
numberOfAreas : The number of areas, in which the windows can be positioned; e. g.
1 with mode s: all windows are maximized
2 with mode m or s: split screen
5 with mode m: one window in the master area, 4 in the stacking area
splitLayout : the direction of the stacking area
v = vertical
h = horizontal
splitRatio : The ratio in which the current column or row will be split (right to left column or upper to
lower row) when the window is moved.
hideTitlebarFlag : If set to true, the titlebar of all windows is hidden leaving more space to the content.
autoResizeAndPositionWindowsFlag: If set to true, the number of areas is automatically set to the number of windows and all
windows are resized and positioned accordingly; this action is triggered by opening or closing a window.
autoDisplayLayoutGridFlag : If set to true, the layout grid is displayed, when the layout is changed (by pressing Win+<m/b/s/v/h/<number>>
exceptions : Classes of windows, which are excluded from the list of windows and therefor are not resized
and positioned; there seem to be windows, which are not shown in the taskbar (Shell_TrayWnd is
obvious) and therefor have to be excluded from the list of managed windows.
=====================
= Hotkeys =
=====================
Alt+<number> : Switch to the <number>th view; number < maxViewNumber (see options)
Alt+- : Display the view number; ß is the key next to 0 on a german keyboard
Alt+0 : Display a list of windows according to their tag (number)
Ctrl+Alt+<number> : Set <number> as the only tag of the active window; number < maxViewNumber (see options)
Ctrl+Shift+Alt+<number> : Add <number> to the tags of the active windsow; number < maxViewNumber (see options)
Win+<number> : Set the number of areas used to position the windows
Win+0 : Set the number of areas to the number of windows on the active view
Win+<m/b/s> : Set the layout mode
m = mono or master (one window in a master area, the other in a stacking area)
b = bi (two windows in a splitted master area, the other in a stacking area)
s = stack (no master, all windows are in teh stacking area)
Win+<v/h> : Set the direction of the stacking area
v = vertical
h = horizontal
Win+g : Display the grid of the layout
Win+<Left Arrow> : Open the "Alt+Tab" menu, switching to the next window; like Alt+Tab
Win+<Right Arrow> : Open the "Alt+Tab" menu, switching to the previous window; like Alt+Shift+Tab
Win+c : Closing the active window
Win+Backspace : Reload the script
Win+Escape : Exit the script
= Shortcuts =
Shortcuts can be added as needed, if they are not conflicting with the existing ones.




