Continue the manual merge. Bar.ahk is merged (pretty much unchanged)

This commit is contained in:
Joshua Fuhs 2012-11-26 22:13:38 -05:00
parent c30a4c3f30
commit e9e5a853cc
7 changed files with 2382 additions and 2506 deletions

View file

@ -1,30 +1,33 @@
/** /*
* bug.n - tiling window management bug.n -- tiling window management
* Copyright (c) 2010-2012 joten Copyright (c) 2010-2012 Joshua Fuhs, joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 8.3.0
*/
Bar_init(m) { This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0
*/
Bar_init(m)
{
Local appBarMsg, GuiN, h1, h2, i, text, titleWidth, trayWndId, w, wndId, wndTitle, wndWidth, x1, x2, y1, y2 Local appBarMsg, GuiN, h1, h2, i, text, titleWidth, trayWndId, w, wndId, wndTitle, wndWidth, x1, x2, y1, y2
If (SubStr(Config_barWidth, 0) = "%") { If (SubStr(Config_barWidth, 0) = "%")
{
StringTrimRight, wndWidth, Config_barWidth, 1 StringTrimRight, wndWidth, Config_barWidth, 1
wndWidth := Round(Monitor_#%m%_width * wndWidth / 100) wndWidth := Round(Monitor_#%m%_width * wndWidth / 100)
} Else }
Else
wndWidth := Config_barWidth wndWidth := Config_barWidth
Monitor_#%m%_barWidth := wndWidth Monitor_#%m%_barWidth := wndWidth
titleWidth := wndWidth titleWidth := wndWidth
@ -35,21 +38,21 @@ Bar_init(m) {
y2 := (Bar_ctrlHeight - Bar_textHeight) / 2 y2 := (Bar_ctrlHeight - Bar_textHeight) / 2
h2 := Bar_ctrlHeight - 2 * y2 h2 := Bar_ctrlHeight - 2 * y2
; Create the GUI window ;; Create the GUI window
wndTitle := "bug.n_BAR_" m wndTitle := "bug.n_BAR_" m
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
Log_dbg_msg(6, "Bar_init(): Gui, " . GuiN . ": Default") Debug_logMessage("DEBUG[6] Bar_init(): Gui, " . GuiN . ": Default", 6)
Gui, %GuiN%: Default Gui, %GuiN%: Default
IfWinExist, %wndTitle%
Gui, Destroy Gui, Destroy
Gui, +AlwaysOnTop -Caption +LabelBar_Gui +LastFound +ToolWindow Gui, +AlwaysOnTop -Caption +LabelBar_Gui +LastFound +ToolWindow
Gui, Color, %Config_normBgColor1% Gui, Color, %Config_normBgColor1%
Gui, Font, c%Config_normFgColor1% s%Config_fontSize%, %Config_fontName% Gui, Font, c%Config_normFgColor1% s%Config_fontSize%, %Config_fontName%
; tags ;; Tags
Loop, % Config_viewCount { Loop, % Config_viewCount
{
i := A_Index i := A_Index
text := " " i " " text := " " Config_viewNames_#%i% " "
w := Bar_getTextWidth(text) w := Bar_getTextWidth(text)
Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_view gBar_GuiClick, Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_view gBar_GuiClick,
If (w <= h1) If (w <= h1)
@ -60,9 +63,9 @@ Bar_init(m) {
titleWidth -= w titleWidth -= w
x1 += w x1 += w
} }
; layout ;; Layout
i := Config_viewCount + 1 i := Config_viewCount + 1
text := " 1x9|=- " text := " ?????? "
w := Bar_getTextWidth(text) w := Bar_getTextWidth(text)
Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_layout gBar_GuiClick, Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_layout gBar_GuiClick,
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor2% Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor2%
@ -71,11 +74,13 @@ Bar_init(m) {
titleWidth -= w titleWidth -= w
x1 += w x1 += w
; The x-position and width of the sub-windows right of the window title are set from the right. ;; The x-position and width of the sub-windows right of the window title are set from the right.
Loop, 4 { Loop, 4
{
i := Config_viewCount + 7 - A_Index i := Config_viewCount + 7 - A_Index
w := 0 w := 0
If (i = Config_viewCount + 6) { ; command gui If (i = Config_viewCount + 6)
{ ;; Command gui
Gui, -Disabled Gui, -Disabled
w := Bar_getTextWidth(" ?? ") w := Bar_getTextWidth(" ?? ")
x2 -= w x2 -= w
@ -83,16 +88,21 @@ Bar_init(m) {
Gui, Add, Text, x%x2% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i% gBar_toggleCommandGui, Gui, Add, Text, x%x2% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i% gBar_toggleCommandGui,
Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2% Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2%
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans, #! Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans, #!
} Else If (i = Config_viewCount + 5) And Config_readinTime { ; time }
Else If (i = Config_viewCount + 5) And Config_readinTime
{ ;; Time
w := Bar_getTextWidth(" ??:?? ") w := Bar_getTextWidth(" ??:?? ")
x2 -= w x2 -= w
titleWidth -= w titleWidth -= w
If Config_readinAny() Or Config_readinBat { If Config_readinAny() Or Config_readinBat
{
Gui, Font, c%Config_normFgColor1% Gui, Font, c%Config_normFgColor1%
Gui, Add, Text, x%x2% y%y1% w%w% h%h1%, Gui, Add, Text, x%x2% y%y1% w%w% h%h1%,
} }
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, ??:?? Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, ??:??
} Else If (i = Config_viewCount + 4) And Config_readinAny() { ; any }
Else If (i = Config_viewCount + 4) And Config_readinAny()
{ ;; Any
text := Config_readinAny() text := Config_readinAny()
w := Bar_getTextWidth(text) w := Bar_getTextWidth(text)
x2 -= w x2 -= w
@ -100,7 +110,9 @@ Bar_init(m) {
Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2% Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2%
Gui, Font, c%Config_normFgColor2% Gui, Font, c%Config_normFgColor2%
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans vBar_#%m%_#%i%, %text% Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans vBar_#%m%_#%i%, %text%
} Else If (i = Config_viewCount + 3) And Config_readinBat { ; battery level }
Else If (i = Config_viewCount + 3) And Config_readinBat
{ ;; Battery level
w := Bar_getTextWidth(" BAT: ???% ") w := Bar_getTextWidth(" BAT: ???% ")
x2 -= w x2 -= w
titleWidth -= w titleWidth -= w
@ -110,9 +122,10 @@ Bar_init(m) {
} }
} }
; window title (remaining space) ;; Window title (remaining space)
Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%, Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%,
If Not Config_singleRowBar { If Not Config_singleRowBar
{
titleWidth := wndWidth titleWidth := wndWidth
x1 := 0 x1 := 0
y1 += h1 y1 += h1
@ -145,13 +158,16 @@ Bar_init(m) {
Else Else
Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle% Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
wndId := WinExist(wndTitle) wndId := WinExist(wndTitle)
If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor) { If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor)
{
trayWndId := WinExist("ahk_class Shell_TrayWnd") trayWndId := WinExist("ahk_class Shell_TrayWnd")
DllCall("SetParent", "UInt", wndId, "UInt", trayWndId) DllCall("SetParent", "UInt", wndId, "UInt", trayWndId)
} Else { }
Else
{
appBarMsg := DllCall("RegisterWindowMessage", Str, "AppBarMsg") appBarMsg := DllCall("RegisterWindowMessage", Str, "AppBarMsg")
; appBarData: http://msdn2.microsoft.com/en-us/library/ms538008.aspx ;; appBarData: http://msdn2.microsoft.com/en-us/library/ms538008.aspx
VarSetCapacity(Bar_appBarData, 36, 0) VarSetCapacity(Bar_appBarData, 36, 0)
offset := NumPut( 36, Bar_appBarData) offset := NumPut( 36, Bar_appBarData)
offset := NumPut( wndId, offset+0) offset := NumPut( wndId, offset+0)
@ -166,15 +182,13 @@ Bar_init(m) {
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_NEW := 0x0) , "UInt", &Bar_appBarData) DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_NEW := 0x0) , "UInt", &Bar_appBarData)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_QUERYPOS := 0x2), "UInt", &Bar_appBarData) DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_QUERYPOS := 0x2), "UInt", &Bar_appBarData)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETPOS := 0x3) , "UInt", &Bar_appBarData) DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETPOS := 0x3) , "UInt", &Bar_appBarData)
; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html) ;; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
} }
Bar_hDrive := DllCall("CreateFile", "Str", "\\.\PhysicalDrive0", "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 0)
Bar_getNetworkInterface()
} }
Bar_initCmdGui() { Bar_initCmdGui()
Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_cmdGuiIsVisible, Config_fontName, Config_fontSize, Config_normBgColor1, Config_normFgColor1 {
Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_cmdGuiIsVisible, Config_barCommands, Config_fontName, Config_fontSize, Config_normBgColor1, Config_normFgColor1
Bar_cmdGuiIsVisible := False Bar_cmdGuiIsVisible := False
wndTitle := "bug.n_BAR_0" wndTitle := "bug.n_BAR_0"
@ -182,67 +196,14 @@ Bar_initCmdGui() {
Gui, +LabelBar_cmdGui Gui, +LabelBar_cmdGui
IfWinExist, %wndTitle% IfWinExist, %wndTitle%
Gui, Destroy Gui, Destroy
Gui, +LastFound -Caption +ToolWindow +AlwaysOnTop Gui, +LastFound -Caption +ToolWindow +AlwaysOnTop +Delimiter`;
Gui, Color, Default Gui, Color, Default
Gui, Font, s%Config_fontSize%, %Config_fontName% Gui, Font, s%Config_fontSize%, %Config_fontName%
Gui, Add, TreeView, x0 y0 r23 w300 Background%Config_normBgColor1% c%Config_normFgColor1% -ReadOnly vBar_#0_#0 gBar_cmdGuiEnter StringSplit, cmd, Config_barCommands, `;
GuiControl, -Redraw, Bar_#0_#0 Gui, Add, ComboBox, x10 y0 r%cmd0% w300 Background%Config_normBgColor1% c%Config_normFgColor1% Simple vBar_#0_#0 gBar_cmdGuiEnter, % Config_barCommands
itemId10 := TV_Add("Window")
itemId11 := TV_Add("set tag", itemId10)
TV_Add("all", itemId11)
TV_Add("Press <F2> to enter a number.", itemId11)
itemId12 := TV_Add("toggle tag", itemId10)
TV_Add("Press <F2> to enter a number.", itemId12)
TV_Add("move to top", itemId10)
TV_Add("move up", itemId10)
TV_Add("move down", itemId10)
TV_Add("toggle floating", itemId10)
TV_Add("toggle decor", itemId10)
TV_Add("close", itemId10)
TV_Add("maximize", itemId10)
TV_Add("move by key", itemId10)
TV_Add("resize by key", itemId10)
TV_Add("activate next", itemId10)
TV_Add("activate prev", itemId10)
TV_Add("move to next monitor", itemId10)
TV_Add("move to prev monitor", itemId10)
itemId20 := TV_Add("Layout")
TV_Add("set last", itemId20)
TV_Add("set 1st (tile)", itemId20)
TV_Add("set 2nd (monocle)", itemId20)
TV_Add("set 3rd (floating)", itemId20)
TV_Add("rotate layout axis", itemId20)
TV_Add("rotate master axis", itemId20)
TV_Add("rotate stack axis", itemId20)
TV_Add("mirror tile layout", itemId20)
TV_Add("increase master X", itemId20)
TV_Add("decrease master X", itemId20)
TV_Add("increase master Y", itemId20)
TV_Add("decrease master Y", itemId20)
TV_Add("increase master factor", itemId20)
TV_Add("decrease master factor", itemId20)
itemId30 := TV_Add("View")
itemId31 := TV_Add("activate", itemId30)
TV_Add("last", itemId31)
TV_Add("Press <F2> to enter a number.", itemId31)
TV_Add("move to next monitor", itemId30)
TV_Add("move to prev monitor", itemId30)
itemId40 := TV_Add("Monitor")
TV_Add("toggle bar", itemId40)
TV_Add("toggle task bar", itemId40)
TV_Add("activate next", itemId40)
TV_Add("activate prev", itemId40)
;itemId50 := TV_add("Log")
; TV_Add("increment debug level", itemId50)
; TV_Add("decrement debug level", itemId50)
; TV_Add("log help info", itemId50)
; TV_Add("log view window info", itemId50)
; TV_Add("log managed window info", itemId50)
TV_Add("Reload")
TV_Add("Quit")
GuiControl, +Redraw, Bar_#0_#0
Gui, Add, Button, Y0 Hidden Default gBar_cmdGuiEnter, OK Gui, Add, Button, Y0 Hidden Default gBar_cmdGuiEnter, OK
GuiControlGet, Bar_#0_#0, Pos GuiControlGet, Bar_#0_#0, Pos
Bar_#0_#0W += 20
Gui, Show, Hide w%Bar_#0_#0W% h%Bar_#0_#0H%, %wndTitle% Gui, Show, Hide w%Bar_#0_#0W% h%Bar_#0_#0H%, %wndTitle%
} }
@ -253,141 +214,23 @@ Bar_cmdGuiEscape:
Return Return
Bar_cmdGuiEnter: Bar_cmdGuiEnter:
If (A_GuiControl = "OK") Or (A_GuiControl = "BAR_#0_#0" And A_GuiControlEvent = "DoubleClick") { If (A_GuiControl = "OK") Or (A_GuiControl = "Bar_#0_#0" And A_GuiControlEvent = "DoubleClick")
Bar_selItemId_#1 := TV_GetSelection() {
If Not TV_GetChild(Bar_selItemId_#1) { Gui, Submit, NoHide
Bar_selItemId_#2 := TV_GetParent(Bar_selItemId_#1)
Bar_selItemId_#3 := TV_GetParent(Bar_selItemId_#2)
TV_GetText(Bar_command_#1, Bar_selItemId_#1)
TV_GetText(Bar_command_#2, Bar_selItemId_#2)
TV_GetText(Bar_command_#3, Bar_selItemId_#3)
} Else
Bar_command_#1 := ""
Bar_cmdGuiIsVisible := False Bar_cmdGuiIsVisible := False
Gui, Cancel Gui, Cancel
WinActivate, ahk_id %Bar_aWndId% WinActivate, ahk_id %Bar_aWndId%
Bar_evaluateCommand() Main_evalCommand(Bar_#0_#0)
Bar_#0_#0 := ""
} }
Return Return
Bar_evaluateCommand() { Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus)
Global Bar_command_#1, Bar_command_#2, Bar_command_#3, Config_viewCount {
If (Bar_command_#1) {
If (Bar_command_#2 = "Run")
Run, %Bar_command_#1%
Else If (Bar_command_#3 = "Window") {
If (Bar_command_#2 = "set tag") {
If (Bar_command_#1 = "all")
Monitor_setWindowTag(0)
Else If (RegExMatch(Bar_command_#1, "[0-9]+") And Bar_command_#1 <= Config_viewCount)
Monitor_setWindowTag(Bar_command_#1)
} Else If (Bar_command_#2 = "toggle tag")
If (RegExMatch(Bar_command_#1, "[0-9]+") And Bar_command_#1 <= Config_viewCount)
Monitor_toggleWindowTag(Bar_command_#1)
} Else If (Bar_command_#2 = "Window") {
If (Bar_command_#1 = "move to top")
View_shuffleWindow(0)
Else If (Bar_command_#1 = "move up")
View_shuffleWindow(-1)
Else If (Bar_command_#1 = "move down")
View_shuffleWindow(+1)
Else If (Bar_command_#1 = "toggle floating")
View_toggleFloating()
Else If (Bar_command_#1 = "toggle decor")
Manager_toggleDecor()
Else If (Bar_command_#1 = "close")
Manager_closeWindow()
Else If (Bar_command_#1 = "move by key")
Manager_moveWindow()
Else If (Bar_command_#1 = "resize by key")
Manager_sizeWindow()
Else If (Bar_command_#1 = "maximize")
Manager_maximizeWindow()
Else If (Bar_command_#1 = "activate next")
View_activateWindow(+1)
Else If (Bar_command_#1 = "activate prev")
View_activateWindow(-1)
Else If (Bar_command_#1 = "move to next monitor")
Manager_setWindowMonitor(+1)
Else If (Bar_command_#1 = "move to prev monitor")
Manager_setWindowMonitor(-1)
} Else If (Bar_command_#2 = "Layout") {
If (Bar_command_#1 = "set last")
View_setLayout(-1)
Else If (Bar_command_#1 = "set 1st (tile)")
View_setLayout(1)
Else If (Bar_command_#1 = "set 2nd (monocle)")
View_setLayout(2)
Else If (Bar_command_#1 = "set 3rd (floating)")
View_setLayout(3)
Else If (Bar_command_#1 = "rotate layout axis")
View_rotateLayoutAxis(1, +1)
Else If (Bar_command_#1 = "rotate master axis")
View_rotateLayoutAxis(2, +1)
Else If (Bar_command_#1 = "rotate stack axis")
View_rotateLayoutAxis(3, +1)
Else If (Bar_command_#1 = "mirror tile layout")
View_rotateLayoutAxis(1, +2)
Else If (Bar_command_#1 = "increase master X")
View_setMX(+1)
Else If (Bar_command_#1 = "decrease master X")
View_setMX(-1)
Else If (Bar_command_#1 = "increase master Y")
View_setMY(+1)
Else If (Bar_command_#1 = "decrease master Y")
View_setMY(-1)
Else If (Bar_command_#1 = "increase master factor")
View_setMFactor(+0.05)
Else If (Bar_command_#1 = "decrease master factor")
View_setMFactor(-0.05)
} Else If (Bar_command_#3 = "View") {
If (Bar_command_#2 = "activate") {
If (Bar_command_#1 = "last")
Monitor_activateView(-1)
Else If (RegExMatch(Bar_command_#1, "[0-9]+") And Bar_command_#1 <= Config_viewCount)
Monitor_activateView(Bar_command_#1)
}
} Else If (Bar_command_#2 = "View") {
If (Bar_command_#1 = "move to next monitor")
Manager_setViewMonitor(+1)
Else If (Bar_command_#1 = "move to prev monitor")
Manager_setViewMonitor(-1)
} Else If (Bar_command_#2 = "Monitor") {
If (Bar_command_#1 = "toggle bar")
Monitor_toggleBar()
Else If (Bar_command_#1 = "toggle task bar")
Monitor_toggleTaskBar()
Else If (Bar_command_#1 = "activate next")
Manager_activateMonitor(+1)
Else If (Bar_command_#1 = "activate prev")
Manager_activateMonitor(-1)
} Else If (Bar_command_#2 = "Log") {
If (Bar_command_#1 = "increment debug level")
Log_incDebugLevel()
If (Bar_command_#1 = "decrement debug level")
Log_decDebugLevel()
If (Bar_command_#1 = "log help info")
Manager_logHelp()
If (Bar_command_#1 = "log view window info")
Manager_logViewWindowList()
If (Bar_command_#1 = "log managed window info")
Manager_logManagedWindowList()
} Else If (Bar_command_#1 = "Reload")
Main_reload()
Else If (Bar_command_#1 = "Quit")
ExitApp
Bar_command_#1 := ""
Bar_command_#2 := ""
Bar_command_#3 := ""
}
}
Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) {
VarSetCapacity(powerStatus, (1 + 1 + 1 + 1 + 4 + 4)) VarSetCapacity(powerStatus, (1 + 1 + 1 + 1 + 4 + 4))
success := DllCall("GetSystemPowerStatus", "UInt", &powerStatus) success := DllCall("GetSystemPowerStatus", "UInt", &powerStatus)
If (ErrorLevel != 0 Or success = 0) { If (ErrorLevel != 0 Or success = 0)
{
MsgBox 16, Power Status, Can't get the power status... MsgBox 16, Power Status, Can't get the power status...
Return Return
} }
@ -404,27 +247,10 @@ Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) {
If batteryLifePercent = 255 If batteryLifePercent = 255
batteryLifePercent = ??? batteryLifePercent = ???
} }
; PhiLho: AC/Battery status (http://www.autohotkey.com/forum/topic7633.html) ;; PhiLho: AC/Battery status (http://www.autohotkey.com/forum/topic7633.html)
Bar_getDiskLoad(ByRef readLoad, ByRef writeLoad) { Bar_getHeight()
Global Bar_hDrive {
Static oldReadCount, oldWriteCount
dpSize := 5 * 8 + 4 + 4 + 4 + 4 + 8 + 4 + 8 * (A_IsUnicode ? 2 : 1) + 12 ; 88?
VarSetCapacity(dp, dpSize)
DllCall("DeviceIoControl", "UInt", Bar_hDrive, "UInt", 0x00070020, "UInt", 0, "UInt", 0, "UInt", &dp, "UInt", dpSize, "UIntP", nReturn, "UInt", 0) ; IOCTL_DISK_PERFORMANCE
newReadCount := NumGet(dp, 40)
newWriteCount := NumGet(dp, 44)
readLoad := SubStr(" " Round((1 - 1 / (1 + newReadCount - oldReadCount)) * 100), -2)
writeLoad := SubStr(" " Round((1 - 1 / (1 + newWriteCount - oldWriteCount)) * 100), -2)
oldReadCount := newReadCount
oldWriteCount := newWriteCount
}
; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
; SKAN: HDD Activity Monitoring LED (http://www.autohotkey.com/community/viewtopic.php?p=113890&sid=64d9824fdf252697ff4d5026faba91f8#p113890)
Bar_getHeight() {
Global Bar_#0_#1, Bar_#0_#1H, Bar_#0_#2, Bar_#0_#2H, Bar_ctrlHeight, Bar_height, Bar_textHeight Global Bar_#0_#1, Bar_#0_#1H, Bar_#0_#2, Bar_#0_#2H, Bar_ctrlHeight, Bar_height, Bar_textHeight
Global Config_fontName, Config_fontSize, Config_singleRowBar, Config_spaciousBar, Config_verticalBarPos Global Config_fontName, Config_fontSize, Config_singleRowBar, Config_spaciousBar, Config_verticalBarPos
@ -434,18 +260,21 @@ Bar_getHeight() {
Gui, Add, Text, x0 y0 vBar_#0_#1, | Gui, Add, Text, x0 y0 vBar_#0_#1, |
GuiControlGet, Bar_#0_#1, Pos GuiControlGet, Bar_#0_#1, Pos
Bar_textHeight := Bar_#0_#1H Bar_textHeight := Bar_#0_#1H
If Config_spaciousBar { If Config_spaciousBar
{
Gui, Add, ComboBox, r9 x0 y0 vBar_#0_#2, | Gui, Add, ComboBox, r9 x0 y0 vBar_#0_#2, |
GuiControlGet, Bar_#0_#2, Pos GuiControlGet, Bar_#0_#2, Pos
Bar_ctrlHeight := Bar_#0_#2H Bar_ctrlHeight := Bar_#0_#2H
} Else }
Else
Bar_ctrlHeight := Bar_textHeight Bar_ctrlHeight := Bar_textHeight
Gui, Destroy Gui, Destroy
Bar_height := Bar_ctrlHeight Bar_height := Bar_ctrlHeight
If Not Config_singleRowBar If Not Config_singleRowBar
Bar_height *= 2 Bar_height *= 2
If (Config_verticalBarPos = "tray") { If (Config_verticalBarPos = "tray")
{
WinGetPos, , , , buttonH, Start ahk_class Button WinGetPos, , , , buttonH, Start ahk_class Button
WinGetPos, , , , barH, ahk_class Shell_TrayWnd WinGetPos, , , , barH, ahk_class Shell_TrayWnd
If (buttonH < barH) If (buttonH < barH)
@ -458,81 +287,12 @@ Bar_getHeight() {
} }
} }
Bar_getMemoryUsage() { Bar_getTextWidth(x, reverse=False)
VarSetCapacity(memoryStatus, 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4) {
DllCall("kernel32.dll\GlobalMemoryStatus", "UInt", &memoryStatus)
Return, SubStr(" " Round(*(&memoryStatus + 4)), -2) ; LS byte is enough, 0..100
}
; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
Bar_getNetworkInterface() {
Global Bar_networkInterface, Bar_networkInterfaceTable
DllCall("iphlpapi\GetNumberOfInterfaces", "UIntP", n)
nSize := 4 + 860 * n + 8
VarSetCapacity(Bar_networkInterfaceTable, nSize)
If Not DllCall("iphlpapi\GetIfTable", "UInt", &Bar_networkInterfaceTable, "UIntP", nSize, "Int", False) {
Loop, 2 {
i := 0
j := A_Index
Loop, % NumGet(Bar_networkInterfaceTable) {
If NumGet(Bar_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 544) < 4
|| NumGet(Bar_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 516) = 24
Continue
i += 1
dn_#%i%_#%j% := NumGet(Bar_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 552)
up_#%i%_#%j% := NumGet(Bar_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 576)
}
If (A_Index < 2)
RunWait, %Comspec% /c ping -n 1 127.0.0.1, , hide
}
Loop, % i
If (dn_#%i%_#2 > dn_#%i%_1) {
Bar_networkInterface := i
Break
}
}
}
; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
Bar_getNetworkLoad(ByRef upLoad, ByRef dnLoad) {
Global Bar_networkInterface, Bar_networkInterfaceTable
Static dn_#0, t_#0, up_#0
DllCall("iphlpapi\GetIfEntry", "UInt", &Bar_networkInterfaceTable + 4 + 860 * (Bar_networkInterface - 1))
dn_#1 := NumGet(Bar_networkInterfaceTable, 4 + 860 * (Bar_networkInterface - 1) + 552) ; Total Incoming Bytes
up_#1 := NumGet(Bar_networkInterfaceTable, 4 + 860 * (Bar_networkInterface - 1) + 576) ; Total Outgoing Bytes
tDiff := (A_TickCount - t_#0) / 1000
t_#0 := A_TickCount
dnLoad := SubStr(" " Round((dn_#1 - dn_#0) / 1024 / tDiff), -3)
upLoad := SubStr(" " Round((up_#1 - up_#0) / 1024 / tDiff), -3)
dn_#0 := dn_#1
up_#0 := up_#1
}
; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
; Sean: Network Download/Upload Meter (http://www.autohotkey.com/community/viewtopic.php?t=18033)
Bar_getSystemTimes() { ; Total CPU Load
Static oldIdleTime, oldKrnlTime, oldUserTime
Static newIdleTime, newKrnlTime, newUserTime
oldIdleTime := newIdleTime
oldKrnlTime := newKrnlTime
oldUserTime := newUserTime
DllCall("GetSystemTimes", "Int64P", newIdleTime, "Int64P", newKrnlTime, "Int64P", newUserTime)
sysTime := SubStr(" " . Round((1 - (newIdleTime - oldIdleTime) / (newKrnlTime - oldKrnlTime+newUserTime - oldUserTime)) * 100), -2)
Return, sysTime ; system time in percent
}
; Sean: CPU LoadTimes (http://www.autohotkey.com/forum/topic18913.html)
Bar_getTextWidth(x, reverse=False) {
Global Config_fontSize Global Config_fontSize
If reverse { ; "reverse" calculates the number of characters to a given width. If reverse
{ ;; 'reverse' calculates the number of characters to a given width.
w := x w := x
i := w / (Config_fontSize - 1) i := w / (Config_fontSize - 1)
If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13)) If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13))
@ -542,7 +302,9 @@ Bar_getTextWidth(x, reverse=False) {
Else If (Config_fontSize > 17) Else If (Config_fontSize > 17)
i := w / (Config_fontSize - 4) i := w / (Config_fontSize - 4)
textWidth := i textWidth := i
} Else { ; "else" calculates the width to a given string. }
Else
{ ;; 'else' calculates the width to a given string.
textWidth := StrLen(x) * (Config_fontSize - 1) textWidth := StrLen(x) * (Config_fontSize - 1)
If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13)) If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13))
textWidth := StrLen(x) * (Config_fontSize - 2) textWidth := StrLen(x) * (Config_fontSize - 2)
@ -557,7 +319,8 @@ Bar_getTextWidth(x, reverse=False) {
Bar_GuiClick: Bar_GuiClick:
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
If (A_GuiEvent = "Normal") { If (A_GuiEvent = "Normal")
{
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
If (SubStr(A_GuiControl, -6) = "_layout") If (SubStr(A_GuiControl, -6) = "_layout")
@ -569,12 +332,16 @@ Return
Bar_GuiContextMenu: Bar_GuiContextMenu:
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
If (A_GuiEvent = "RightClick") { If (A_GuiEvent = "RightClick")
If (SubStr(A_GuiControl, -6) = "_layout") { {
If (SubStr(A_GuiControl, -6) = "_layout")
{
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
View_setLayout(">") View_setLayout(">")
} Else If (SubStr(A_GuiControl, -4) = "_view") { }
Else If (SubStr(A_GuiControl, -4) = "_view")
{
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
Manager_setWindowMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) Manager_setWindowMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
Monitor_setWindowTag(SubStr(A_GuiControl, InStr(A_GuiControl, "_#", False, 0) + 2, 1)) Monitor_setWindowTag(SubStr(A_GuiControl, InStr(A_GuiControl, "_#", False, 0) + 2, 1))
@ -586,7 +353,8 @@ Bar_loop:
Bar_updateStatus() Bar_updateStatus()
Return Return
Bar_move(m) { Bar_move(m)
{
Local wndTitle, x, y Local wndTitle, x, y
x := Monitor_#%m%_barX x := Monitor_#%m%_barX
@ -603,41 +371,47 @@ Bar_toggleCommandGui:
Bar_toggleCommandGui() Bar_toggleCommandGui()
Return Return
Bar_toggleCommandGui() { Bar_toggleCommandGui()
{
Local wndId, x, y Local wndId, x, y
Gui, 99: Default Gui, 99: Default
If Bar_cmdGuiIsVisible { If Bar_cmdGuiIsVisible
{
Bar_cmdGuiIsVisible := False Bar_cmdGuiIsVisible := False
Gui, Cancel Gui, Cancel
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
} Else { }
Else
{
Bar_cmdGuiIsVisible := True Bar_cmdGuiIsVisible := True
x := Monitor_#%Manager_aMonitor%_barX + Monitor_#%Manager_aMonitor%_barWidth - Bar_#0_#0W x := Monitor_#%Manager_aMonitor%_barX + Monitor_#%Manager_aMonitor%_barWidth - Bar_#0_#0W
If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray" And Not Manager_aMonitor = Manager_taskBarMonitor) If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray" And (Manager_taskBarPos = "top" Or Not Manager_aMonitor = Manager_taskBarMonitor))
y := Monitor_#%Manager_aMonitor%_y y := Monitor_#%Manager_aMonitor%_y
Else Else
y := Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height - Bar_#0_#0H y := Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height - Bar_#0_#0H
Gui, Show Gui, Show
WinMove, bug.n_BAR_0, , %x%, %y% WinMove, bug.n_BAR_0, , %x%, %y%
WinGet, wndId, ID, bug.n_BAR_0
Manager_winActivate(wndId)
GuiControl, Focus, % Bar_#0_#0 GuiControl, Focus, % Bar_#0_#0
} }
} }
Bar_toggleVisibility(m) { Bar_toggleVisibility(m)
{
Local GuiN Local GuiN
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
If Monitor_#%m%_showBar { If Monitor_#%m%_showBar
{
If Not (GuiN = 99) Or Bar_cmdGuiIsVisible If Not (GuiN = 99) Or Bar_cmdGuiIsVisible
Gui, %GuiN%: Show Gui, %GuiN%: Show
} Else }
Else
Gui, %GuiN%: Cancel Gui, %GuiN%: Cancel
} }
Bar_updateLayout(m) { Bar_updateLayout(m)
{
Local aView, GuiN, i Local aView, GuiN, i
aView := Monitor_#%m%_aView_#1 aView := Monitor_#%m%_aView_#1
@ -646,25 +420,33 @@ Bar_updateLayout(m) {
GuiControl, %GuiN%: , Bar_#%m%_#%i%, % View_#%m%_#%aView%_layoutSymbol GuiControl, %GuiN%: , Bar_#%m%_#%i%, % View_#%m%_#%aView%_layoutSymbol
} }
Bar_updateStatus() { Bar_updateStatus()
{
Local anyContent, anyText, b1, b2, b3, GuiN, i, m Local anyContent, anyText, b1, b2, b3, GuiN, i, m
Loop, % Manager_monitorCount { Loop, % Manager_monitorCount
{
m := A_Index m := A_Index
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
Log_dbg_msg(6, "Bar_updateStatus(): Gui, " . GuiN . ": Default") Debug_logMessage("DEBUG[6] Bar_updateStatus(): Gui, " . GuiN . ": Default", 6)
Gui, %GuiN%: Default Gui, %GuiN%: Default
If Config_readinBat { If Config_readinBat
{
Bar_getBatteryStatus(b1, b2) Bar_getBatteryStatus(b1, b2)
b3 := SubStr(" " b1, -2) b3 := SubStr(" " b1, -2)
i := Config_viewCount + 3 i := Config_viewCount + 3
If (b1 < 10) And (b2 = "off") { ; change the color, if the battery level is below 10% If (b1 < 10) And (b2 = "off")
{ ;; Change the color, if the battery level is below 10%
GuiControl, +Background%Config_normBgColor4% +c%Config_normBgColor2%, Bar_#%m%_#%i%_tagged GuiControl, +Background%Config_normBgColor4% +c%Config_normBgColor2%, Bar_#%m%_#%i%_tagged
GuiControl, +c%Config_selFgColor6%, Bar_#%m%_#%i% GuiControl, +c%Config_selFgColor6%, Bar_#%m%_#%i%
} Else If (b2 = "off") { ; change the color, if the pc is not plugged in }
Else If (b2 = "off")
{ ;; Change the color, if the pc is not plugged in
GuiControl, +Background%Config_normBgColor2% +c%Config_normFgColor5%, Bar_#%m%_#%i%_tagged GuiControl, +Background%Config_normBgColor2% +c%Config_normFgColor5%, Bar_#%m%_#%i%_tagged
GuiControl, +c%Config_normFgColor4%, Bar_#%m%_#%i% GuiControl, +c%Config_normFgColor4%, Bar_#%m%_#%i%
} Else { }
Else
{
GuiControl, +Background%Config_normBgColor3% +c%Config_normFgColor3%, Bar_#%m%_#%i%_tagged GuiControl, +Background%Config_normBgColor3% +c%Config_normFgColor3%, Bar_#%m%_#%i%_tagged
GuiControl, +c%Config_normFgColor2%, Bar_#%m%_#%i% GuiControl, +c%Config_normFgColor2%, Bar_#%m%_#%i%
} }
@ -672,25 +454,29 @@ Bar_updateStatus() {
GuiControl, , Bar_#%m%_#%i%, % " BAT: " b3 "% " GuiControl, , Bar_#%m%_#%i%, % " BAT: " b3 "% "
} }
anyText := Config_readinAny() anyText := Config_readinAny()
If anyText { If anyText
{
i := Config_viewCount + 4 i := Config_viewCount + 4
GuiControlGet, anyContent, , Bar_#%m%_#%i% GuiControlGet, anyContent, , Bar_#%m%_#%i%
If Not (anyText = anyContent) If Not (anyText = anyContent)
GuiControl, , Bar_#%m%_#%i%, % anyText GuiControl, , Bar_#%m%_#%i%, % anyText
} }
If Config_readinTime { If Config_readinTime
{
i := Config_viewCount + 5 i := Config_viewCount + 5
GuiControl, , Bar_#%m%_#%i%, % " " A_Hour ":" A_Min " " GuiControl, , Bar_#%m%_#%i%, % " " A_Hour ":" A_Min " "
} }
} }
} }
Bar_updateTitle(debugMsg = "") { Bar_updateTitle(debugMsg = "")
{
Local aWndId, aWndTitle, content, GuiN, i, title Local aWndId, aWndTitle, content, GuiN, i, title
If debugMsg If debugMsg
aWndTitle := debugMsg aWndTitle := debugMsg
Else { Else
{
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
WinGetTitle, aWndTitle, ahk_id %aWndId% WinGetTitle, aWndTitle, ahk_id %aWndId%
If InStr(Bar_hideTitleWndIds, aWndId ";") Or (aWndTitle = "bug.n_BAR_0") If InStr(Bar_hideTitleWndIds, aWndId ";") Or (aWndTitle = "bug.n_BAR_0")
@ -702,19 +488,22 @@ Bar_updateTitle(debugMsg = "") {
} }
title := " " . aWndTitle . " " title := " " . aWndTitle . " "
If (Bar_getTextWidth(title) > Bar_#%Manager_aMonitor%_titleWidth) { ; shorten the window title if its length exceeds the width of the bar If (Bar_getTextWidth(title) > Bar_#%Manager_aMonitor%_titleWidth)
{ ;; Shorten the window title if its length exceeds the width of the bar
i := Bar_getTextWidth(Bar_#%Manager_aMonitor%_titleWidth, True) - 6 i := Bar_getTextWidth(Bar_#%Manager_aMonitor%_titleWidth, True) - 6
StringLeft, title, aWndTitle, i StringLeft, title, aWndTitle, i
title := " " . title . " ... " title := " " . title . " ... "
} }
i := Config_viewCount + 2 i := Config_viewCount + 2
Loop, % Manager_monitorCount { Loop, % Manager_monitorCount
{
GuiN := (A_Index - 1) + 1 GuiN := (A_Index - 1) + 1
Log_dbg_msg(6, "Bar_updateTitle(): Gui, " . GuiN . ": Default") Debug_logMessage("DEBUG[6] Bar_updateTitle(): Gui, " . GuiN . ": Default", 6)
Gui, %GuiN%: Default Gui, %GuiN%: Default
GuiControlGet, content, , Bar_#%A_Index%_#%i% GuiControlGet, content, , Bar_#%A_Index%_#%i%
If (A_Index = Manager_aMonitor) { If (A_Index = Manager_aMonitor)
{
If Not (content = title) If Not (content = title)
GuiControl, , Bar_#%A_Index%_#%i%, % title GuiControl, , Bar_#%A_Index%_#%i%, % title
} Else If Not (content = "") } Else If Not (content = "")
@ -723,35 +512,38 @@ Bar_updateTitle(debugMsg = "") {
Bar_aWndId := aWndId Bar_aWndId := aWndId
} }
; Update the view portion of the status bar. Bar_updateView(m, v)
Bar_updateView(m, v) { {
Local IdsLen, ViewIdsLen Local managedWndId0, wndId0, wndIds
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
Log_dbg_msg(6, "Bar_updateView(): m: " . m . "; Gui, " . GuiN . ": Default")
Gui, %GuiN%: Default Gui, %GuiN%: Default
Debug_logMessage("DEBUG[6] Bar_updateView(): m: " . m . "; Gui, " . GuiN . ": Default", 6)
IdsLen := StrLen(Manager_managedWndIds) StringTrimRight, wndIds, Manager_managedWndIds, 1
StringSplit, managedWndId, wndIds, `;
If (v = Monitor_#%m%_aView_#1) { If (v = Monitor_#%m%_aView_#1)
; Set foreground/background colors if the view is the current view. { ;; Set foreground/background colors if the view is the current view.
GuiControl, +Background%Config_selBgColor1% +c%Config_selFgColor2%, Bar_#%m%_#%v%_tagged GuiControl, +Background%Config_selBgColor1% +c%Config_selFgColor2%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_selFgColor1%, Bar_#%m%_#%v% GuiControl, +c%Config_selFgColor1%, Bar_#%m%_#%v%
} Else If StrLen(View_#%m%_#%v%_wndIds) > 0 { }
; Set foreground/background colors if the view contains windows. Else If wndId0
{ ;; Set foreground/background colors if the view contains windows.
GuiControl, +Background%Config_normBgColor5% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged GuiControl, +Background%Config_normBgColor5% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_normFgColor7%, Bar_#%m%_#%v% GuiControl, +c%Config_normFgColor7%, Bar_#%m%_#%v%
} Else { }
; Set foreground/background colors if the view is empty. Else
{ ;; Set foreground/background colors if the view is empty.
GuiControl, +Background%Config_normBgColor1% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged GuiControl, +Background%Config_normBgColor1% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_normFgColor1%, Bar_#%m%_#%v% GuiControl, +c%Config_normFgColor1%, Bar_#%m%_#%v%
} }
Loop, %Config_viewCount% { Loop, %Config_viewCount%
ViewIdsLen := StrLen( View_#%m%_#%A_Index%_wndIds ) {
; Update the percentage fill for the view. StringTrimRight, wndIds, View_#%m%_#%A_Index%_wndIds, 1
GuiControl, , Bar_#%m%_#%A_Index%_tagged, % ViewIdsLen / IdsLen * 100 StringSplit, wndId, wndIds, `;
; Refresh the number on the bar. GuiControl, , Bar_#%m%_#%A_Index%_tagged, % wndId0 / managedWndId0 * 100 ;; Update the percentage fill for the view.
GuiControl, , Bar_#%m%_#%A_Index%, %A_Index% GuiControl, , Bar_#%m%_#%A_Index%, % Config_viewNames_#%A_Index% ;; Refresh the number on the bar.
} }
} }

View file

@ -267,29 +267,37 @@ Config_restoreConfig(filename) {
Return Return
Loop, READ, %filename% Loop, READ, %filename%
If (SubStr(A_LoopReadLine, 1, 7) = "Config_") { If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
{
;Log_msg("Processing line: " . A_LoopReadLine) ;Log_msg("Processing line: " . A_LoopReadLine)
i := InStr(A_LoopReadLine, "=") i := InStr(A_LoopReadLine, "=")
var := SubStr(A_LoopReadLine, 1, i - 1) var := SubStr(A_LoopReadLine, 1, i - 1)
val := SubStr(A_LoopReadLine, i + 1) val := SubStr(A_LoopReadLine, i + 1)
type := SubStr(var, 1, 13) type := SubStr(var, 1, 13)
If (type = "Config_hotkey") { If (type = "Config_hotkey")
{
Debug_logMessage("Processing configured hotkey: " . A_LoopReadLine, 0)
i := InStr(val, "::") i := InStr(val, "::")
key := SubStr(val, 1, i - 1) key := SubStr(val, 1, i - 1)
cmd := SubStr(val, i + 2) cmd := SubStr(val, i + 2)
If Not cmd If Not cmd
Hotkey, %key%, Off Hotkey, %key%, Off
Else { Else
{
Debug_logMessage(" Hotkey: " . key . " -> " . cmd, 0)
Config_hotkeyCount += 1 Config_hotkeyCount += 1
Config_hotkey_#%Config_hotkeyCount%_key := key Config_hotkey_#%Config_hotkeyCount%_key := key
Config_hotkey_#%Config_hotkeyCount%_command := cmd Config_hotkey_#%Config_hotkeyCount%_command := cmd
Hotkey, %key%, Config_hotkeyLabel Hotkey, %key%, Config_hotkeyLabel
} }
} Else If (type = "Config_rule") { }
Else If (type = "Config_rule")
{
i := 0 i := 0
If InStr(var, "Config_rule_#") If InStr(var, "Config_rule_#")
i := SubStr(var, 14) i := SubStr(var, 14)
If (i = 0 Or i > Config_ruleCount) { If (i = 0 Or i > Config_ruleCount)
{
Config_ruleCount += 1 Config_ruleCount += 1
i := Config_ruleCount i := Config_ruleCount
} }
@ -382,11 +390,11 @@ Config_saveSession(original, target)
#+i::Manager_getWindowList() #+i::Manager_getWindowList()
;; Window debugging ;; Window debugging
#^i::Manager_logViewWindowList() #^i::Debug_logViewWindowList()
#+^i::Manager_logManagedWindowList() #+^i::Debug_logManagedWindowList()
#^h::Manager_logHelp() #^h::Debug_logHelp()
#^[::Log_decDebugLevel() #^d::Debug_setLogLevel(-1)
#^]::Log_incDebugLevel() #^+d::Debug_setLogLevel(+1)
;; Layout management ;; Layout management
#Tab::View_setLayout(-1) #Tab::View_setLayout(-1)

167
src/Debug.ahk Normal file
View file

@ -0,0 +1,167 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0
*/
Debug_initLog(filename, level = 0, truncateFile = True)
{
Global Debug_logFilename, Debug_logLevel
Debug_logFilename := filename
Debug_logLevel := level
If truncateFile
If FileExist(Debug_logFilename)
FileDelete, %Debug_logFilename%
}
Debug_logHelp()
{
Debug_logMessage("Help Display", 0)
Debug_logMessage("Window list columns", 0, False)
Debug_logMessage(" ID - Windows ID. Unique, OS-assigned ID", 0, False)
Debug_logMessage(" H - Hidden. Whether bug.n thinks this window is hidden.", 0, False)
Debug_logMessage(" W - Windows active. This window is active according to Windows.", 0, False)
Debug_logMessage(" A - View active. This window is active according to bug.n.", 0, False)
Debug_logMessage(" F - Floating. This window should not be positioned and resized by the layout.", 0, False)
Debug_logMessage(" D - Decorated. Does the window have a title bar?", 0, False)
Debug_logMessage(" R - Responsive. Is responding to messages?", 0, False)
Debug_logMessage(" G - Ghost. Is this window a ghost of another hung window?", 0, False)
Debug_logMessage(" M - Monitor number.", 0, False)
Debug_logMessage(" Tags - Bit-mask of the views in which the window is active.", 0, False)
Debug_logMessage(" X - Windows X position.", 0, False)
Debug_logMessage(" Y - Windows Y position.", 0, False)
Debug_logMessage(" W - Windows width.", 0, False)
Debug_logMessage(" H - Windows height.", 0, False)
Debug_logMessage(" Style - Windows style.", 0, False)
Debug_logMessage(" Proc / Class / Title - Process/Class/Title of the window.", 0, False)
}
Debug_logManagedWindowList()
{
Local wndIds
Debug_logMessage("Window dump for manager")
Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False)
StringTrimRight, wndIds, Manager_managedWndIds, 1
Loop, PARSE, wndIds, `;
{
Debug_logWindowInfo(A_LoopField)
}
}
Debug_logMessage(text, level = 1, includeTimestamp = True)
{
Global Debug_logFilename, Debug_logLevel
If (Debug_logLevel >= level)
{
If includeTimestamp
{
FormatTime, time, , yyyy-MM-dd HH:mm:ss
text := time " " text
}
Else
text := " " text
FileAppend, %text%`r`n, %Debug_logFilename%
}
}
Debug_logViewWindowList()
{
Local v, wndIds
v := Monitor_#%Manager_aMonitor%_aView_#1
Debug_logMessage("Window dump for active view (" . Manager_aMonitor . ", " . v . ")")
Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
Debug_logWindowInfo(A_LoopField)
}
}
Debug_logWindowInfo(wndId)
{
Local aWndId, detect_state, text, v
Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus
Local wndClass, wndH, wndProc, wndStyle, wndTitle, wndW, wndX, wndY
detect_state := A_DetectHiddenWindows
DetectHiddenWindows, On
WinGet, aWndId, ID, A
If aWndId = %wndId%
isWinFocus := "*"
Else
isWinFocus := " "
v := Monitor_#%Manager_aMonitor%_aView_#1
If View_#%Manager_aMonitor%_#%v%_aWndId = %wndId%
isBugnActive := "*"
Else
isBugnActive := " "
WinGetTitle, wndTitle, ahk_id %wndId%
WinGetClass, wndClass, ahk_id %wndId%
WinGet, wndProc, ProcessName, ahk_id %wndId%
If InStr(Bar_hiddenWndIds, wndId)
isHidden := "*"
Else
isHidden := " "
If Manager_#%wndId%_isFloating
isFloating := "*"
Else
isFloating := " "
If Manager_#%wndId%_isDecorated
isDecorated := "*"
Else
isDecorated := " "
WinGet, wndStyle, Style, ahk_id %wndId%
WinGetPos, wndX, wndY, wndW, wndH, ahk_id %wndId%
If Manager_isGhost(wndId)
isGhost := "*"
Else
isGhost := " "
DetectHiddenWindows, %detect_state%
;; Intentionally don't detect hidden windows here to see what Manager_hungTest does
If Manager_isHung(wndId)
isResponsive := " "
Else
isResponsive := "*"
text := wndId "`t"
text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " "
text .= Manager_#%wndId%_monitor "`t" Manager_#%wndId%_tags "`t"
text .= wndX "`t" wndY "`t" wndW "`t" wndH "`t" wndStyle "`t" wndProc " / " wndClass " / " wndTitle
Debug_logMessage(text , 0, False)
}
Debug_setLogLevel(d)
{
Global Debug_logLevel
i := Debug_logLevel + d
If (i >= 0)
{
Debug_logLevel := i
If (i = 0)
Debug_logMessage("Logging disabled.", 0)
Else
Debug_logMessage("Log level set to " i ".")
}
}

View file

@ -39,11 +39,10 @@ SetWinDelay, 10
Main_setup() Main_setup()
Log_init(Main_logFile, False) Debug_initLog(Main_appDir "\log.txt", 0, False)
Log_msg("====== Initializing ======") Debug_logMessage("====== Initializing ======")
If 0 = 1 Config_filePath := Main_appDir "\Config.ini"
Config_filePath = %1%
Config_init() Config_init()
Menu, Tray, Tip, %NAME% %VERSION% Menu, Tray, Tip, %NAME% %VERSION%
@ -57,17 +56,17 @@ SetWinDelay, 10
ResourceMonitor_init() ResourceMonitor_init()
Manager_init() Manager_init()
Log_msg("====== Running ======") Debug_logMessage("====== Running ======", 0)
Return ;; end of the auto-execute section Return ;; end of the auto-execute section
;; Function & label definitions ;; Function & label definitions
Main_cleanup: Main_cleanup:
Log_msg("====== Cleaning up ======") Debug_logMessage("====== Cleaning up ======", 0)
If Config_autoSaveSession If Config_autoSaveSession
Config_saveSession(Config_filePath, Config_filePath) Config_saveSession(Config_filePath, Config_filePath)
Manager_cleanup() Manager_cleanup()
ResourceMonitor_cleanup() ResourceMonitor_cleanup()
Log_msg("====== Exiting ======") Debug_logMessage("====== Exiting bug.n ======", 0)
ExitApp ExitApp
Main_evalCommand(command) Main_evalCommand(command)
@ -242,7 +241,7 @@ Main_toggleBar:
Monitor_toggleBar() Monitor_toggleBar()
Return Return
#Include Log.ahk #include Debug.ahk
#Include List.ahk #Include List.ahk
#Include Bar.ahk #Include Bar.ahk
#Include Config.ahk #Include Config.ahk

View file

@ -87,11 +87,11 @@ Return
Manager_maintenance() { Manager_maintenance() {
Local tmp Local tmp
;Log_dbg_msg(2, "Manager_maintenance") ;Debug_logMessage("Manager_maintenance", 2)
; @todo: Check for changes to the layout. ; @todo: Check for changes to the layout.
;If Manager_layoutDirty { ;If Manager_layoutDirty {
;Log_msg("Saving layout state: " . Main_autoLayout) ;Debug_logMessage("Saving layout state: " . Main_autoLayout, 0)
Config_saveSession(Config_filaPath, Main_autoLayout) Config_saveSession(Config_filaPath, Main_autoLayout)
Manager_layoutDirty := 0 Manager_layoutDirty := 0
;} ;}
@ -100,21 +100,25 @@ Manager_maintenance() {
; @todo: Check for changes to windows. ; @todo: Check for changes to windows.
;If Manager_windowsDirty { ;If Manager_windowsDirty {
;Log_msg("Saving window state: " . Main_autoWindowState) ;Debug_logMessage("Saving window state: " . Main_autoWindowState, 0)
Manager_saveWindowState(Main_autoWindowState, Manager_monitorCount, Config_viewCount) Manager_saveWindowState(Main_autoWindowState, Manager_monitorCount, Config_viewCount)
Manager_windowsDirty := 0 Manager_windowsDirty := 0
;} ;}
} }
Manager_activateMonitor(d) { Manager_activateMonitor(d)
{
Local aView, aWndClass, aWndHeight, aWndId, aWndWidth, aWndX, aWndY, v, wndId Local aView, aWndClass, aWndHeight, aWndId, aWndWidth, aWndX, aWndY, v, wndId
If (Manager_monitorCount > 1) { If (Manager_monitorCount > 1)
{
aView := Monitor_#%Manager_aMonitor%_aView_#1 aView := Monitor_#%Manager_aMonitor%_aView_#1
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) { If WinExist("ahk_id" aWndId)
{
WinGetClass, aWndClass, ahk_id %aWndId% WinGetClass, aWndClass, ahk_id %aWndId%
If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui") And Not (aWndClass = "DesktopBackgroundClass") { If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui") And Not (aWndClass = "DesktopBackgroundClass")
{
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId% WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
If (Monitor_get(aWndX + aWndWidth / 2, aWndY + aWndHeight / 2) = Manager_aMonitor) If (Monitor_get(aWndX + aWndWidth / 2, aWndY + aWndHeight / 2) = Manager_aMonitor)
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
@ -124,7 +128,8 @@ Manager_activateMonitor(d) {
Manager_aMonitor := Manager_loop(Manager_aMonitor, d, 1, Manager_monitorCount) Manager_aMonitor := Manager_loop(Manager_aMonitor, d, 1, Manager_monitorCount)
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
wndId := View_#%Manager_aMonitor%_#%v%_aWndId wndId := View_#%Manager_aMonitor%_#%v%_aWndId
If Not (wndId And WinExist("ahk_id" wndId)) { If Not (wndId And WinExist("ahk_id" wndId))
{
If View_#%Manager_aMonitor%_#%v%_wndIds If View_#%Manager_aMonitor%_#%v%_wndIds
wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";")-1) wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";")-1)
Else Else
@ -134,7 +139,8 @@ Manager_activateMonitor(d) {
} }
} }
Manager_applyRules(wndId, ByRef isManaged, ByRef m, ByRef tags, ByRef isFloating, ByRef isDecorated, ByRef hideTitle) { Manager_applyRules(wndId, ByRef isManaged, ByRef m, ByRef tags, ByRef isFloating, ByRef isDecorated, ByRef hideTitle)
{
Local mouseX, mouseY, wndClass, wndHeight, wndStyle, wndTitle, wndWidth, wndX, wndY Local mouseX, mouseY, wndClass, wndHeight, wndStyle, wndTitle, wndWidth, wndX, wndY
Local rule0, rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9 Local rule0, rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9
@ -161,14 +167,17 @@ Manager_applyRules(wndId, ByRef isManaged, ByRef m, ByRef tags, ByRef isFloating
hideTitle := rule9 hideTitle := rule9
} }
} }
} Else { }
Else
{
isManaged := False isManaged := False
If wndTitle If wndTitle
hideTitle := True hideTitle := True
} }
} }
Manager_cleanup() { Manager_cleanup()
{
Local aWndId, m, ncmSize, ncm, wndIds Local aWndId, m, ncmSize, ncm, wndIds
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
@ -205,7 +214,8 @@ Manager_cleanup() {
; Reset windows position and size. ; Reset windows position and size.
Manager_showTaskBar := True Manager_showTaskBar := True
Loop, % Manager_monitorCount { Loop, % Manager_monitorCount
{
m := A_Index m := A_Index
Monitor_#%m%_showBar := False Monitor_#%m%_showBar := False
Monitor_getWorkArea(m) Monitor_getWorkArea(m)
@ -219,7 +229,8 @@ Manager_cleanup() {
; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html) ; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
} }
Manager_closeWindow() { Manager_closeWindow()
{
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
WinGetClass, aWndClass, ahk_id %aWndId% WinGetClass, aWndClass, ahk_id %aWndId%
WinGetTitle, aWndTitle, ahk_id %aWndId% WinGetTitle, aWndTitle, ahk_id %aWndId%
@ -227,7 +238,8 @@ Manager_closeWindow() {
Manager_winClose(aWndId) Manager_winClose(aWndId)
} }
Manager_getWindowInfo() { Manager_getWindowInfo()
{
Local text, v, aWndClass, aWndHeight, aWndId, aWndProcessName, aWndStyle, aWndTitle, aWndWidth, aWndX, aWndY Local text, v, aWndClass, aWndHeight, aWndId, aWndProcessName, aWndStyle, aWndTitle, aWndWidth, aWndX, aWndY
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
@ -247,7 +259,8 @@ Manager_getWindowInfo() {
Clipboard := text Clipboard := text
} }
Manager_getWindowList() { Manager_getWindowList()
{
Local text, v, aWndId, wndIds, aWndTitle Local text, v, aWndId, wndIds, aWndTitle
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
@ -268,113 +281,8 @@ Manager_getWindowList() {
Clipboard := text Clipboard := text
} }
Manager_logViewLayout() { Manager_lockWorkStation()
{
}
Manager_logWindowInfo( w ) {
Local v, wndId, isWinFocus, isBugnActive, isFloating, isHidden, isDecorated, isResponsive, isGhost, wndTitle, wndProc, wndClass, wndStyle, wndX, wndY, wndW, wndH, detect_state
detect_state := A_DetectHiddenWindows
DetectHiddenWindows, On
WinGet, wndId, ID, A
If wndId = %w%
isWinFocus := "*"
Else
isWinFocus := " "
v := Monitor_#%Manager_aMonitor%_aView_#1
If View_#%Manager_aMonitor%_#%v%_aWndId = %w%
isBugnActive := "*"
Else
isBugnActive := " "
WinGetTitle, wndTitle, ahk_id %w%
WinGetClass, wndClass, ahk_id %w%
WinGet, wndProc, ProcessName, ahk_id %w%
If InStr(Bar_hiddenWndIds, w)
isHidden := "*"
Else
isHidden := " "
If Manager_#%w%_isFloating
isFloating := "*"
Else
isFloating := " "
If Manager_#%w%_isDecorated
isDecorated := "*"
Else
isDecorated := " "
WinGet, wndStyle, Style, ahk_id %w%
WinGetPos, wndX, wndY, wndW, wndH, ahk_id %w%
If Manager_isGhost(w)
isGhost := "*"
Else
isGhost := " "
DetectHiddenWindows, %detect_state%
; Intentionally don't detect hidden windows here to see what Manager_hungTest does
If Manager_isHung(w)
isResponsive := " "
Else
isResponsive := "*"
Log_bare(w . "`t" . isHidden . " " isWinFocus . " " . isBugnActive . " " . isFloating . " " . isDecorated . " " . isResponsive . " " . isGhost . " " . Manager_#%w%_monitor . "`t" . Manager_#%w%_tags . "`t" . wndX . "`t" . wndY . "`t" . wndW . "`t" . wndH . "`t" . wndStyle . "`t" . wndProc . " / " . wndClass . " / " . wndTitle)
}
Manager_logHeader() {
Log_bare( "ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title")
}
Manager_logViewWindowList() {
Local text, v, aWndId, wndIds, aWndTitle
v := Monitor_#%Manager_aMonitor%_aView_#1
Log_msg( "Window dump for active view (" . Manager_aMonitor . ", " . v . ")" )
Manager_logHeader()
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
Manager_logWindowInfo( A_LoopField )
}
}
Manager_logManagedWindowList() {
Local wndIds
Log_msg( "Window dump for manager" )
Manager_logHeader()
StringTrimRight, wndIds, Manager_managedWndIds, 1
Loop, PARSE, wndIds, `;
{
Manager_logWindowInfo( A_LoopField)
}
}
Manager_logHelp() {
Log_msg("Help Display")
Log_bare("Window list columns")
Log_bare(" ID - Windows ID. Unique, OS-assigned ID")
Log_bare(" H - Hidden. Whether bug.n thinks this window is hidden.")
Log_bare(" W - Windows active. This window is active according to Windows.")
Log_bare(" A - View active. This window is active according to bug.n.")
Log_bare(" F - Floating. This window should not be positioned and resized by the layout.")
Log_bare(" D - Decorated. Does the window have a title bar?")
Log_bare(" R - Responsive. Is responding to messages?")
Log_bare(" G - Ghost. Is this window a ghost of another hung window?")
Log_bare(" M - Monitor number.")
Log_bare(" Tags - Bit-mask of the views in which the window is active.")
Log_bare(" X - Windows X position.")
Log_bare(" Y - Windows Y position.")
Log_bare(" W - Windows width.")
Log_bare(" H - Windows height.")
Log_bare(" Style - Windows style.")
Log_bare(" Proc / Class / Title - Process/Class/Title of the window.")
}
Manager_lockWorkStation() {
Global Config_shellMsgDelay Global Config_shellMsgDelay
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Policies\System, DisableLockWorkstation, 0 RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Policies\System, DisableLockWorkstation, 0
@ -385,7 +293,8 @@ Manager_lockWorkStation() {
} }
; Unambiguous: Re-use WIN+L as a hotkey in bug.n (http://www.autohotkey.com/community/viewtopic.php?p=500903&sid=eb3c7a119259b4015ff045ef80b94a81#p500903) ; Unambiguous: Re-use WIN+L as a hotkey in bug.n (http://www.autohotkey.com/community/viewtopic.php?p=500903&sid=eb3c7a119259b4015ff045ef80b94a81#p500903)
Manager_loop(index, increment, lowerBound, upperBound) { Manager_loop(index, increment, lowerBound, upperBound)
{
index += increment index += increment
If (index > upperBound) If (index > upperBound)
index := lowerBound index := lowerBound
@ -397,7 +306,8 @@ Manager_loop(index, increment, lowerBound, upperBound) {
Return, index Return, index
} }
Manager__setWinProperties(wndId, isManaged, m, tags, isDecorated, isFloating, hideTitle ) { Manager__setWinProperties(wndId, isManaged, m, tags, isDecorated, isFloating, hideTitle )
{
Local a Local a
If Not Instr(Manager_allWndIds, wndId ";") If Not Instr(Manager_allWndIds, wndId ";")
@ -449,7 +359,7 @@ Manager_manage(pm, pv, wndId) {
body := 0 body := 0
If Manager_isGhost( wndId ) { If Manager_isGhost( wndId ) {
Log_dbg_msg(2, "A window has given up the ghost (Ghost wndId: " . wndId . ")") Debug_logMessage("A window has given up the ghost (Ghost wndId: " . wndId . ")", 2)
; Ghosts need special attention. ; Ghosts need special attention.
; Say a quick prayer and try to reattach it to its body. ; Say a quick prayer and try to reattach it to its body.
body := Manager_findHung( wndId ) body := Manager_findHung( wndId )
@ -462,7 +372,7 @@ Manager_manage(pm, pv, wndId) {
hideTitle := InStr(Bar_hideTitleWndIds, body ";") hideTitle := InStr(Bar_hideTitleWndIds, body ";")
} }
Else { Else {
Log_dbg_msg(1, "No body could be found for ghost wndId: " . wndId) Debug_logMessage("No body could be found for ghost wndId: " . wndId, 1)
} }
} }
@ -583,7 +493,7 @@ Manager_onShellMessage(wParam, lParam) {
lParam := lParam+0 lParam := lParam+0
SetFormat, Integer, d SetFormat, Integer, d
Log_dbg_msg(2, "Manager_onShellMessage( wParam: " . wParam . ", lParam: " . lParam . " )") Debug_logMessage("Manager_onShellMessage( wParam: " . wParam . ", lParam: " . lParam . " )", 2)
WinGetClass, wndClass, ahk_id %lParam% WinGetClass, wndClass, ahk_id %lParam%
WinGetTitle, wndTitle, ahk_id %lParam% WinGetTitle, wndTitle, ahk_id %lParam%
@ -648,7 +558,7 @@ Manager_onShellMessage(wParam, lParam) {
wndId := SubStr(wndIds, 1, InStr(wndIds, ";") - 1) wndId := SubStr(wndIds, 1, InStr(wndIds, ";") - 1)
Loop, % Config_viewCount Loop, % Config_viewCount
If (Manager_#%wndId%_tags & 1 << A_Index - 1) { If (Manager_#%wndId%_tags & 1 << A_Index - 1) {
Log_dbg_msg(3, "Switching views because " . wndId . " is considered hidden and active") Debug_logMessage("Switching views because " . wndId . " is considered hidden and active", 3)
Manager_aMonitor := Manager_#%wndId%_monitor Manager_aMonitor := Manager_#%wndId%_monitor
Monitor_activateView(A_Index) Monitor_activateView(A_Index)
Break Break
@ -900,7 +810,7 @@ Manager__restoreWindowState(filename) {
} }
Else { Else {
excluded_view_set := excluded_view_set . view_list%vidx% excluded_view_set := excluded_view_set . view_list%vidx%
Log_msg("View (" . m . ", " . v . ") is no longer available (" . vidx . ")") Debug_logMessage("View (" . m . ", " . v . ") is no longer available (" . vidx . ")", 0)
} }
} }
Else If (SubStr(A_LoopReadLine, 1, 7) = "Window ") { Else If (SubStr(A_LoopReadLine, 1, 7) = "Window ") {
@ -908,8 +818,8 @@ Manager__restoreWindowState(filename) {
widx := widx + 1 widx := widx + 1
} }
;Log_msg("view_set: " . view_set) ;Debug_logMessage("view_set: " . view_set, 1)
;Log_msg("excluded_view_set: " . excluded_view_set) ;Debug_logMessage("excluded_view_set: " . excluded_view_set, 1)
candidate_set := List_new() candidate_set := List_new()
@ -917,7 +827,7 @@ Manager__restoreWindowState(filename) {
Loop, % (widx - 1) { Loop, % (widx - 1) {
StringSplit, items, wnds%A_Index%, `; StringSplit, items, wnds%A_Index%, `;
If ( items0 < 9 ) { If ( items0 < 9 ) {
Log_msg("Window '" . wnds%A_Index% . "' could not be processed due to parse error") Debug_logMessage("Window '" . wnds%A_Index% . "' could not be processed due to parse error", 0)
Continue Continue
} }
@ -930,7 +840,7 @@ Manager__restoreWindowState(filename) {
WinGet, wndProc, ProcessName, ahk_id %i% WinGet, wndProc, ProcessName, ahk_id %i%
DetectHiddenWindows, Off DetectHiddenWindows, Off
If Not ( items%j% = wndProc ) { If Not ( items%j% = wndProc ) {
Log_msg("Window ahk_id " . i . " process '" . wndProc . "' doesn't match expected '" . items%j% . "', forgetting this window") Debug_logMessage("Window ahk_id " . i . " process '" . wndProc . "' doesn't match expected '" . items%j% . "', forgetting this window", 0)
Continue Continue
} }
@ -941,10 +851,10 @@ Manager__restoreWindowState(filename) {
If ( items%j% ) If ( items%j% )
If ( InStr(view_set, i) = 0) { If ( InStr(view_set, i) = 0) {
If ( InStr(excluded_view_set, i) ) { If ( InStr(excluded_view_set, i) ) {
Log_msg("Window ahk_id " . i . " is being ignored because it no longer belongs to an active view") Debug_logMessage("Window ahk_id " . i . " is being ignored because it no longer belongs to an active view", 0)
} }
Else { Else {
Log_msg("Window ahk_id " . i . " is being ignored because it doesn't exist in any views") Debug_logMessage("Window ahk_id " . i . " is being ignored because it doesn't exist in any views", 0)
} }
Continue Continue
} }
@ -968,7 +878,7 @@ Manager__restoreWindowState(filename) {
List_append(candidate_set, i) List_append(candidate_set, i)
} }
;Log_msg("candidate_set: " . candidate_set) ;Debug_logMessage("candidate_set: " . candidate_set, 1)
; Set up all views. Must filter the window list by those from the candidate set. ; Set up all views. Must filter the window list by those from the candidate set.
Loop, % (vidx - 1) { Loop, % (vidx - 1) {
@ -1074,7 +984,7 @@ Manager_winActivate(wndId) {
DllCall("SetCursorPos", "Int", Round(Monitor_#%Manager_aMonitor%_x + Monitor_#%Manager_aMonitor%_width / 2), "Int", Round(Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height / 2)) DllCall("SetCursorPos", "Int", Round(Monitor_#%Manager_aMonitor%_x + Monitor_#%Manager_aMonitor%_width / 2), "Int", Round(Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height / 2))
} }
If Manager_isHung(wndId) { If Manager_isHung(wndId) {
Log_dbg_msg(2, "Manager_winActivate: Potentially hung window " . wndId) Debug_logMessage("Manager_winActivate: Potentially hung window " . wndId, 2)
Return 1 Return 1
} }
Else { Else {
@ -1089,7 +999,7 @@ Manager_winActivate(wndId) {
Manager_winMove(wndId, x, y, width, height) { Manager_winMove(wndId, x, y, width, height) {
If Manager_isHung(wndId) { If Manager_isHung(wndId) {
Log_dbg_msg(2, "Manager_winMove: Potentially hung window " . wndId) Debug_logMessage("Manager_winMove: Potentially hung window " . wndId, 2)
Return 1 Return 1
} }
Else Else
@ -1098,7 +1008,7 @@ Manager_winMove(wndId, x, y, width, height) {
WM_EXITSIZEMOVE = 0x0232 WM_EXITSIZEMOVE = 0x0232
SendMessage, WM_ENTERSIZEMOVE, , , , ahk_id %wndId% SendMessage, WM_ENTERSIZEMOVE, , , , ahk_id %wndId%
If ErrorLevel { If ErrorLevel {
Log_dbg_msg(2, "Manager_winMove: Potentially hung window " . wndId) Debug_logMessage("Manager_winMove: Potentially hung window " . wndId, 2)
Return 1 Return 1
} }
Else { Else {
@ -1110,7 +1020,7 @@ Manager_winMove(wndId, x, y, width, height) {
Manager_winHide(wndId) { Manager_winHide(wndId) {
If Manager_isHung(wndId) { If Manager_isHung(wndId) {
Log_dbg_msg(2, "Manager_winHide: Potentially hung window " . wndId) Debug_logMessage("Manager_winHide: Potentially hung window " . wndId, 2)
Return 1 Return 1
} }
Else { Else {
@ -1122,7 +1032,7 @@ Manager_winHide(wndId) {
Manager_winShow(wndId) { Manager_winShow(wndId) {
If Manager_isHung(wndId) { If Manager_isHung(wndId) {
Log_dbg_msg(2, "Manager_winShow: Potentially hung window " . wndId) Debug_logMessage("Manager_winShow: Potentially hung window " . wndId, 2)
Return 1 Return 1
} }
Else { Else {
@ -1134,7 +1044,7 @@ Manager_winShow(wndId) {
Manager_winClose(wndId) { Manager_winClose(wndId) {
If Manager_isHung(wndId) { If Manager_isHung(wndId) {
Log_dbg_msg(2, "Manager_winClose: Potentially hung window " . wndId) Debug_logMessage("Manager_winClose: Potentially hung window " . wndId, 2)
Return 1 Return 1
} }
Else { Else {
@ -1148,7 +1058,7 @@ Manager_winClose(wndId) {
Manager_winSet(type, value, wndId) { Manager_winSet(type, value, wndId) {
If Manager_isHung(wndId) { If Manager_isHung(wndId) {
Log_dbg_msg(2, "Manager_winSet: Potentially hung window " . wndId) Debug_logMessage("Manager_winSet: Potentially hung window " . wndId, 2)
Return 1 Return 1
} }
Else { Else {
@ -1178,7 +1088,7 @@ Manager_isHung(wndId) {
; This is only known to work on Windows 7 ; This is only known to work on Windows 7
Manager_findHung( ghostWnd ) { Manager_findHung( ghostWnd ) {
Local expectedTitle, expectedX, expectedY, expectedW, expectedH, wndTitle, wndX, wndY, wndW, wndH, wndIds Local expectedTitle, expectedX, expectedY, expectedW, expectedH, wndTitle, wndX, wndY, wndW, wndH, wndIds
;Log_dbg_msg(3, "Manager_findHung(" . ghostWnd . ")") ;Debug_logMessage("Manager_findHung(" . ghostWnd . ")", 3)
WinGetTitle, expectedTitle, ahk_id %ghostWnd% WinGetTitle, expectedTitle, ahk_id %ghostWnd%
StringReplace, expectedTitle, expectedTitle, " (Not Responding)", "" StringReplace, expectedTitle, expectedTitle, " (Not Responding)", ""
WinGetPos, expectedX, expectedY, expectedW, expectedH, ahk_id %ghostWnd% WinGetPos, expectedX, expectedY, expectedW, expectedH, ahk_id %ghostWnd%

View file

@ -41,7 +41,7 @@ Monitor_activateView(v) {
Else If (v = "<") Else If (v = "<")
v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount) v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount)
Log_dbg_msg(1, "Monitor_activateView(" . v . ") Manager_aMonitor: " . Manager_aMonitor . "; wndIds: " . View_#%m%_#%aView%_wndIds) Debug_logMessage("Monitor_activateView(" . v . ") Manager_aMonitor: " . Manager_aMonitor . "; wndIds: " . View_#%m%_#%aView%_wndIds, 1)
If (v <= 0) Or (v > Config_viewCount) Or Manager_hideShow If (v <= 0) Or (v > Config_viewCount) Or Manager_hideShow
Return Return

View file

@ -38,18 +38,18 @@ View_init(m, v) {
View_activateWindow(d) { View_activateWindow(d) {
Local aWndId, i, j, v, wndId, wndId0, wndIds, failure, direction Local aWndId, i, j, v, wndId, wndId0, wndIds, failure, direction
Log_dbg_msg(1, "View_activateWindow(" . d . ")") Debug_logMessage("View_activateWindow(" . d . ")", 1)
If (d = 0) If (d = 0)
Return Return
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
Log_dbg_bare(2, "Active Windows ID: " . aWndId) Debug_logMessage("Active Windows ID: " . aWndId, 2, False)
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
Log_dbg_bare(2, "View (" . v . ") wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds) Debug_logMessage("View (" . v . ") wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 2)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1 StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
StringSplit, wndId, wndIds, `; StringSplit, wndId, wndIds, `;
Log_dbg_bare(2, "wndId count: " . wndId0) Debug_logMessage("wndId count: " . wndId0, 2)
If (wndId0 > 1) { If (wndId0 > 1) {
If Manager_#%aWndId%_isFloating If Manager_#%aWndId%_isFloating
Manager_winSet("Bottom", "", aWndId) Manager_winSet("Bottom", "", aWndId)
@ -62,10 +62,10 @@ View_activateWindow(d) {
direction = 1 direction = 1
Else Else
direction = -1 direction = -1
Log_dbg_bare(2, "Current wndId index: " . i) Debug_logMessage("Current wndId index: " . i, 2, False)
j := Manager_loop(i, d, 1, wndId0) j := Manager_loop(i, d, 1, wndId0)
Loop, % wndId0 { Loop, % wndId0 {
Log_dbg_bare(2, "Next wndId index: " . j) Debug_logMessage("Next wndId index: " . j, 2, False)
wndId := wndId%j% wndId := wndId%j%
Manager_winSet("AlwaysOnTop", "On", wndId) Manager_winSet("AlwaysOnTop", "On", wndId)
Manager_winSet("AlwaysOnTop", "Off", wndId) Manager_winSet("AlwaysOnTop", "Off", wndId)
@ -135,7 +135,7 @@ View_delWnd(m, v, wndId) {
View_arrange(m, v) { View_arrange(m, v) {
Local fn, l, wndIds Local fn, l, wndIds
Log_dbg_msg(1, "View_arrange(" . m . ", " . v . ")") Debug_logMessage("View_arrange(" . m . ", " . v . ")", 1)
; All window actions are performed on independent windows. A delay won't help. ; All window actions are performed on independent windows. A delay won't help.
SetWinDelay, 0 SetWinDelay, 0
l := View_#%m%_#%v%_layout_#1 l := View_#%m%_#%v%_layout_#1
@ -441,7 +441,7 @@ View_draw_stack( arrName, off, len, dir, x, y, w, h, margin ) {
; margin - Number of pixels to put between the windows. ; margin - Number of pixels to put between the windows.
View_draw_row( arrName, off, len, dir, axis, x, y, w, h, margin ) { View_draw_row( arrName, off, len, dir, axis, x, y, w, h, margin ) {
Local base, inc, x_inc, y_inc, wHeight, wWidth Local base, inc, x_inc, y_inc, wHeight, wWidth
;Log_bare("View_draw_row(" . arrName . ", " . off . ", " . len . ", " . dir . ", " . axis . ", " . x . ", " . y . ", " . w . ", " . h . ", " . margin . ")") ;Debug_logMessage("View_draw_row(" . arrName . ", " . off . ", " . len . ", " . dir . ", " . axis . ", " . x . ", " . y . ", " . w . ", " . h . ", " . margin . ")", 0)
If (dir = 0) { If (dir = 0) {
; Left-to-right and top-to-bottom, depending on axis ; Left-to-right and top-to-bottom, depending on axis
base := off base := off
@ -515,7 +515,7 @@ View_arrange_tile(m, v, wndIds) {
StringTrimRight, wndIds, wndIds, 1 StringTrimRight, wndIds, wndIds, 1
StringSplit, View_arrange_tile_wndId, wndIds, `; StringSplit, View_arrange_tile_wndId, wndIds, `;
Log_dbg_msg(1, "View_arrange_tile: (" . View_arrange_tile_wndId0 . ") " . wndIds) Debug_logMessage("View_arrange_tile: (" . View_arrange_tile_wndId0 . ") " . wndIds, 1)
If (View_arrange_tile_wndId0 = 0) If (View_arrange_tile_wndId0 = 0)
Return Return
@ -558,7 +558,7 @@ View_arrange_tile(m, v, wndIds) {
secondary_areas := Ceil(msplit / dimAligned) secondary_areas := Ceil(msplit / dimAligned)
areas_remaining := secondary_areas areas_remaining := secondary_areas
windows_remaining := msplit windows_remaining := msplit
;Log_bare("msplit: " . msplit . "; layoutMX/Y: " . dimAligned . "; secondary_areas: " . secondary_areas . "; areas_remaining: " . areas_remaining . "; windows_remaining: " . windows_remaining) ;Debug_logMessage("msplit: " . msplit . "; layoutMX/Y: " . dimAligned . "; secondary_areas: " . secondary_areas . "; areas_remaining: " . areas_remaining . "; windows_remaining: " . windows_remaining, 0)
Loop, % secondary_areas { Loop, % secondary_areas {
View_split_region(Not (axis2 - 1), (1/areas_remaining), x1, y1, w1, h1, mx1, my1, mw1, mh1, x1, y1, w1, h1) View_split_region(Not (axis2 - 1), (1/areas_remaining), x1, y1, w1, h1, mx1, my1, mw1, mh1, x1, y1, w1, h1)
draw_windows := dimAligned draw_windows := dimAligned