initial fork commit
This commit is contained in:
parent
914c47c506
commit
0f6580b372
7 changed files with 563 additions and 80 deletions
28
CHANGES.md
Normal file
28
CHANGES.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Changes
|
||||
Required by license to disclose changes.
|
||||
|
||||
## Bar
|
||||
* Disabled shebang
|
||||
* Icon support
|
||||
* Time and date can be combined and clicked on to change between states
|
||||
* MusicBee integration via MusicBeeIPC plugin
|
||||
* Proper text resizing
|
||||
* Clicking items no longer repositions mouse cursor
|
||||
* Bar elements no longer have progress element
|
||||
* Time has optional binary clock mode
|
||||
|
||||
## Config
|
||||
* Renamed `Config_readinMemoryUsage` to `Config_readinRam`
|
||||
* Added `Config_readinMusic`, only supports MusicBee currently
|
||||
* Added `Config_readinTimeBinary` for enabling binary clock
|
||||
* Removed `Config_readinDiskLoad` and `Config_readinNetworkLoad`
|
||||
* Added `Config_barItemSpacing`, `Config_barIconSpacing` and `Config_iconFontYOffset`
|
||||
* Added `Config_barIcons`: `<time>;<date>;<ram>;<cpu>;<battery>;<volume>;<music>`
|
||||
* Added `Config_combineDateAndTime`
|
||||
|
||||
## ResourceMonitor
|
||||
* RAM is now in MB
|
||||
* Different CPU load getting functions
|
||||
|
||||
## Window
|
||||
* Implement [#283](https://github.com/fuhsjr00/bug.n/pull/283)
|
404
src/Bar.ahk
404
src/Bar.ahk
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
bug.n -- tiling window management
|
||||
Copyright (c) 2010-2019 Joshua Fuhs, joten
|
||||
|
||||
|
@ -43,7 +43,7 @@ Bar_init(m) {
|
|||
Debug_logMessage("DEBUG[6] Bar_init(): Gui, " . GuiN . ": Default", 6)
|
||||
Gui, %GuiN%: Default
|
||||
Gui, Destroy
|
||||
Gui, +AlwaysOnTop -Caption +LabelBar_Gui +LastFound +ToolWindow
|
||||
Gui, -Caption +LabelBar_Gui +LastFound +ToolWindow
|
||||
Gui, Color, %Config_backColor_#1_#3%
|
||||
Gui, Font, c%Config_fontColor_#1_#3% s%Config_fontSize%, %Config_fontName%
|
||||
|
||||
|
@ -61,47 +61,65 @@ Bar_init(m) {
|
|||
x1 += w
|
||||
|
||||
;; The x-position and width of the sub-windows right of the window title are set from the right.
|
||||
;; <view>;<layout>;<title>;<shebang>;<time>;<date>;<anyText>;<batteryStatus>;<volumeLevel>
|
||||
color := "4"
|
||||
id := "shebang"
|
||||
text := " #! "
|
||||
;; <view>;<layout>;<title>;<shebang>;<time>;<date>;<anyText>;<battery>;<volumeLevel>
|
||||
;color := "4"
|
||||
;id := "shebang"
|
||||
;text := " #! "
|
||||
color := ""
|
||||
id := ""
|
||||
text := ""
|
||||
If Config_readinTime {
|
||||
color .= ";5"
|
||||
id .= ";time"
|
||||
text .= "; " . Config_readinTimeFormat . " "
|
||||
color .= "4"
|
||||
id .= "time"
|
||||
text .= "" . Config_readinTimeFormat
|
||||
}
|
||||
If Config_readinDate {
|
||||
color .= ";6"
|
||||
If (Config_readinDate And !Config_combineDateAndTime) {
|
||||
color .= ";5"
|
||||
id .= ";date"
|
||||
text .= "; " . Config_readinDateFormat . " "
|
||||
text .= ";" . Config_readinDateFormat
|
||||
}
|
||||
If Config_readinVolume {
|
||||
color .= ";9"
|
||||
id .= ";volume"
|
||||
text .= "; VOL: ???% "
|
||||
text .= ";VOL: ???%"
|
||||
}
|
||||
anyText := Config_readinAny()
|
||||
If anyText {
|
||||
If Config_readinRam {
|
||||
color .= ";6"
|
||||
id .= ";ram"
|
||||
text .= ";" . ResourceMonitor_getRamText()
|
||||
}
|
||||
If Config_readinCpu {
|
||||
color .= ";7"
|
||||
id .= ";anyText"
|
||||
text .= ";" anyText
|
||||
id .= ";cpu"
|
||||
text .= ";" . ResourceMonitor_getCpuText()
|
||||
}
|
||||
If Config_readinBat {
|
||||
color .= ";8"
|
||||
id .= ";batteryStatus"
|
||||
text .= "; BAT: ???% "
|
||||
id .= ";battery"
|
||||
text .= ";BAT: ???%"
|
||||
}
|
||||
If Config_readinMusic {
|
||||
color .= ";10"
|
||||
id .= ";music"
|
||||
text .= ";" . MusicBee_GetNowPlaying()
|
||||
}
|
||||
StringSplit, color, color, `;
|
||||
StringSplit, id, id, `;
|
||||
StringSplit, text, text, `;
|
||||
Loop, % id0 {
|
||||
If (id%A_Index% = "shebang")
|
||||
elemId := id%A_Index%
|
||||
If (elemId = "shebang")
|
||||
Gui, -Disabled
|
||||
w := Bar_getTextWidth(text%A_Index%)
|
||||
x2 -= w
|
||||
titleWidth -= w
|
||||
i := color%A_Index%
|
||||
Bar_addElement(m, id%A_Index%, text%A_Index%, x2, y1, w, Config_backColor_#1_#%i%, Config_foreColor_#1_#%i%, Config_fontColor_#1_#%i%)
|
||||
iconIndex := i - 3
|
||||
icon := Config_barIcon_#%iconIndex%
|
||||
iconId := % elemId "_icon"
|
||||
Bar_addElement(m, elemId, text%A_Index%, x2, y1, wndWidth, Config_backColor_#1_#%i%, Config_foreColor_#1_#%i%, Config_fontColor_#1_#%i%)
|
||||
Bar_addElement(m, iconId, icon, x2, y1, wndWidth, Config_backColor_#1_#%i%, Config_foreColor_#1_#%i%, Config_fontColor_#1_#%i%, Config_iconFontSize, Config_iconFontName)
|
||||
GuiControl, -Center, Bar_#%m%_%elemId%
|
||||
}
|
||||
|
||||
;; Window title (remaining space)
|
||||
|
@ -161,6 +179,9 @@ Bar_init(m) {
|
|||
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)
|
||||
}
|
||||
|
||||
Bar_BinaryClockChars := ["⠀","⠈","⠐","⠘","⠠","⠨","⠰","⠸","⢀","⢈","⠁","⠉","⠑","⠙","⠡","⠩","⠱","⠹","⢁","⢉","⠂","⠊","⠒","⠚","⠢","⠪","⠲","⠺","⢂","⢊","⠃","⠋","⠓","⠛","⠣","⠫","⠳","⠻","⢃","⢋","⠄","⠌","⠔","⠜","⠤","⠬","⠴","⠼","⢄","⢌","⠅","⠍","⠕","⠝","⠥","⠭","⠵","⠽","⢅","⢍"]
|
||||
Bar_TimeDateState := 0
|
||||
}
|
||||
|
||||
Bar_initCmdGui()
|
||||
|
@ -188,15 +209,23 @@ Bar_initCmdGui()
|
|||
Gui, Show, Hide w%Bar_#0_#0W% h%Bar_#0_#0H%, %wndTitle%
|
||||
}
|
||||
|
||||
Bar_addElement(m, id, text, x, y1, width, backColor, foreColor, fontColor) {
|
||||
Bar_addElement(m, id, text, x, y1, width, backColor, foreColor, fontColor, fontSize="", fontName="") {
|
||||
Local y2
|
||||
|
||||
if (fontSize == "") {
|
||||
fontSize = %Config_fontSize%
|
||||
}
|
||||
if (fontName == "") {
|
||||
fontName = %Config_fontName%
|
||||
}
|
||||
|
||||
y2 := y1 + (Bar_ctrlHeight - Bar_textHeight) / 2
|
||||
|
||||
Gui, Add, Text, x%x% y%y1% w%width% h%Bar_ctrlHeight% BackgroundTrans vBar_#%m%_%id%_event gBar_GuiClick,
|
||||
Gui, Add, Progress, x%x% y%y1% w%width% h%Bar_ctrlHeight% Background%backColor% c%foreColor% vBar_#%m%_%id%_highlighted
|
||||
GuiControl, , Bar_#%m%_%id%_highlighted, 100
|
||||
Gui, Font, c%fontColor%
|
||||
Gui, Add, Text, x%x% y%y2% w%width% h%Bar_textHeight% BackgroundTrans Center vBar_#%m%_%id%, %text%
|
||||
;Gui, Add, Progress, x%x% y%y1% w%width% h%Bar_ctrlHeight% Background%backColor% c%foreColor% vBar_#%m%_%id%_highlighted
|
||||
;GuiControl, , Bar_#%m%_%id%_highlighted, 100
|
||||
Gui, Font, c%fontColor% s%fontSize%, %fontName%
|
||||
Gui, Add, Text, x%x% y%y2% w%width% h%Bar_textHeight% BackgroundTrans Center vBar_#%m%_%id% HwndBar_#%m%_%id%_hwnd, %text%
|
||||
}
|
||||
|
||||
Bar_cmdGuiEnter:
|
||||
|
@ -289,14 +318,46 @@ Bar_getTextWidth(x, reverse=False)
|
|||
Return, textWidth
|
||||
}
|
||||
|
||||
Bar_getTrueTextWidth(controlHwnd, newText) {
|
||||
dc := DllCall("GetDC", "Ptr", controlHwnd)
|
||||
|
||||
; 0x31 = WM_GETFONT
|
||||
SendMessage 0x31,,,, ahk_id %controlHwnd%
|
||||
hFont := ErrorLevel
|
||||
oldFont := 0
|
||||
if (hFont != "FAIL")
|
||||
oldFont := DllCall("SelectObject", "Ptr", dc, "Ptr", hFont)
|
||||
|
||||
VarSetCapacity(rect, 16, 0)
|
||||
; 0x440 = DT_CALCRECT | DT_EXPANDTABS
|
||||
h := DllCall("DrawText", "Ptr", dc, "Ptr", &newText, "Int", -1, "Ptr", &rect, "UInt", 0x440)
|
||||
; width = rect.right - rect.left
|
||||
w := NumGet(rect, 8, "Int") - NumGet(rect, 0, "Int")
|
||||
|
||||
if oldFont
|
||||
DllCall("SelectObject", "Ptr", dc, "Ptr", oldFont)
|
||||
DllCall("ReleaseDC", "Ptr", controlHwnd, "Ptr", dc)
|
||||
|
||||
return w
|
||||
}
|
||||
|
||||
Bar_GuiClick:
|
||||
Manager_winActivate(Bar_aWndId)
|
||||
If (A_GuiEvent = "Normal") {
|
||||
If (SubStr(A_GuiControl, -13) = "_shebang_event") {
|
||||
If Not Bar_cmdGuiIsVisible
|
||||
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_", False, 6) - 6) = Manager_aMonitor)
|
||||
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_", False, 6) - 6))
|
||||
Bar_toggleCommandGui()
|
||||
;If (SubStr(A_GuiControl, -13) = "_shebang_event") {
|
||||
; If Not Bar_cmdGuiIsVisible
|
||||
; If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_", False, 6) - 6) = Manager_aMonitor)
|
||||
; Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_", False, 6) - 6))
|
||||
; Bar_toggleCommandGui()
|
||||
;} Else
|
||||
If (SubStr(A_GuiControl, -10) = "_time_event") {
|
||||
If (Config_combineDateAndTime) {
|
||||
If (Bar_TimeDateState == 0) {
|
||||
Bar_TimeDateState := 1
|
||||
} Else {
|
||||
Bar_TimeDateState := 0
|
||||
}
|
||||
}
|
||||
} Else {
|
||||
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_", False, 6) - 6) = Manager_aMonitor)
|
||||
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_", False, 6) - 6))
|
||||
|
@ -397,12 +458,13 @@ Bar_updateStatic(m) {
|
|||
}
|
||||
|
||||
Bar_updateStatus() {
|
||||
Local anyText, bat1, bat2, bat3, GuiN, m, mute, time, vol
|
||||
Local bat1, bat2, bat3, GuiN, m, mute, time, vol, hours, minutes, seconds, text, textWidth, statusWidth, iconWidth, iconY
|
||||
|
||||
iconY := (Bar_ctrlHeight - Bar_textHeight) / 2 - %Config_iconFontYOffset%
|
||||
|
||||
anyText := Config_readinAny()
|
||||
If Config_readinBat {
|
||||
ResourceMonitor_getBatteryStatus(bat1, bat2)
|
||||
bat3 := SubStr(" " bat1, -2)
|
||||
bat3 := bat1
|
||||
}
|
||||
If Config_readinVolume {
|
||||
SoundGet, vol, MASTER, VOLUME
|
||||
|
@ -415,49 +477,236 @@ Bar_updateStatus() {
|
|||
GuiN := (m - 1) + 1
|
||||
Debug_logMessage("DEBUG[6] Bar_updateStatus(): Gui, " . GuiN . ": Default", 6)
|
||||
Gui, %GuiN%: Default
|
||||
If Config_readinBat {
|
||||
If (bat1 < 10) And (bat2 = "off") {
|
||||
;; Change the color, if the battery level is below 10%
|
||||
GuiControl, +Background%Config_backColor_#3_#8% +c%Config_foreColor_#3_#8%, Bar_#%m%_batteryStatus_highlighted
|
||||
GuiControl, +c%Config_fontColor_#3_#8%, Bar_#%m%_batteryStatus
|
||||
} Else If (bat2 = "off") {
|
||||
;; Change the color, if the pc is not plugged in
|
||||
GuiControl, +Background%Config_backColor_#2_#8% +c%Config_foreColor_#2_#8%, Bar_#%m%_batteryStatus_highlighted
|
||||
GuiControl, +c%Config_fontColor_#2_#8%, Bar_#%m%_batteryStatus
|
||||
|
||||
statusWidth := Monitor_#%m%_barWidth
|
||||
statusWidth -= %Config_barItemSpacing%
|
||||
|
||||
If Config_readinTime {
|
||||
If Config_readinTimeBinary {
|
||||
FormatTime, hours,, H
|
||||
FormatTime, minutes,, m
|
||||
FormatTime, seconds,, s
|
||||
If (Config_combineDateAndTime) {
|
||||
If (Bar_TimeDateState == 0) {
|
||||
time := % Bar_BinaryClockChars[hours + 1] " " Bar_BinaryClockChars[minutes + 1] " " Bar_BinaryClockChars[seconds + 1]
|
||||
} Else {
|
||||
GuiControl, +Background%Config_backColor_#1_#8% +c%Config_foreColor_#1_#8%, Bar_#%m%_batteryStatus_highlighted
|
||||
GuiControl, +c%Config_fontColor_#1_#8%, Bar_#%m%_batteryStatus
|
||||
FormatTime, time, , % Config_readinDateFormat
|
||||
}
|
||||
GuiControl, , Bar_#%m%_batteryStatus_highlighted, %bat3%
|
||||
GuiControl, , Bar_#%m%_batteryStatus, % " BAT: " bat3 "% "
|
||||
} else {
|
||||
time := % Bar_BinaryClockChars[hours + 1] " " Bar_BinaryClockChars[minutes + 1] " " Bar_BinaryClockChars[seconds + 1]
|
||||
}
|
||||
} Else {
|
||||
If (Config_combineDateAndTime) {
|
||||
If (Bar_TimeDateState == 0) {
|
||||
FormatTime, time, , % Config_readinTimeFormat
|
||||
} Else {
|
||||
FormatTime, time, , % Config_readinDateFormat
|
||||
}
|
||||
} else {
|
||||
FormatTime, time, , % Config_readinTimeFormat
|
||||
}
|
||||
}
|
||||
textWidth := Bar_getTrueTextWidth(Bar_#%m%_time_hwnd, time)
|
||||
statusWidth -= textWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_time, % time
|
||||
GuiControl, Move, Bar_#%m%_time, % "w" textWidth " x" statusWidth
|
||||
GuiControl, Move, Bar_#%m%_time_event, % "w" textWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_time_highlighted, % "w" textWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barIconSpacing%
|
||||
|
||||
If (Config_combineDateAndTime) {
|
||||
If (Bar_TimeDateState == 0) {
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_time_icon_hwnd, Config_barIcon_#1)
|
||||
} Else {
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_time_icon_hwnd, Config_barIcon_#2)
|
||||
}
|
||||
} Else {
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_time_icon_hwnd, Config_barIcon_#1)
|
||||
}
|
||||
statusWidth -= iconWidth
|
||||
|
||||
If (Config_combineDateAndTime) {
|
||||
If (Bar_TimeDateState == 0) {
|
||||
GuiControl,, Bar_#%m%_time_icon, %Config_barIcon_#1%
|
||||
} Else {
|
||||
GuiControl,, Bar_#%m%_time_icon, %Config_barIcon_#2%
|
||||
}
|
||||
} Else {
|
||||
GuiControl,, Bar_#%m%_time_icon, %Config_barIcon_#1%
|
||||
}
|
||||
GuiControl, Move, Bar_#%m%_time_icon, % "w" iconWidth " x" statusWidth " h" Bar_ctrlHeight " y" iconY
|
||||
GuiControl, Move, Bar_#%m%_time_icon_event, % "w" iconWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_time_icon_highlighted, % "w" iconWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barItemSpacing%
|
||||
}
|
||||
If Config_readinDate And !Config_combineDateAndTime {
|
||||
FormatTime, time, , % Config_readinDateFormat
|
||||
textWidth := Bar_getTrueTextWidth(Bar_#%m%_date_hwnd, time)
|
||||
statusWidth -= textWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_date, % time
|
||||
GuiControl, Move, Bar_#%m%_date, % "w" textWidth " x" statusWidth
|
||||
GuiControl, Move, Bar_#%m%_date_event, % "w" textWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_date_highlighted, % "w" textWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barIconSpacing%
|
||||
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_date_icon_hwnd, Config_barIcon_#2)
|
||||
statusWidth -= iconWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_date_icon, %Config_barIcon_#2%
|
||||
GuiControl, Move, Bar_#%m%_date_icon, % "w" iconWidth " x" statusWidth " h" Bar_ctrlHeight " y" iconY
|
||||
GuiControl, Move, Bar_#%m%_date_icon_event, % "w" iconWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_date_icon_highlighted, % "w" iconWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barItemSpacing%
|
||||
}
|
||||
If anyText
|
||||
GuiControl, , Bar_#%m%_anyText, % anyText
|
||||
If Config_readinVolume {
|
||||
If (mute = "On") {
|
||||
;; Change the color, if the mute is on
|
||||
GuiControl, +Background%Config_backColor_#1_#9% +c%Config_foreColor_#1_#9%, Bar_#%m%_volume_highlighted
|
||||
GuiControl, +c%Config_fontColor_#1_#9%, Bar_#%m%_volume
|
||||
} Else {
|
||||
GuiControl, +Background%Config_backColor_#2_#9% +c%Config_foreColor_#2_#9%, Bar_#%m%_volume_highlighted
|
||||
;GuiControl, +Background%Config_backColor_#1_#9% +c%Config_foreColor_#1_#9%, Bar_#%m%_volume_highlighted
|
||||
GuiControl, +c%Config_fontColor_#2_#9%, Bar_#%m%_volume
|
||||
GuiControl, +c%Config_fontColor_#2_#9%, Bar_#%m%_volume_icon
|
||||
} Else {
|
||||
;GuiControl, +Background%Config_backColor_#2_#9% +c%Config_foreColor_#2_#9%, Bar_#%m%_volume_highlighted
|
||||
GuiControl, +c%Config_fontColor_#1_#9%, Bar_#%m%_volume
|
||||
GuiControl, +c%Config_fontColor_#1_#9%, Bar_#%m%_volume_icon
|
||||
}
|
||||
GuiControl, , Bar_#%m%_volume_highlighted, %vol%
|
||||
GuiControl, , Bar_#%m%_volume, % " VOL: " SubStr(" " vol, -2) "% "
|
||||
|
||||
text := % vol "%"
|
||||
textWidth := Bar_getTrueTextWidth(Bar_#%m%_volume_hwnd, text)
|
||||
statusWidth -= textWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_volume, % text
|
||||
GuiControl, Move, Bar_#%m%_volume, % "w" textWidth " x" statusWidth
|
||||
GuiControl, Move, Bar_#%m%_volume_event, % "w" textWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_volume_highlighted, % "w" textWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barIconSpacing%
|
||||
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_volume_icon_hwnd, Config_barIcon_#6)
|
||||
statusWidth -= iconWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_volume_icon, %Config_barIcon_#6%
|
||||
GuiControl, Move, Bar_#%m%_volume_icon, % "w" iconWidth " x" statusWidth " h" Bar_ctrlHeight " y" iconY
|
||||
GuiControl, Move, Bar_#%m%_volume_icon_event, % "w" iconWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_volume_icon_highlighted, % "w" iconWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barItemSpacing%
|
||||
}
|
||||
If Config_readinDate {
|
||||
FormatTime, time, , % Config_readinDateFormat
|
||||
GuiControl, , Bar_#%m%_date, % time
|
||||
If Config_readinRam {
|
||||
text := ResourceMonitor_getRamText()
|
||||
textWidth := Bar_getTrueTextWidth(Bar_#%m%_ram_hwnd, text)
|
||||
statusWidth -= textWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_ram, % text
|
||||
GuiControl, Move, Bar_#%m%_ram, % "w" textWidth " x" statusWidth
|
||||
GuiControl, Move, Bar_#%m%_ram_event, % "w" textWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_ram_highlighted, % "w" textWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barIconSpacing%
|
||||
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_ram_icon_hwnd, Config_barIcon_#3)
|
||||
statusWidth -= iconWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_ram_icon, %Config_barIcon_#3%
|
||||
GuiControl, Move, Bar_#%m%_ram_icon, % "w" iconWidth " x" statusWidth " h" Bar_ctrlHeight " y" iconY
|
||||
GuiControl, Move, Bar_#%m%_ram_icon_event, % "w" iconWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_ram_icon_highlighted, % "w" iconWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barItemSpacing%
|
||||
}
|
||||
If Config_readinTime {
|
||||
FormatTime, time, , % Config_readinTimeFormat
|
||||
GuiControl, , Bar_#%m%_time, % time
|
||||
If Config_readinCpu {
|
||||
text := ResourceMonitor_getCpuText()
|
||||
textWidth := Bar_getTrueTextWidth(Bar_#%m%_cpu_hwnd, text)
|
||||
statusWidth -= textWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_cpu, % text
|
||||
GuiControl, Move, Bar_#%m%_cpu, % "w" textWidth " x" statusWidth
|
||||
GuiControl, Move, Bar_#%m%_cpu_event, % "w" textWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_cpu_highlighted, % "w" textWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barIconSpacing%
|
||||
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_cpu_icon_hwnd, Config_barIcon_#4)
|
||||
statusWidth -= iconWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_cpu_icon, %Config_barIcon_#4%
|
||||
GuiControl, Move, Bar_#%m%_cpu_icon, % "w" iconWidth " x" statusWidth " h" Bar_ctrlHeight " y" iconY
|
||||
GuiControl, Move, Bar_#%m%_cpu_icon_event, % "w" iconWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_cpu_icon_highlighted, % "w" iconWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barItemSpacing%
|
||||
}
|
||||
If Config_readinBat {
|
||||
If (bat1 < 10) And (bat2 = "off") {
|
||||
;; Change the color, if the battery level is below 10%
|
||||
;GuiControl, +Background%Config_backColor_#3_#8% +c%Config_foreColor_#3_#8%, Bar_#%m%_battery_highlighted
|
||||
GuiControl, +c%Config_fontColor_#3_#8%, Bar_#%m%_battery
|
||||
} Else If (bat2 = "off") {
|
||||
;; Change the color, if the pc is not plugged in
|
||||
;GuiControl, +Background%Config_backColor_#2_#8% +c%Config_foreColor_#2_#8%, Bar_#%m%_battery_highlighted
|
||||
GuiControl, +c%Config_fontColor_#2_#8%, Bar_#%m%_battery
|
||||
} Else {
|
||||
;GuiControl, +Background%Config_backColor_#1_#8% +c%Config_foreColor_#1_#8%, Bar_#%m%_battery_highlighted
|
||||
GuiControl, +c%Config_fontColor_#1_#8%, Bar_#%m%_battery
|
||||
}
|
||||
|
||||
text := % bat3 "%"
|
||||
textWidth := Bar_getTrueTextWidth(Bar_#%m%_battery_hwnd, text)
|
||||
statusWidth -= textWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_battery, % text
|
||||
GuiControl, Move, Bar_#%m%_battery, % "w" textWidth " x" statusWidth
|
||||
GuiControl, Move, Bar_#%m%_battery_event, % "w" textWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_battery_highlighted, % "w" textWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barIconSpacing%
|
||||
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_battery_icon_hwnd, Config_barIcon_#5)
|
||||
statusWidth -= iconWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_battery_icon, %Config_barIcon_#5%
|
||||
GuiControl, Move, Bar_#%m%_battery_icon, % "w" iconWidth " x" statusWidth " h" Bar_ctrlHeight " y" iconY
|
||||
GuiControl, Move, Bar_#%m%_battery_icon_event, % "w" iconWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_battery_icon_highlighted, % "w" iconWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barItemSpacing%
|
||||
}
|
||||
If Config_readinMusic {
|
||||
text := MusicBee_GetNowPlaying()
|
||||
textWidth := Bar_getTrueTextWidth(Bar_#%m%_music_hwnd, text)
|
||||
statusWidth -= textWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_music, % text
|
||||
GuiControl, Move, Bar_#%m%_music, % "w" textWidth " x" statusWidth
|
||||
GuiControl, Move, Bar_#%m%_music_event, % "w" textWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_music_highlighted, % "w" textWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barIconSpacing%
|
||||
|
||||
if (text == "") {
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_music_icon_hwnd, "")
|
||||
} else {
|
||||
iconWidth := Bar_getTrueTextWidth(Bar_#%m%_music_icon_hwnd, Config_barIcon_#7)
|
||||
}
|
||||
statusWidth -= iconWidth
|
||||
|
||||
GuiControl,, Bar_#%m%_music_icon, %Config_barIcon_#7%
|
||||
GuiControl, Move, Bar_#%m%_music_icon, % "w" iconWidth " x" statusWidth " h" Bar_ctrlHeight " y" iconY
|
||||
GuiControl, Move, Bar_#%m%_music_icon_event, % "w" iconWidth " x" statusWidth
|
||||
;GuiControl, Move, Bar_#%m%_music_icon_highlighted, % "w" iconWidth " x" statusWidth
|
||||
|
||||
statusWidth -= %Config_barItemSpacing%
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bar_updateTitle() {
|
||||
Local aWndId, aWndTitle, content, GuiN, i, title
|
||||
Local aWndId, aWndTitle, content, GuiN, i, title, titleWidth, barWidth, titleX
|
||||
|
||||
WinGet, aWndId, ID, A
|
||||
WinGetTitle, aWndTitle, ahk_id %aWndId%
|
||||
|
@ -467,24 +716,33 @@ Bar_updateTitle() {
|
|||
aWndTitle := "~ " aWndTitle
|
||||
If (Manager_monitorCount > 1)
|
||||
aWndTitle := "[" Manager_aMonitor "] " aWndTitle
|
||||
title := " " . aWndTitle . " "
|
||||
|
||||
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
|
||||
StringLeft, title, aWndTitle, i
|
||||
title := " " . title . " ... "
|
||||
}
|
||||
title := aWndTitle
|
||||
|
||||
;If (Bar_getTextWidth(title) > 768) {
|
||||
; ;; Shorten the window title if its length exceeds the width of the bar
|
||||
; i := Bar_getTextWidth(Bar_#%Manager_aMonitor%_titleWidth, True) - 6
|
||||
; StringLeft, title, aWndTitle, i
|
||||
; title := " " . title . " ... "
|
||||
;}
|
||||
StringReplace, title, title, &, &&, All ;; Special character '&', which would underline the next letter.
|
||||
|
||||
|
||||
Loop, % Manager_monitorCount {
|
||||
barWidth := Monitor_#%A_Index%_barWidth
|
||||
titleWidth := Bar_getTrueTextWidth(Bar_#%A_Index%_title_hwnd, title)
|
||||
titleX := barWidth / 2 - titleWidth / 2
|
||||
|
||||
GuiN := (A_Index - 1) + 1
|
||||
Debug_logMessage("DEBUG[6] Bar_updateTitle(): Gui, " . GuiN . ": Default", 6)
|
||||
Gui, %GuiN%: Default
|
||||
GuiControlGet, content, , Bar_#%A_Index%_title
|
||||
If (A_Index = Manager_aMonitor) {
|
||||
If Not (content = title)
|
||||
GuiControl, , Bar_#%A_Index%_title, % title
|
||||
GuiControl,, Bar_#%A_Index%_title, % title
|
||||
GuiControl, Move, Bar_#%A_Index%_title, % "w" titleWidth "x" titleX
|
||||
GuiControl, Move, Bar_#%A_Index%_title_event, % "w" titleWidth "x" titleX
|
||||
GuiControl, Move, Bar_#%A_Index%_title_highlighted, % "w" titleWidth "x" titleX
|
||||
} Else If Not (content = "")
|
||||
GuiControl, , Bar_#%A_Index%_title,
|
||||
}
|
||||
|
@ -503,18 +761,18 @@ Bar_updateView(m, v) {
|
|||
|
||||
If (v = Monitor_#%m%_aView_#1) {
|
||||
;; Set foreground/background colors if the view is the current view.
|
||||
GuiControl, +Background%Config_backColor_#2_#1% +c%Config_foreColor_#2_#1%, Bar_#%m%_view_#%v%_highlighted
|
||||
;GuiControl, +Background%Config_backColor_#2_#1% +c%Config_foreColor_#2_#1%, Bar_#%m%_view_#%v%_highlighted
|
||||
GuiControl, +c%Config_fontColor_#2_#1%, Bar_#%m%_view_#%v%
|
||||
} Else {
|
||||
;; Set foreground/background colors.
|
||||
GuiControl, +Background%Config_backColor_#1_#1% +c%Config_foreColor_#1_#1%, Bar_#%m%_view_#%v%_highlighted
|
||||
;GuiControl, +Background%Config_backColor_#1_#1% +c%Config_foreColor_#1_#1%, Bar_#%m%_view_#%v%_highlighted
|
||||
GuiControl, +c%Config_fontColor_#1_#1%, Bar_#%m%_view_#%v%
|
||||
}
|
||||
|
||||
Loop, % Config_viewCount {
|
||||
StringTrimRight, wndIds, View_#%m%_#%A_Index%_wndIds, 1
|
||||
StringSplit, wndId, wndIds, `;
|
||||
GuiControl, , Bar_#%m%_view_#%A_Index%_highlighted, % wndId0 / managedWndId0 * 100 ;; Update the percentage fill for the view.
|
||||
;GuiControl, , Bar_#%m%_view_#%A_Index%_highlighted, % wndId0 / managedWndId0 * 100 ;; Update the percentage fill for the view.
|
||||
GuiControl, , Bar_#%m%_view_#%A_Index%, % Config_viewNames_#%A_Index% ;; Refresh the number on the bar.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,13 +37,16 @@ Config_init() {
|
|||
Config_readinCpu := False
|
||||
Config_readinDate := True
|
||||
Config_readinDateFormat := "ddd, dd. MMM. yyyy"
|
||||
Config_readinDiskLoad := False
|
||||
Config_readinMemoryUsage := False
|
||||
Config_readinNetworkLoad := False
|
||||
Config_readinRam := False
|
||||
Config_readinMusic := False
|
||||
Config_readinTime := True
|
||||
Config_readinTimeBinary := False
|
||||
Config_readinTimeFormat := "HH:mm"
|
||||
Config_readinVolume := False
|
||||
Config_readinInterval := 30000
|
||||
Config_barItemSpacing := 8
|
||||
Config_barIconSpacing := 4
|
||||
Config_iconFontYOffset := 3
|
||||
|
||||
;; Windows ui elements
|
||||
Config_bbCompatibility := False
|
||||
|
@ -117,6 +120,7 @@ Config_init() {
|
|||
|
||||
Config_getSystemSettings()
|
||||
Config_initColors()
|
||||
Config_initBarIcons()
|
||||
Loop, % Config_layoutCount {
|
||||
StringSplit, layout, Config_layout_#%A_Index%, `;
|
||||
Config_layoutFunction_#%A_Index% := layout2
|
||||
|
@ -152,6 +156,12 @@ Config_initColors() {
|
|||
}
|
||||
}
|
||||
|
||||
Config_initBarIcons() {
|
||||
Global
|
||||
|
||||
StringSplit, Config_barIcon_#, Config_barIcons, `;
|
||||
}
|
||||
|
||||
Config_convertSystemColor(systemColor)
|
||||
{ ;; systemColor format: 0xBBGGRR
|
||||
rr := SubStr(systemColor, 7, 2)
|
||||
|
|
|
@ -192,3 +192,4 @@ Return
|
|||
#Include View.ahk
|
||||
#Include Window.ahk
|
||||
#Include %A_ScriptDir%\MonitorManager.ahk
|
||||
#Include %A_ScriptDir%\MusicBee.ahk
|
153
src/MusicBee.ahk
Normal file
153
src/MusicBee.ahk
Normal file
|
@ -0,0 +1,153 @@
|
|||
MusicBee_FormatTime(time) {
|
||||
seconds := time / 1000
|
||||
hours := Floor(seconds / 3600)
|
||||
seconds := Mod(seconds, 3600)
|
||||
minutes := Floor(seconds / 60)
|
||||
seconds := Mod(seconds, 60)
|
||||
seconds := Floor(seconds)
|
||||
|
||||
if (seconds < 10) {
|
||||
seconds := % "0" seconds
|
||||
}
|
||||
if (minutes < 10) {
|
||||
minutes := % "0" minutes
|
||||
}
|
||||
|
||||
if (hours != 0) {
|
||||
return % hours ":" minutes ":" seconds
|
||||
} else {
|
||||
return % minutes ":" seconds
|
||||
}
|
||||
}
|
||||
|
||||
MusicBee_GetNowPlaying() {
|
||||
detectHidden := A_DetectHiddenWindows
|
||||
DetectHiddenWindows, On
|
||||
ipcId := WinExist("MusicBee IPC Interface")
|
||||
|
||||
SendMessage, 0x0400, 999, 0,, ahk_id %ipcId%
|
||||
probeState := ErrorLevel
|
||||
|
||||
SendMessage, 0x0400, 109, 0,, ahk_id %ipcId%
|
||||
playState := ErrorLevel
|
||||
|
||||
SendMessage, 0x0400, 110, 0,, ahk_id %ipcId%
|
||||
position := ErrorLevel
|
||||
|
||||
SendMessage, 0x0400, 141, 16,, ahk_id %ipcId%
|
||||
durationData := ErrorLevel
|
||||
MBIPC_Unpack_s(MBIPC_GetLResult(durationData), displayDuration)
|
||||
SendMessage, 0x0400, 900, %durationData%,, ahk_id %ipcId%
|
||||
|
||||
SendMessage, 0x0400, 142, 32,, ahk_id %ipcId%
|
||||
artistData := ErrorLevel
|
||||
MBIPC_Unpack_s(MBIPC_GetLResult(artistData), artist)
|
||||
SendMessage, 0x0400, 900, %artistData%,, ahk_id %ipcId%
|
||||
|
||||
SendMessage, 0x0400, 142, 31,, ahk_id %ipcId%
|
||||
albumArtistData := ErrorLevel
|
||||
MBIPC_Unpack_s(MBIPC_GetLResult(albumArtistData), albumArtist)
|
||||
SendMessage, 0x0400, 900, %albumArtistData%,, ahk_id %ipcId%
|
||||
|
||||
SendMessage, 0x0400, 142, 65,, ahk_id %ipcId%
|
||||
titleData := ErrorLevel
|
||||
MBIPC_Unpack_s(MBIPC_GetLResult(titleData), title)
|
||||
SendMessage, 0x0400, 900, %titleData%,, ahk_id %ipcId%
|
||||
|
||||
displayArtist := artist
|
||||
if (StrLen(artist) > 64) {
|
||||
displayArtist := albumArtist
|
||||
}
|
||||
|
||||
state := ""
|
||||
if (playState = 6) {
|
||||
state := " [paused]"
|
||||
}
|
||||
|
||||
duration := 0
|
||||
splitDuration := StrSplit(displayDuration, ":")
|
||||
duration += splitDuration[1] * 60
|
||||
duration += splitDuration[2]
|
||||
duration *= 1000
|
||||
|
||||
DetectHiddenWindows, %detectHidden%
|
||||
|
||||
StringReplace, displayArtist, displayArtist, &, &&, All
|
||||
StringReplace, title, title, &, &&, All
|
||||
|
||||
if (probeState = 1) {
|
||||
return % displayArtist " - " title " [" MusicBee_FormatTime(position) "/" MusicBee_FormatTime(duration) "]" state
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
;;;;
|
||||
|
||||
MBIPC_Unpack_s(Byref lr, ByRef string_1)
|
||||
{
|
||||
string_1 := ""
|
||||
|
||||
mmf := MBIPC_OpenMmf(lr)
|
||||
if !mmf
|
||||
return 0
|
||||
|
||||
view := MBIPC_MapMmfView(mmf, lr, ptr)
|
||||
if !view
|
||||
{
|
||||
MBIPC_CloseMmf(mmf)
|
||||
return 0
|
||||
}
|
||||
|
||||
byteCount := NumGet(ptr+0, 0, "Int")
|
||||
ptr += 4
|
||||
|
||||
if byteCount > 0
|
||||
string_1 := StrGet(ptr, byteCount // 2, "UTF-16")
|
||||
|
||||
MBIPC_UnmapMmfView(view)
|
||||
|
||||
MBIPC_CloseMmf(mmf)
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
MBIPC_OpenMmf(ByRef lr)
|
||||
{
|
||||
if !lr
|
||||
return 0
|
||||
|
||||
; FILE_MAP_READ = 0x0004 = 4
|
||||
; FALSE = 0
|
||||
return DllCall("OpenFileMapping", UInt, 4, Int, 0, Str, "mbipc_mmf_" . NumGet(lr, 0, "UShort"), UInt)
|
||||
}
|
||||
|
||||
MBIPC_CloseMmf(mmf)
|
||||
{
|
||||
DllCall("CloseHandle", UInt, mmf)
|
||||
}
|
||||
|
||||
MBIPC_MapMmfView(mmf, ByRef lr, ByRef ptr)
|
||||
{
|
||||
; FILE_MAP_READ = 0x0004 = 4
|
||||
view := DllCall("MapViewOfFile", UInt, mmf, UInt, 4, UInt, 0, UInt, 0, UInt, 0, UInt)
|
||||
|
||||
ptr := view + NumGet(lr, 2, "UShort") + 8
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
MBIPC_UnmapMmfView(view)
|
||||
{
|
||||
DllCall("UnmapViewOfFile", UInt, view)
|
||||
}
|
||||
|
||||
MBIPC_GetLResult(el)
|
||||
{
|
||||
if el = FAIL
|
||||
return 0
|
||||
|
||||
VarSetCapacity(lr, 4)
|
||||
NumPut(el, lr, 0, "Int")
|
||||
return lr
|
||||
}
|
|
@ -126,7 +126,7 @@ ResourceMonitor_getSystemTimes() {
|
|||
oldUserTime := newUserTime
|
||||
|
||||
DllCall("GetSystemTimes", "Int64P", newIdleTime, "Int64P", newKrnlTime, "Int64P", newUserTime)
|
||||
sysTime := SubStr(" " . Round((1 - (newIdleTime - oldIdleTime) / (newKrnlTime - oldKrnlTime+newUserTime - oldUserTime)) * 100), -2)
|
||||
sysTime := Round((1 - (newIdleTime - oldIdleTime) / (newKrnlTime - oldKrnlTime+newUserTime - oldUserTime)) * 100)
|
||||
Return, sysTime ;; system time in percent
|
||||
}
|
||||
;; Sean: CPU LoadTimes (http://www.autohotkey.com/forum/topic18913.html)
|
||||
|
@ -157,3 +157,35 @@ ResourceMonitor_getText() {
|
|||
|
||||
Return, text
|
||||
}
|
||||
|
||||
ResourceMonitor_getSystemTimes2(ByRef IdleTime) {
|
||||
DllCall("GetSystemTimes", "Int64P", IdleTime, "Int64P", KernelTime, "Int64P", UserTime)
|
||||
Return KernelTime + UserTime
|
||||
}
|
||||
|
||||
ResourceMonitor_getCpuLoad(period := 500) {
|
||||
total := ResourceMonitor_getSystemTimes2(idle)
|
||||
Sleep, % period
|
||||
total2 := ResourceMonitor_getSystemTimes2(idle2)
|
||||
Return 100*(1 - (idle2 - idle)/(total2 - total))
|
||||
}
|
||||
|
||||
ResourceMonitor_getCpuText() {
|
||||
Return, Floor(ResourceMonitor_getCpuLoad()) . "%"
|
||||
}
|
||||
|
||||
ResourceMonitor_GlobalMemoryStatusEx()
|
||||
{
|
||||
static MSEX, init := NumPut(VarSetCapacity(MSEX, 64, 0), MSEX, "uint")
|
||||
if !(DllCall("GlobalMemoryStatusEx", "ptr", &MSEX))
|
||||
throw Exception("Call to GlobalMemoryStatusEx failed: " A_LastError, -1)
|
||||
return { MemoryLoad: NumGet(MSEX, 4, "uint"), TotalPhys: NumGet(MSEX, 8, "uint64"), AvailPhys: NumGet(MSEX, 16, "uint64") }
|
||||
}
|
||||
|
||||
ResourceMonitor_getRamText() {
|
||||
GMSEx := ResourceMonitor_GlobalMemoryStatusEx()
|
||||
TotalMem := GMSEx.TotalPhys
|
||||
AvailMem := GMSEx.AvailPhys
|
||||
mem := RegExReplace(Floor((TotalMem - AvailMem) / 1048576), "(\d)(?=(?:\d{3})+(?:\.|$))", "$1,")
|
||||
Return, mem . " MB"
|
||||
}
|
|
@ -18,6 +18,7 @@ Window_activate(wndId) {
|
|||
Debug_logMessage("DEBUG[2] Window_activate: Potentially hung window " . wndId, 2)
|
||||
Return, 1
|
||||
} Else {
|
||||
WinActivate, ahk_class Progman
|
||||
WinActivate, ahk_id %wndId%
|
||||
WinGet, aWndId, ID, A
|
||||
If (wndId != aWndId)
|
||||
|
|
Loading…
Reference in a new issue