Step 1 of a long manual merge
This commit is contained in:
parent
aaa73c4729
commit
c30a4c3f30
4 changed files with 773 additions and 561 deletions
769
src/Config.ahk
769
src/Config.ahk
|
@ -1,434 +1,418 @@
|
||||||
/**
|
/*
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
Config_init() {
|
This program is free software: you can redistribute it and/or modify
|
||||||
Local i, key, layout0, layout1, layout2
|
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.
|
||||||
|
|
||||||
; status bar
|
This program is distributed in the hope that it will be useful,
|
||||||
Config_showBar := True ; If false, the bar is hidden. It can be made visible or hidden by hotkey (see below).
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
Config_horizontalBarPos := "left" ; The horizontal position of the bar: "center", "left" or "right" side of the monitor or an offset in pixel (px) from the left (>= 0) or right (< 0).
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
Config_verticalBarPos := "top" ; The vertical position of the bar: "top" or "bottom" of the monitor, "tray" = sub-window of the task bar.
|
GNU General Public License for more details.
|
||||||
Config_barWidth := "100%" ; The width of the bar in pixel (px) or with a per cent sign (%) as a percentage.
|
|
||||||
Config_singleRowBar := True ; If false, the bar will have to rows, one for the window title and one for all other GUI controls.
|
|
||||||
Config_spaciousBar := False ; If true, the height of the bar will be set to a value equal to the height of an edit control, else it will be set to the text height.
|
|
||||||
Config_fontName := "Lucida Console" ; A monospace font is preferable for bug.n to calculate the correct width of the bar and its elements (sub-windows).
|
|
||||||
Config_fontSize :=
|
|
||||||
Config_normBgColor :=
|
|
||||||
Config_normFgColor :=
|
|
||||||
Config_selBgColor :=
|
|
||||||
Config_selFgColor :=
|
|
||||||
Config_readinBat := False ; If true, the system battery status is read in and displayed in the status bar. This only makes sense, if you have a system battery (notebook).
|
|
||||||
Config_readinCpu := False ; If true, the current CPU load is read in and displayed in the status bar.
|
|
||||||
Config_readinDate := True ; If true, the current date is read in (format: "WW, DD. MMM. YYYY") and displayed in the status bar.
|
|
||||||
Config_readinDiskLoad := False ; If true, the current disk load (read and write) is read in and displayed in the status bar.
|
|
||||||
Config_readinMemoryUsage := False ; If true, the system memory usage is read in and displayed in the status bar.
|
|
||||||
Config_readinNetworkLoad := False ; If true, the current network load (up and down) is read in and displayed in the status bar.
|
|
||||||
Config_readinTime := True ; If true, the current time is read in (format: "HH:MM") and displayed in the status bar.
|
|
||||||
Config_readinInterval := 30000 ; Time in milliseconds after which the above status values are refreshed.
|
|
||||||
|
|
||||||
; Windows ui elements
|
You should have received a copy of the GNU General Public License
|
||||||
Config_bbCompatibility := False ; If true, bug.n looks for BlackBox components (bbLeanBar, bbSlit and SystemBarEx) when calculating the work area. It is assumed that the virtual desktop functionality of BlackBox and NOT bug.n is used (=> Hiding and showing windows is detected and acted upon).
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
Config_borderWidth := 0 ; If > 0, the window border width is set to the integer value Config_borderWidth.
|
|
||||||
Config_borderPadding := -1 ; If >= 0, the window border padding is set to the integer value Config_borderPadding (only for Windows >= Vista).
|
|
||||||
Config_showTaskBar := False ; If false, the task bar is hidden. It can be made visible or hidden by hotkey (see below).
|
|
||||||
Config_showBorder := True ; If false, the window borders are hidden; therefor windows cannot be resized manually by dragging the border, even if using the according hotkey.
|
|
||||||
Config_selBorderColor := "" ; Border colour of the active window; format: 0x00BBGGRR (e. g. "0x006A240A", if = "", the system's window border colour is not changed).
|
|
||||||
; Config_borderWidth, Config_borderPadding and Config_selBorderColor are especially usefull, if you are not allowed to set the design in the system settings.
|
|
||||||
; window arrangement
|
|
||||||
Config_viewCount := 9 ; The total number of views. This has effects on the displayed groups in the bar, and should not be exceeded in the hotkeys below.
|
|
||||||
Config_layout_#1 := "[]=;tile" ; The layout symbol and arrange function (the first entry is set as the default layout, no layout function means floating behavior)
|
|
||||||
Config_layout_#2 := "[M];monocle"
|
|
||||||
Config_layout_#3 := "><>;"
|
|
||||||
Config_layoutCount := 3 ; Total number of layouts defined above.
|
|
||||||
Config_layoutAxis_#1 := 1 ; The layout axis: 1 = x, 2 = y; negative values mirror the layout, setting the master area to the right / bottom instead of left / top.
|
|
||||||
Config_layoutAxis_#2 := 2 ; The master axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle).
|
|
||||||
Config_layoutAxis_#3 := 2 ; The stack axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle).
|
|
||||||
Config_layoutGapWidth := 0 ; The default gap width in px (only even numbers) of the "tile" layout, i. e. the space between windows and around the layout.
|
|
||||||
Config_layoutMFactor := 0.6 ; The factor for the size of the master area, which is multiplied by the monitor size.
|
|
||||||
Config_mouseFollowsFocus := True ; If true, the mouse pointer is set over the focused window, if a window is activated by bug.n.
|
|
||||||
Config_onActiveHiddenWnds := "view" ; The action, which will be taken, if a window e. g. should be activated, but is not visible; "view": show the view accordng to the first tag of the window in question, "tag": add the window in question to the current visible view, "hide": hide the window again ignoring the activation.
|
|
||||||
Config_newWndPosition := "top" ; The position of a new window in a view; "top": at the beginning of the window list and the master area (default), "masterBottom": at the end of the master area, "stackTop": on top of the stack area, "bottom": at the end of the window list and the stack area.
|
|
||||||
Config_shellMsgDelay := 350 ; The time bug.n waits after a shell message (a window is opened, closed or the focus has been changed); if there are any problems recognizing, when windows are opened or closed, try to increase this number.
|
|
||||||
Config_syncMonitorViews := 0 ; The number of monitors (2 or more), for which views should be activated, when using the accordant hotkey. If set to 1, the views are activated for all monitors. If set to 0, views are activated independently (only on the active monitor).
|
|
||||||
Config_viewFollowsTagged := False ; If true and a window is tagged with a single tag, the view is correspondingly set to the tag.
|
|
||||||
|
|
||||||
; Config_rule_#i := "<class (regular expression string)>;<title (regular expression string)>;<window style (hexadecimal number or blank)>;
|
@version 8.3.0
|
||||||
; <is managed (1 = True or 0 = False)>;
|
*/
|
||||||
; <monitor (0 <= integer <= total number of monitors, 0 means the currently active monitor)>;
|
|
||||||
; <tags (binary mask as integer >= 0, e. g. 17 for 1 and 5, 0 means the currently active tag)>;
|
|
||||||
; <is floating (1 = True or 0 = False)>;<is decorated (1 = True or 0 = False)>;<hide title (1 = True or 0 = False)>"
|
|
||||||
; (";" is not allowed as a character)
|
|
||||||
Config_rule_#1 := ".*;.*;;1;0;0;0;0;0" ; At first you may set a default rule (.*;.*;) for a default monitor, view and / or showing window title bars.
|
|
||||||
Config_rule_#2 := ".*;.*;0x80000000;0;0;0;1;1;1" ; Pop-up windows (style WS_POPUP=0x80000000) will not be managed, are floating and the titles are hidden.
|
|
||||||
Config_rule_#3 := "SWT_Window0;.*;;1;0;0;0;0;0" ; Windows created by Java (SWT) e. g. Eclipse have the style WS_POPUP, but should excluded from the above rule.
|
|
||||||
Config_rule_#4 := "Xming;.*;;1;0;0;0;0;0" ; Xming windows have the style WS_POPUP, but should be excluded from the above rule.
|
|
||||||
Config_rule_#5 := "MsiDialog(No)?CloseClass;.*;;1;0;0;1;1;0"
|
|
||||||
Config_rule_#6 := "AdobeFlashPlayerInstaller;.*;;1;0;0;1;0;1"
|
|
||||||
Config_rule_#7 := "CalcFrame;.*;;1;0;0;1;1;0"
|
|
||||||
Config_rule_#8 := "_sp;_sp;;1;0;0;1;0;1"
|
|
||||||
Config_rule_#9 := "MozillaDialogClass;.*;;1;0;0;1;1;0"
|
|
||||||
Config_rule_#10 := "gdkWindowToplevel;GIMP-Start;;1;0;0;1;1;0"
|
|
||||||
Config_rule_#11 := "gdkWindowToplevel;GNU Image Manipulation Program;;1;0;0;1;1;0"
|
|
||||||
Config_rule_#12 := "gdkWindowToplevel;Werkzeugkasten;;1;0;0;1;1;0"
|
|
||||||
Config_rule_#13 := "gdkWindowToplevel;Ebenen, .* - Pinsel, Muster, .*;;1;0;0;1;1;0"
|
|
||||||
Config_rule_#14 := "gdkWindowToplevel;Toolbox;;1;0;0;1;1;0"
|
|
||||||
Config_rule_#15 := "gdkWindowToplevel;Layers, Channels, Paths, .*;;1;0;0;1;1;0"
|
|
||||||
Config_ruleCount := 15 ; This variable has to be set to the total number of active rules above.
|
|
||||||
|
|
||||||
; configuration management
|
Config_init()
|
||||||
Config_autoSaveSession := False ; Automatically save the current state of monitors, views, layouts (active view, layout, axes, mfact and msplit) to the configuration file (set below) when quitting bug.n.
|
{
|
||||||
If Not Config_filePath ; The file path, to which the configuration and session is saved. This target directory must be writable by the user (%A_ScriptDir% is the diretory, in which "Main.ahk" or the executable of bug.n is saved).
|
Local i, key, layout0, layout1, layout2, vNames0, vNames1, vNames2, vNames3, vNames4, vNames5, vNames6, vNames7, vNames8, vNames9
|
||||||
Config_filePath := A_ScriptDir "\Config.ini"
|
|
||||||
Config_maintenanceInterval := 5000
|
|
||||||
|
|
||||||
Config_restoreConfig(Config_filePath)
|
;; Status bar
|
||||||
Config_getSystemSettings()
|
Config_showBar := True
|
||||||
Config_initColors()
|
Config_horizontalBarPos := "left"
|
||||||
Loop, % Config_layoutCount {
|
Config_verticalBarPos := "top"
|
||||||
StringSplit, layout, Config_layout_#%A_Index%, `;
|
Config_barWidth := "100%"
|
||||||
Config_layoutFunction_#%A_Index% := layout2
|
Config_singleRowBar := True
|
||||||
Config_layoutSymbol_#%A_Index% := layout1
|
Config_spaciousBar := False
|
||||||
}
|
Config_fontName := "Lucida Console"
|
||||||
If (Config_viewCount > 9)
|
Config_fontSize :=
|
||||||
Config_viewCount := 9
|
Config_normBgColor :=
|
||||||
|
Config_normFgColor :=
|
||||||
|
Config_selBgColor :=
|
||||||
|
Config_selFgColor :=
|
||||||
|
Config_barCommands := "Run, explore doc;Monitor_toggleBar();Main_reload();Reload;ExitApp"
|
||||||
|
Config_readinBat := False
|
||||||
|
Config_readinCpu := False
|
||||||
|
Config_readinDate := True
|
||||||
|
Config_readinDiskLoad := False
|
||||||
|
Config_readinMemoryUsage := False
|
||||||
|
Config_readinNetworkLoad := False
|
||||||
|
Config_readinTime := True
|
||||||
|
Config_readinInterval := 30000
|
||||||
|
|
||||||
|
;; Windows ui elements
|
||||||
|
Config_bbCompatibility := False
|
||||||
|
Config_borderWidth := 0
|
||||||
|
Config_borderPadding := -1
|
||||||
|
Config_showTaskBar := False
|
||||||
|
Config_showBorder := True
|
||||||
|
Config_selBorderColor := ""
|
||||||
|
|
||||||
|
;; Window arrangement
|
||||||
|
Config_viewNames := "1;2;3;4;5;6;7;8;9"
|
||||||
|
Config_layout_#1 := "[]=;tile"
|
||||||
|
Config_layout_#2 := "[M];monocle"
|
||||||
|
Config_layout_#3 := "><>;"
|
||||||
|
Config_layoutCount := 3
|
||||||
|
Config_layoutAxis_#1 := 1
|
||||||
|
Config_layoutAxis_#2 := 2
|
||||||
|
Config_layoutAxis_#3 := 2
|
||||||
|
Config_layoutGapWidth := 0
|
||||||
|
Config_layoutMFactor := 0.6
|
||||||
|
Config_ghostWndSubString := " (Not Responding)"
|
||||||
|
Config_mouseFollowsFocus := True
|
||||||
|
Config_viewMargins := "0;0;0;0"
|
||||||
|
Config_newWndPosition := "top"
|
||||||
|
Config_onActiveHiddenWnds := "view"
|
||||||
|
Config_shellMsgDelay := 350
|
||||||
|
Config_syncMonitorViews := 0
|
||||||
|
Config_viewFollowsTagged := False
|
||||||
|
|
||||||
|
;; Config_rule_#<i> := '<class>;<title>;<style>;<is managed>;<m>;<tags>;<is floating>;<is decorated>;<hide title>;<action>'
|
||||||
|
Config_rule_#1 := ".*;.*;;1;0;0;0;0;0;" ;; default rule
|
||||||
|
Config_rule_#2 := ".*;.*;0x80000000;0;0;0;1;1;1;" ;; Pop-up windows (style WS_POPUP=0x80000000) will not be managed, are floating and the titles are hidden.
|
||||||
|
Config_rule_#3 := "SWT_Window0;.*;;1;0;0;0;0;0;" ;; Windows created by Java (SWT) e. g. Eclipse have the style WS_POPUP, but should be excluded from the second rule.
|
||||||
|
Config_rule_#4 := "QWidget;.*;;1;0;0;0;0;0;" ;; ... also windows created by QT (QWidget)
|
||||||
|
Config_rule_#5 := "Xming;.*;;1;0;0;0;0;0;" ;; ... and Xming windows
|
||||||
|
Config_rule_#6 := "MsiDialog(No)?CloseClass;.*;;1;0;0;1;1;0;"
|
||||||
|
Config_rule_#7 := "AdobeFlashPlayerInstaller;.*;;1;0;0;1;0;1;"
|
||||||
|
Config_rule_#8 := "CalcFrame;.*;;1;0;0;1;1;0;"
|
||||||
|
Config_rule_#9 := "MozillaDialogClass;.*;;1;0;0;1;1;0;"
|
||||||
|
Config_rule_#10 := "_sp;_sp;;1;0;0;1;0;1;"
|
||||||
|
Config_rule_#11 := "MozillaWindowClass;.* - Mozilla Firefox;;1;0;0;0;1;0;Maximize"
|
||||||
|
Config_rule_#12 := "Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;Maximize"
|
||||||
|
Config_ruleCount := 12 ;; This variable has to be set to the total number of active rules above.
|
||||||
|
|
||||||
|
;; Configuration management
|
||||||
|
Config_autoSaveSession := False
|
||||||
|
; @todo: To be removed?
|
||||||
|
If Not Config_filePath ; The file path, to which the configuration and session is saved. This target directory must be writable by the user (%A_ScriptDir% is the diretory, in which "Main.ahk" or the executable of bug.n is saved).
|
||||||
|
Config_filePath := A_ScriptDir "\Config.ini"
|
||||||
|
Config_maintenanceInterval := 5000
|
||||||
|
|
||||||
|
Config_restoreConfig(Config_filePath)
|
||||||
|
Config_getSystemSettings()
|
||||||
|
Config_initColors()
|
||||||
|
Loop, % Config_layoutCount
|
||||||
|
{
|
||||||
|
StringSplit, layout, Config_layout_#%A_Index%, `;
|
||||||
|
Config_layoutFunction_#%A_Index% := layout2
|
||||||
|
Config_layoutSymbol_#%A_Index% := layout1
|
||||||
|
}
|
||||||
|
StringSplit, vNames, Config_viewNames, `;
|
||||||
|
If vNames0 > 9
|
||||||
|
Config_viewCount := 9
|
||||||
|
Else
|
||||||
|
Config_viewCount := vNames0
|
||||||
|
Loop, % Config_viewCount
|
||||||
|
{
|
||||||
|
Config_viewNames_#%A_Index% := vNames%A_Index%
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_initColors() {
|
Config_initColors()
|
||||||
Global
|
{
|
||||||
|
Global
|
||||||
|
|
||||||
StringReplace, Config_normBgColor, Config_normBgColor, `;0`;, `;000000`;, All
|
StringReplace, Config_normBgColor, Config_normBgColor, `;0`;, `;000000`;, All
|
||||||
Config_normBgColor := RegExReplace(Config_normBgColor, "^0;", "000000;")
|
Config_normBgColor := RegExReplace(Config_normBgColor, "^0;", "000000;")
|
||||||
Config_normBgColor := RegExReplace(Config_normBgColor, ";0$", ";000000")
|
Config_normBgColor := RegExReplace(Config_normBgColor, ";0$", ";000000")
|
||||||
StringSplit, Config_normBgColor, Config_normBgColor, `;
|
StringSplit, Config_normBgColor, Config_normBgColor, `;
|
||||||
|
|
||||||
StringReplace, Config_normFgColor, Config_normFgColor, `;0`;, `;000000`;, All
|
StringReplace, Config_normFgColor, Config_normFgColor, `;0`;, `;000000`;, All
|
||||||
Config_normFgColor := RegExReplace(Config_normFgColor, "^0;", "000000;")
|
Config_normFgColor := RegExReplace(Config_normFgColor, "^0;", "000000;")
|
||||||
Config_normFgColor := RegExReplace(Config_normFgColor, ";0$", ";000000")
|
Config_normFgColor := RegExReplace(Config_normFgColor, ";0$", ";000000")
|
||||||
StringSplit, Config_normFgColor, Config_normFgColor, `;
|
StringSplit, Config_normFgColor, Config_normFgColor, `;
|
||||||
|
|
||||||
StringReplace, Config_selBgColor, Config_selBgColor, `;0`;, `;000000`;, All
|
StringReplace, Config_selBgColor, Config_selBgColor, `;0`;, `;000000`;, All
|
||||||
Config_selBgColor := RegExReplace(Config_selBgColor, "^0;", "000000;")
|
Config_selBgColor := RegExReplace(Config_selBgColor, "^0;", "000000;")
|
||||||
Config_selBgColor := RegExReplace(Config_selBgColor, ";0$", ";000000")
|
Config_selBgColor := RegExReplace(Config_selBgColor, ";0$", ";000000")
|
||||||
StringSplit, Config_selBgColor, Config_selBgColor, `;
|
StringSplit, Config_selBgColor, Config_selBgColor, `;
|
||||||
|
|
||||||
StringReplace, Config_selFgColor, Config_selFgColor, `;0`;, `;000000`;, All
|
StringReplace, Config_selFgColor, Config_selFgColor, `;0`;, `;000000`;, All
|
||||||
Config_selFgColor := RegExReplace(Config_selFgColor, "^0;", "000000;")
|
Config_selFgColor := RegExReplace(Config_selFgColor, "^0;", "000000;")
|
||||||
Config_selFgColor := RegExReplace(Config_selFgColor, ";0$", ";000000")
|
Config_selFgColor := RegExReplace(Config_selFgColor, ";0$", ";000000")
|
||||||
StringSplit, Config_selFgColor, Config_selFgColor, `;
|
StringSplit, Config_selFgColor, Config_selFgColor, `;
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_convertSystemColor(systemColor) { ; systemColor format: 0xBBGGRR
|
Config_convertSystemColor(systemColor)
|
||||||
rr := SubStr(systemColor, 7, 2)
|
{ ;; systemColor format: 0xBBGGRR
|
||||||
gg := SubStr(systemColor, 5, 2)
|
rr := SubStr(systemColor, 7, 2)
|
||||||
bb := SubStr(systemColor, 3, 2)
|
gg := SubStr(systemColor, 5, 2)
|
||||||
|
bb := SubStr(systemColor, 3, 2)
|
||||||
|
|
||||||
Return, rr gg bb
|
Return, rr gg bb
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_getSystemSettings() {
|
Config_getSystemSettings()
|
||||||
Global Config_fontName, Config_fontSize, Config_normBgColor, Config_normFgColor, Config_selBgColor, Config_selFgColor
|
{
|
||||||
|
Global Config_fontName, Config_fontSize, Config_normBgColor, Config_normFgColor, Config_selBgColor, Config_selFgColor
|
||||||
|
|
||||||
If Not Config_fontName {
|
If Not Config_fontName
|
||||||
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
|
{
|
||||||
NumPut(ncmSize, ncm, 0, "UInt")
|
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
|
||||||
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
NumPut(ncmSize, ncm, 0, "UInt")
|
||||||
|
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
||||||
|
|
||||||
VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
|
VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
|
||||||
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
|
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
|
||||||
VarSetCapacity(Config_fontName, 32 * (A_IsUnicode ? 2 : 1), 0)
|
VarSetCapacity(Config_fontName, 32 * (A_IsUnicode ? 2 : 1), 0)
|
||||||
DllCall("RtlMoveMemory", "Str", Config_fontName, "UInt", &lf + 28, "UInt", 32 * (A_IsUnicode ? 2 : 1))
|
DllCall("RtlMoveMemory", "Str", Config_fontName, "UInt", &lf + 28, "UInt", 32 * (A_IsUnicode ? 2 : 1))
|
||||||
; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
|
;; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
|
||||||
}
|
}
|
||||||
If Not Config_fontSize {
|
If Not Config_fontSize
|
||||||
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
|
{
|
||||||
NumPut(ncmSize, ncm, 0, "UInt")
|
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
|
||||||
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
NumPut(ncmSize, ncm, 0, "UInt")
|
||||||
|
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
||||||
|
|
||||||
lfSize := VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
|
lfSize := VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
|
||||||
NumPut(lfSize, lf, 0, "UInt")
|
NumPut(lfSize, lf, 0, "UInt")
|
||||||
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
|
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
|
||||||
|
|
||||||
lfHeightSize := VarSetCapacity(lfHeight, 4, 0)
|
lfHeightSize := VarSetCapacity(lfHeight, 4, 0)
|
||||||
NumPut(lfHeightSize, lfHeight, 0, "Int")
|
NumPut(lfHeightSize, lfHeight, 0, "Int")
|
||||||
lfHeight := NumGet(lf, 0, "Int")
|
lfHeight := NumGet(lf, 0, "Int")
|
||||||
|
|
||||||
lfPixelsY := DllCall("GetDeviceCaps", "UInt", DllCall("GetDC", "UInt", 0), "UInt", 90) ; LOGPIXELSY
|
lfPixelsY := DllCall("GetDeviceCaps", "UInt", DllCall("GetDC", "UInt", 0), "UInt", 90) ;; LOGPIXELSY
|
||||||
Config_fontSize := -DllCall("MulDiv", "Int", lfHeight, "Int", 72, "Int", lfPixelsY)
|
Config_fontSize := -DllCall("MulDiv", "Int", lfHeight, "Int", 72, "Int", lfPixelsY)
|
||||||
; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
|
;; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
|
||||||
}
|
}
|
||||||
SetFormat, Integer, hex
|
SetFormat, Integer, hex
|
||||||
If Not Config_normBgColor {
|
If Not Config_normBgColor
|
||||||
Config_normBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 4)) ; COLOR_MENU
|
{
|
||||||
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ; COLOR_INACTIVECAPTION
|
Config_normBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 4)) ;; COLOR_MENU
|
||||||
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 28)) ; COLOR_GRADIENTINACTIVECAPTION
|
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ;; COLOR_INACTIVECAPTION
|
||||||
Config_normBgColor .= ";Red"
|
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 28)) ;; COLOR_GRADIENTINACTIVECAPTION
|
||||||
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 28)) ; COLOR_GRADIENTINACTIVECAPTION
|
Config_normBgColor .= ";Red"
|
||||||
}
|
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 28)) ;; COLOR_GRADIENTINACTIVECAPTION
|
||||||
If Not Config_normFgColor {
|
}
|
||||||
Config_normFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 7)) ; COLOR_MENUTEXT
|
If Not Config_normFgColor
|
||||||
Config_normFgColor .= ";Default"
|
{
|
||||||
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ; COLOR_INACTIVECAPTION
|
Config_normFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 7)) ;; COLOR_MENUTEXT
|
||||||
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 19)) ; COLOR_INACTIVECAPTIONTEXT
|
Config_normFgColor .= ";Default"
|
||||||
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 13)) ; COLOR_HIGHLIGHT
|
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ;; COLOR_INACTIVECAPTION
|
||||||
Config_normFgColor .= ";White"
|
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 19)) ;; COLOR_INACTIVECAPTIONTEXT
|
||||||
Config_normFgColor .= ";Default"
|
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 13)) ;; COLOR_HIGHLIGHT
|
||||||
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ; COLOR_INACTIVECAPTION
|
Config_normFgColor .= ";White"
|
||||||
}
|
Config_normFgColor .= ";Default"
|
||||||
If Not Config_selBgColor {
|
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ;; COLOR_INACTIVECAPTION
|
||||||
Config_selBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 27)) ; COLOR_GRADIENTACTIVECAPTION
|
}
|
||||||
}
|
If Not Config_selBgColor
|
||||||
If Not Config_selFgColor {
|
{
|
||||||
Config_selFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 9)) ; COLOR_CAPTIONTEXT
|
Config_selBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 27)) ;; COLOR_GRADIENTACTIVECAPTION
|
||||||
Config_selFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 2)) ; COLOR_ACTIVECAPTION
|
}
|
||||||
}
|
If Not Config_selFgColor
|
||||||
SetFormat, Integer, d
|
{
|
||||||
|
Config_selFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 9)) ;; COLOR_CAPTIONTEXT
|
||||||
|
Config_selFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 2)) ;; COLOR_ACTIVECAPTION
|
||||||
|
}
|
||||||
|
SetFormat, Integer, d
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_hotkeyLabel:
|
Config_hotkeyLabel:
|
||||||
Config_redirectHotkey(A_ThisHotkey)
|
Config_redirectHotkey(A_ThisHotkey)
|
||||||
Return
|
Return
|
||||||
|
|
||||||
Config_readinAny() { ; Add information to the variable "text" in this function to display it in the status bar.
|
Config_readinAny()
|
||||||
Global Config_readinCpu, Config_readinDate, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad
|
{ ;; Add information to the variable 'text' in this function to display it in the status bar.
|
||||||
|
Global Config_readinDate
|
||||||
|
|
||||||
text := ""
|
text := ""
|
||||||
If Config_readinCpu
|
text .= ResourceMonitor_getText()
|
||||||
text .= " CPU: " Bar_getSystemTimes() "% "
|
If Config_readinDate
|
||||||
If Config_readinMemoryUsage {
|
text .= " " A_DDD ", " A_DD ". " A_MMM ". " A_YYYY " "
|
||||||
If Config_readinCpu
|
|
||||||
text .= "|"
|
|
||||||
text .= " RAM: " Bar_getMemoryUsage() "% "
|
|
||||||
}
|
|
||||||
If Config_readinDiskLoad {
|
|
||||||
If (Config_readinCpu Or Config_readinMemoryUsage)
|
|
||||||
text .= "|"
|
|
||||||
Bar_getDiskLoad(rLoad, wLoad)
|
|
||||||
text .= " Dr: " rLoad "% | Dw: " wLoad "% "
|
|
||||||
}
|
|
||||||
If Config_readinNetworkLoad {
|
|
||||||
If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad)
|
|
||||||
text .= "|"
|
|
||||||
Bar_getNetworkLoad(upLoad, dnLoad)
|
|
||||||
text .= " UP: " upLoad " KB/s | dn: " dnLoad " KB/s "
|
|
||||||
}
|
|
||||||
If Config_readinDate {
|
|
||||||
If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad Or Config_readinNetworkLoad)
|
|
||||||
text .= "|"
|
|
||||||
text .= " " A_DDD ", " A_DD ". " A_MMM ". " A_YYYY " "
|
|
||||||
}
|
|
||||||
|
|
||||||
Return, text
|
Return, text
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_redirectHotkey(key) {
|
Config_redirectHotkey(key)
|
||||||
Local functionArgument0, functionArgument1, functionArgument2, functionArguments, functionName, i, j, parameter0, parameter1, parameter2, parameter3, parameters, type
|
{
|
||||||
|
Global
|
||||||
|
|
||||||
Loop, % Config_hotkeyCount
|
Loop, % Config_hotkeyCount
|
||||||
If (key = Config_hotkey_#%A_index%_key) {
|
{
|
||||||
type := SubStr(Config_hotkey_#%A_index%_command, 1, 5)
|
If (key = Config_hotkey_#%A_index%_key)
|
||||||
If (type = "Run, ") {
|
{
|
||||||
parameters := SubStr(Config_hotkey_#%A_index%_command, 6)
|
Main_evalCommand(Config_hotkey_#%A_index%_command)
|
||||||
If InStr(parameters, ", ") {
|
Break
|
||||||
StringSplit, parameter, parameters, `,
|
}
|
||||||
If (parameter0 = 2) {
|
}
|
||||||
StringTrimLeft, parameter2, parameter2, 1
|
|
||||||
Run, %parameter1%, %parameter2%
|
|
||||||
} Else If (parameter0 > 2) {
|
|
||||||
StringTrimLeft, parameter2, parameter2, 1
|
|
||||||
StringTrimLeft, parameter3, parameter3, 1
|
|
||||||
Run, %parameter1%, %parameter2%, %parameter3%
|
|
||||||
}
|
|
||||||
} Else
|
|
||||||
Run, %parameters%
|
|
||||||
} Else If (type = "Send ")
|
|
||||||
Send % SubStr(Config_hotkey_#%A_index%_command, 6)
|
|
||||||
Else If (type = "Reloa")
|
|
||||||
Reload
|
|
||||||
Else If (Config_hotkey_#%A_Index%_command = "ExitApp")
|
|
||||||
ExitApp
|
|
||||||
Else {
|
|
||||||
i := InStr(Config_hotkey_#%A_index%_command, "(")
|
|
||||||
j := InStr(Config_hotkey_#%A_index%_command, ")", False, i)
|
|
||||||
If i And j {
|
|
||||||
functionName := SubStr(Config_hotkey_#%A_index%_command, 1, i - 1)
|
|
||||||
functionArguments := SubStr(Config_hotkey_#%A_index%_command, i + 1, j - (i + 1))
|
|
||||||
StringSplit, functionArgument, functionArguments, `,
|
|
||||||
If (functionArgument0 < 2)
|
|
||||||
%functionName%(functionArguments)
|
|
||||||
Else If (functionArgument0 = 2) {
|
|
||||||
StringTrimLeft, functionArgument2, functionArgument2, 1
|
|
||||||
%functionName%(functionArgument1, functionArgument2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_restoreLayout(filename, m) {
|
Config_restoreLayout(filename, m) {
|
||||||
Local i, var, val
|
Local i, var, val
|
||||||
|
|
||||||
If Not FileExist(filename)
|
If Not FileExist(filename)
|
||||||
Return
|
Return
|
||||||
|
|
||||||
Loop, READ, %filename%
|
Loop, READ, %filename%
|
||||||
If (SubStr(A_LoopReadLine, 1, 10 + StrLen(m)) = "Monitor_#" m "_" Or SubStr(A_LoopReadLine, 1, 8 + StrLen(m)) = "View_#" m "_#") {
|
If (SubStr(A_LoopReadLine, 1, 10 + StrLen(m)) = "Monitor_#" m "_" Or SubStr(A_LoopReadLine, 1, 8 + StrLen(m)) = "View_#" m "_#") {
|
||||||
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)
|
||||||
%var% := val
|
%var% := val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_restoreConfig(filename) {
|
Config_restoreConfig(filename) {
|
||||||
Local cmd, i, key, type, val, var
|
Local cmd, i, key, type, val, var
|
||||||
|
|
||||||
If Not FileExist(filename)
|
If Not FileExist(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") {
|
||||||
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 {
|
||||||
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
|
||||||
}
|
}
|
||||||
var := "Config_rule_#" i
|
var := "Config_rule_#" i
|
||||||
}
|
}
|
||||||
%var% := val
|
%var% := val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_UI_saveSession() {
|
Config_UI_saveSession()
|
||||||
Config_saveSession(Config_filePath)
|
{
|
||||||
|
Config_saveSession(Config_filePath, Config_filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
Config_saveSession(filename) {
|
Config_saveSession(original, target)
|
||||||
Local m, text, tmpfilename
|
{
|
||||||
|
Local m, text, tmpfilename
|
||||||
|
|
||||||
tmpfilename := filename . ".tmp"
|
tmpfilename := target . ".tmp"
|
||||||
FileDelete, %tmpfilename%
|
FileDelete, %tmpfilename%
|
||||||
|
|
||||||
text := "; bug.n - tiling window management`n; @version " VERSION "`n`n"
|
text := "; bug.n - tiling window management`n; @version " VERSION "`n`n"
|
||||||
If FileExist(filename) {
|
If FileExist(original)
|
||||||
Loop, READ, %filename%
|
{
|
||||||
If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
|
Loop, READ, %original%
|
||||||
text .= A_LoopReadLine "`n"
|
{
|
||||||
text .= "`n"
|
If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
|
||||||
}
|
text .= A_LoopReadLine "`n"
|
||||||
|
}
|
||||||
|
text .= "`n"
|
||||||
|
}
|
||||||
|
|
||||||
Loop, % Manager_monitorCount {
|
Loop, % Manager_monitorCount
|
||||||
m := A_Index
|
{
|
||||||
text .= "Monitor_#" m "_aView_#1=" Monitor_#%m%_aView_#1 "`n"
|
m := A_Index
|
||||||
text .= "Monitor_#" m "_aView_#2=" Monitor_#%m%_aView_#2 "`n"
|
If Not (Monitor_#%m%_aView_#1 = 1)
|
||||||
text .= "Monitor_#" m "_showBar=" Monitor_#%m%_showBar "`n"
|
text .= "Monitor_#" m "_aView_#1=" Monitor_#%m%_aView_#1 "`n"
|
||||||
Loop, % Config_viewCount {
|
If Not (Monitor_#%m%_aView_#2 = 1)
|
||||||
text .= "View_#" m "_#" A_Index "_layout_#1=" View_#%m%_#%A_Index%_layout_#1 "`n"
|
text .= "Monitor_#" m "_aView_#2=" Monitor_#%m%_aView_#2 "`n"
|
||||||
text .= "View_#" m "_#" A_Index "_layout_#2=" View_#%m%_#%A_Index%_layout_#2 "`n"
|
If Not (Monitor_#%m%_showBar = Config_showBar)
|
||||||
text .= "View_#" m "_#" A_Index "_layoutAxis_#1=" View_#%m%_#%A_Index%_layoutAxis_#1 "`n"
|
text .= "Monitor_#" m "_showBar=" Monitor_#%m%_showBar "`n"
|
||||||
text .= "View_#" m "_#" A_Index "_layoutAxis_#2=" View_#%m%_#%A_Index%_layoutAxis_#2 "`n"
|
Loop, % Config_viewCount
|
||||||
text .= "View_#" m "_#" A_Index "_layoutAxis_#3=" View_#%m%_#%A_Index%_layoutAxis_#3 "`n"
|
{
|
||||||
text .= "View_#" m "_#" A_Index "_layoutGapWidth=" View_#%m%_#%A_Index%_layoutGapWidth "`n"
|
If Not (View_#%m%_#%A_Index%_layout_#1 = 1)
|
||||||
text .= "View_#" m "_#" A_Index "_layoutMFact=" View_#%m%_#%A_Index%_layoutMFact "`n"
|
text .= "View_#" m "_#" A_Index "_layout_#1=" View_#%m%_#%A_Index%_layout_#1 "`n"
|
||||||
text .= "View_#" m "_#" A_Index "_layoutMX=" View_#%m%_#%A_Index%_layoutMX "`n"
|
If Not (View_#%m%_#%A_Index%_layout_#2 = 1)
|
||||||
text .= "View_#" m "_#" A_Index "_layoutMY=" View_#%m%_#%A_Index%_layoutMY "`n"
|
text .= "View_#" m "_#" A_Index "_layout_#2=" View_#%m%_#%A_Index%_layout_#2 "`n"
|
||||||
}
|
If Not (View_#%m%_#%A_Index%_layoutAxis_#1 = Config_layoutAxis_#1)
|
||||||
}
|
text .= "View_#" m "_#" A_Index "_layoutAxis_#1=" View_#%m%_#%A_Index%_layoutAxis_#1 "`n"
|
||||||
|
If Not (View_#%m%_#%A_Index%_layoutAxis_#2 = Config_layoutAxis_#2)
|
||||||
|
text .= "View_#" m "_#" A_Index "_layoutAxis_#2=" View_#%m%_#%A_Index%_layoutAxis_#2 "`n"
|
||||||
|
If Not (View_#%m%_#%A_Index%_layoutAxis_#3 = Config_layoutAxis_#3)
|
||||||
|
text .= "View_#" m "_#" A_Index "_layoutAxis_#3=" View_#%m%_#%A_Index%_layoutAxis_#3 "`n"
|
||||||
|
If Not (View_#%m%_#%A_Index%_layoutGapWidth = Config_layoutGapWidth)
|
||||||
|
text .= "View_#" m "_#" A_Index "_layoutGapWidth=" View_#%m%_#%A_Index%_layoutGapWidth "`n"
|
||||||
|
If Not (View_#%m%_#%A_Index%_layoutMFact = Config_layoutMFactor)
|
||||||
|
text .= "View_#" m "_#" A_Index "_layoutMFact=" View_#%m%_#%A_Index%_layoutMFact "`n"
|
||||||
|
If Not (View_#%m%_#%A_Index%_layoutMX = 1)
|
||||||
|
text .= "View_#" m "_#" A_Index "_layoutMX=" View_#%m%_#%A_Index%_layoutMX "`n"
|
||||||
|
If Not (View_#%m%_#%A_Index%_layoutMY = 1)
|
||||||
|
text .= "View_#" m "_#" A_Index "_layoutMY=" View_#%m%_#%A_Index%_layoutMY "`n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileAppend, %text%, %tmpfilename%
|
;; The FileMove below is an all-or-nothing replacement of the file.
|
||||||
If ErrorLevel {
|
;; We don't want to leave this half-finished.
|
||||||
If FileExist(tmpfilename)
|
FileAppend, %text%, %tmpfilename%
|
||||||
FileDelete, %tmpfilename%
|
If ErrorLevel {
|
||||||
}
|
If FileExist(tmpfilename)
|
||||||
Else
|
FileDelete, %tmpfilename%
|
||||||
FileMove, %tmpfilename%, %filename%, 1
|
}
|
||||||
|
Else
|
||||||
|
FileMove, %tmpfilename%, %target%, 1
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
;; Key definitions
|
||||||
* key definitions
|
;; Window management
|
||||||
*
|
#Down::View_activateWindow(+1)
|
||||||
* format: <modifier><key>::<function>(<argument>)
|
#Up::View_activateWindow(-1)
|
||||||
* modifier: ! = Alt (Mod1Mask), ^ = Ctrl (ControlMask), + = Shift (ShiftMask), # = LWin (Mod4Mask)
|
#+Down::View_shuffleWindow(+1)
|
||||||
*/
|
#+Up::View_shuffleWindow(-1)
|
||||||
#Down::View_activateWindow(+1) ; Activate the next window in the active view.
|
#+Enter::View_shuffleWindow(0)
|
||||||
#Up::View_activateWindow(-1) ; Activate the previous window in the active view.
|
#c::Manager_closeWindow()
|
||||||
#+Down::View_shuffleWindow(+1) ; Move the active window to the next position in the window list of the view.
|
#+d::Manager_toggleDecor()
|
||||||
#+Up::View_shuffleWindow(-1) ; Move the active window to the previous position in the window list of the view.
|
#+f::View_toggleFloating()
|
||||||
#+Enter::View_shuffleWindow(0) ; Move the active window to the first position in the window list of the view.
|
#+m::Manager_moveWindow()
|
||||||
#c::Manager_closeWindow() ; Close the active window.
|
#+s::Manager_sizeWindow()
|
||||||
#+d::Manager_toggleDecor() ; Show / Hide the title bar of the active window.
|
#+x::Manager_maximizeWindow()
|
||||||
#+f::View_toggleFloating() ; Toggle the floating status of the active window (i. e. dis- / regard it when tiling).
|
#i::Manager_getWindowInfo()
|
||||||
#+m::Manager_moveWindow() ; Move the active window by key (only floating windows).
|
#+i::Manager_getWindowList()
|
||||||
#+s::Manager_sizeWindow() ; Resize the active window by key (only floating windows).
|
|
||||||
#+x::Manager_maximizeWindow() ; Move and resize the active window to the size of the work area (only floating windows).
|
|
||||||
#i::Manager_getWindowInfo() ; Get information for the active window (id, title, class, process name, style, geometry, tags and floating state).
|
|
||||||
#+i::Manager_getWindowList() ; Get a window list for the active view (id, title and class).
|
|
||||||
#^i::Manager_logViewWindowList() ; Dump window information for the active view.
|
|
||||||
#+^i::Manager_logManagedWindowList() ; Dump window information for every managed window.
|
|
||||||
#^h::Manager_logHelp() ; Dump to the log an explanation of some of the other more cryptic log messages.
|
|
||||||
#^[::Log_decDebugLevel() ; Decrement the log debug level.
|
|
||||||
#^]::Log_incDebugLevel() ; Increment the log debug level.
|
|
||||||
|
|
||||||
#Tab::View_setLayout(-1) ; Set the previously set layout. You may also use View_setLayout(">") for setting the next layout in the layout array.
|
;; Window debugging
|
||||||
#f::View_setLayout(3) ; Set the 3rd defined layout (i. e. floating layout in the default configuration).
|
#^i::Manager_logViewWindowList()
|
||||||
#m::View_setLayout(2) ; Set the 2nd defined layout (i. e. monocle layout in the default configuration).
|
#+^i::Manager_logManagedWindowList()
|
||||||
#t::View_setLayout(1) ; Set the 1st defined layout (i. e. tile layout in the default configuration).
|
#^h::Manager_logHelp()
|
||||||
#Left::View_setMFactor(-0.05) ; Reduce the size of the master area in the active view (only for the "tile" layout).
|
#^[::Log_decDebugLevel()
|
||||||
#Right::View_setMFactor(+0.05) ; Enlarge the size of the master area in the active view (only for the "tile" layout).
|
#^]::Log_incDebugLevel()
|
||||||
#^t::View_rotateLayoutAxis(1, +1) ; Rotate the layout axis (i. e. 2 -> 1 = vertical layout, 1 -> 2 = horizontal layout, only for the "tile" layout).
|
|
||||||
#^Enter::View_rotateLayoutAxis(1, +2) ; Mirror the layout axis (i. e. -1 -> 1 / 1 -> -1 = master on the left / right side, -2 -> 2 / 2 -> -2 = master at top / bottom, only for the "tile" layout).
|
|
||||||
#^Tab::View_rotateLayoutAxis(2, +1) ; Rotate the master axis (i. e. 3 -> 1 = x-axis = horizontal stack, 1 -> 2 = y-axis = vertical stack, 2 -> 3 = z-axis = monocle, only for the "tile" layout).
|
|
||||||
#^+Tab::View_rotateLayoutAxis(3, +1) ; Rotate the stack axis (i. e. 3 -> 1 = x-axis = horizontal stack, 1 -> 2 = y-axis = vertical stack, 2 -> 3 = z-axis = monocle, only for the "tile" layout).
|
|
||||||
#^Up::View_setMY(+1) ; Increase the master Y dimension [1,9] (only for the "tile" layout).
|
|
||||||
#^Down::View_setMY(-1) ; Decrease the master Y dimension [1,9] (only for the "tile" layout).
|
|
||||||
#^Right::View_setMX(+1) ; Increase the master X dimension [1,9] (only for the "tile" layout).
|
|
||||||
#^Left::View_setMX(-1) ; Decrease the master X dimension [1,9] (only for the "tile" layout).
|
|
||||||
#+Left::View_setGapWidth(-2) ; Decrease the gap width by 2 px (only for the "tile" layout and even numbers; see the variable "Config_layoutGapWidth").
|
|
||||||
#+Right::View_setGapWidth(+2) ; Increase the gap width by 2 px (only for the "tile" layout and even numbers; see the variable "Config_layoutGapWidth").
|
|
||||||
|
|
||||||
|
;; Layout management
|
||||||
|
#Tab::View_setLayout(-1)
|
||||||
|
#f::View_setLayout(3)
|
||||||
|
#m::View_setLayout(2)
|
||||||
|
#t::View_setLayout(1)
|
||||||
|
#Left::View_setMFactor(-0.05)
|
||||||
|
#Right::View_setMFactor(+0.05)
|
||||||
|
#^t::View_rotateLayoutAxis(1, +1)
|
||||||
|
#^Enter::View_rotateLayoutAxis(1, +2)
|
||||||
|
#^Tab::View_rotateLayoutAxis(2, +1)
|
||||||
|
#^+Tab::View_rotateLayoutAxis(3, +1)
|
||||||
|
#^Up::View_setMY(+1)
|
||||||
|
#^Down::View_setMY(-1)
|
||||||
|
#^Right::View_setMX(+1)
|
||||||
|
#^Left::View_setMX(-1)
|
||||||
|
#+Left::View_setGapWidth(-2)
|
||||||
|
#+Right::View_setGapWidth(+2)
|
||||||
|
|
||||||
#BackSpace::Monitor_activateView(-1) ; Activate the previously activated view. You may also use Monitor_activateView("<") or Monitor_activateView(">") for activating the previous or next adjacent view.
|
;; View/Tag management
|
||||||
#+0::Monitor_setWindowTag(0) ; Tag the active window with all tags (1 ... Config_viewCount). You may also use Monitor_setWindowTag("<") or Monitor_setWindowTag(">") for setting the tag of the previous or next adjacent to the current view.
|
;#+n::View_toggleMargins()
|
||||||
#1::Monitor_activateView(1) ; Activate the view (choose one out of 1 ... Config_viewCount).
|
#BackSpace::Monitor_activateView(-1)
|
||||||
#+1::Monitor_setWindowTag(1) ; Tag the active window (choose one tag out of 1 ... Config_viewCount).
|
#+0::Monitor_setWindowTag(0)
|
||||||
#^1::Monitor_toggleWindowTag(1) ; Add / Remove the tag (1 ... Config_viewCount) for the active window, if it is not / is already set.
|
#1::Monitor_activateView(1)
|
||||||
|
#+1::Monitor_setWindowTag(1)
|
||||||
|
#^1::Monitor_toggleWindowTag(1)
|
||||||
#2::Monitor_activateView(2)
|
#2::Monitor_activateView(2)
|
||||||
#+2::Monitor_setWindowTag(2)
|
#+2::Monitor_setWindowTag(2)
|
||||||
#^2::Monitor_toggleWindowTag(2)
|
#^2::Monitor_toggleWindowTag(2)
|
||||||
|
@ -454,19 +438,22 @@ Config_saveSession(filename) {
|
||||||
#+9::Monitor_setWindowTag(9)
|
#+9::Monitor_setWindowTag(9)
|
||||||
#^9::Monitor_toggleWindowTag(9)
|
#^9::Monitor_toggleWindowTag(9)
|
||||||
|
|
||||||
#.::Manager_activateMonitor(+1) ; Activate the next monitor in a multi-monitor environment.
|
;; Monitor management
|
||||||
#,::Manager_activateMonitor(-1) ; Activate the previous monitor in a multi-monitor environment.
|
#.::Manager_activateMonitor(+1)
|
||||||
#+.::Manager_setWindowMonitor(+1) ; Set the active window to the active view on the next monitor in a multi-monitor environment.
|
#,::Manager_activateMonitor(-1)
|
||||||
#+,::Manager_setWindowMonitor(-1) ; Set the active window to the active view on the previous monitor in a multi-monitor environment.
|
#+.::Manager_setWindowMonitor(+1)
|
||||||
#^+.::Manager_setViewMonitor(+1) ; Set all windows of the active view on the active view of the next monitor in a multi-monitor environment.
|
#+,::Manager_setWindowMonitor(-1)
|
||||||
#^+,::Manager_setViewMonitor(-1) ; Set all windows of the active view on the active view of the previous monitor in a multi-monitor environment.
|
#^+.::Manager_setViewMonitor(+1)
|
||||||
|
#^+,::Manager_setViewMonitor(-1)
|
||||||
|
|
||||||
#+Space::Monitor_toggleBar() ; Hide / Show the bar (bug.n status bar) on the active monitor.
|
;; GUI management
|
||||||
#Space::Monitor_toggleTaskBar() ; Hide / Show the task bar.
|
#+Space::Monitor_toggleBar()
|
||||||
#y::Bar_toggleCommandGui() ; Open the command GUI for executing programmes or bug.n functions.
|
#Space::Monitor_toggleTaskBar()
|
||||||
#^e::Run, edit %Config_filePath% ; Open the configuration file in the standard text editor.
|
#y::Bar_toggleCommandGui()
|
||||||
#^s::Config_UI_saveSession() ; Save the current state of monitors, views, layouts to the configuration file.
|
|
||||||
#^r::Main_reload() ; Reload bug.n (i. e. the configuration and its dependent settings) without deleting the window lists of bug.n and restoring windows.
|
;; Administration
|
||||||
; It does not reset internal configuration variables, the tray icon or menu, hotkeys (unless set explicitly in Config.ini), individual window settings like Config_showBorder (since windows might be hidden) or hiding the title bar, the monitor count or views.
|
#^e::Run, edit %Config_filePath%
|
||||||
; It does not reload functions. Changed rules are only applied to new windows.
|
#^s::Config_UI_saveSession()
|
||||||
#^q::ExitApp ; Quit bug.n, restore the default Windows UI and show all windows.
|
#^r::Main_reload()
|
||||||
|
;#^+r::Reload
|
||||||
|
#^q::ExitApp
|
||||||
|
|
336
src/Main.ahk
336
src/Main.ahk
|
@ -1,27 +1,27 @@
|
||||||
/**
|
/*
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
NAME := "bug.n"
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
|
NAME := "bug.n"
|
||||||
VERSION := "8.3.0"
|
VERSION := "8.3.0"
|
||||||
|
|
||||||
; script settings
|
;; Script settings
|
||||||
OnExit, Main_cleanup
|
OnExit, Main_cleanup
|
||||||
SetBatchLines, -1
|
SetBatchLines, -1
|
||||||
SetTitleMatchMode, 3
|
SetTitleMatchMode, 3
|
||||||
|
@ -31,154 +31,215 @@ SetWinDelay, 10
|
||||||
#SingleInstance force
|
#SingleInstance force
|
||||||
#WinActivateForce
|
#WinActivateForce
|
||||||
|
|
||||||
; pseudo main function
|
;; Pseudo main function
|
||||||
|
If 0 = 1
|
||||||
|
Main_dataDir = %1%
|
||||||
|
Else
|
||||||
|
Main_dataDir = %A_ScriptDir%
|
||||||
|
|
||||||
Main_setup()
|
Main_setup()
|
||||||
|
|
||||||
Log_init(Main_logFile, False)
|
Log_init(Main_logFile, False)
|
||||||
|
|
||||||
Log_msg("====== Initializing ======")
|
Log_msg("====== Initializing ======")
|
||||||
If 0 = 1
|
If 0 = 1
|
||||||
Config_filePath = %1%
|
Config_filePath = %1%
|
||||||
Config_init()
|
Config_init()
|
||||||
|
|
||||||
Menu, Tray, Tip, %NAME% %VERSION%
|
Menu, Tray, Tip, %NAME% %VERSION%
|
||||||
IfExist %A_ScriptDir%\images\kfm.ico
|
IfExist %A_ScriptDir%\images\kfm.ico
|
||||||
Menu, Tray, Icon, %A_ScriptDir%\images\kfm.ico
|
Menu, Tray, Icon, %A_ScriptDir%\images\kfm.ico
|
||||||
Menu, Tray, NoStandard
|
Menu, Tray, NoStandard
|
||||||
Menu, Tray, Add, Toggle bar, Main_toggleBar
|
Menu, Tray, Add, Toggle bar, Main_toggleBar
|
||||||
Menu, Tray, Add, Help, Main_help
|
Menu, Tray, Add, Help, Main_help
|
||||||
Menu, Tray, Add,
|
Menu, Tray, Add,
|
||||||
Menu, Tray, Add, Exit, Main_quit
|
Menu, Tray, Add, Exit, Main_quit
|
||||||
|
|
||||||
Manager_init()
|
ResourceMonitor_init()
|
||||||
Log_msg("====== Running ======")
|
Manager_init()
|
||||||
Return ; end of the auto-execute section
|
Log_msg("====== Running ======")
|
||||||
|
Return ;; end of the auto-execute section
|
||||||
|
|
||||||
/**
|
;; Function & label definitions
|
||||||
* function & label definitions
|
Main_cleanup:
|
||||||
*/
|
Log_msg("====== Cleaning up ======")
|
||||||
Main_cleanup: ; The labels with "ExitApp" or "Return" at the end and hotkeys have to be after the auto-execute section.
|
If Config_autoSaveSession
|
||||||
Log_msg("====== Cleaning up ======")
|
Config_saveSession(Config_filePath, Config_filePath)
|
||||||
If Config_autoSaveSession
|
Manager_cleanup()
|
||||||
Config_saveSession(Config_filePath)
|
ResourceMonitor_cleanup()
|
||||||
Manager_cleanup()
|
Log_msg("====== Exiting ======")
|
||||||
DllCall("CloseHandle", "UInt", Bar_hDrive) ; used in Bar_getDiskLoad
|
|
||||||
Log_msg("====== Exiting ======")
|
|
||||||
ExitApp
|
ExitApp
|
||||||
|
|
||||||
|
Main_evalCommand(command)
|
||||||
|
{
|
||||||
|
type := SubStr(command, 1, 5)
|
||||||
|
If (type = "Run, ")
|
||||||
|
{
|
||||||
|
parameters := SubStr(command, 6)
|
||||||
|
If InStr(parameters, ", ")
|
||||||
|
{
|
||||||
|
StringSplit, parameter, parameters, `,
|
||||||
|
If (parameter0 = 2)
|
||||||
|
{
|
||||||
|
StringTrimLeft, parameter2, parameter2, 1
|
||||||
|
Run, %parameter1%, %parameter2%
|
||||||
|
}
|
||||||
|
Else If (parameter0 > 2)
|
||||||
|
{
|
||||||
|
StringTrimLeft, parameter2, parameter2, 1
|
||||||
|
StringTrimLeft, parameter3, parameter3, 1
|
||||||
|
Run, %parameter1%, %parameter2%, %parameter3%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
Run, %parameters%
|
||||||
|
}
|
||||||
|
Else If (type = "Send ")
|
||||||
|
Send % SubStr(command, 6)
|
||||||
|
Else If (command = "Reload")
|
||||||
|
Reload
|
||||||
|
Else If (command = "ExitApp")
|
||||||
|
ExitApp
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
i := InStr(command, "(")
|
||||||
|
j := InStr(command, ")", False, i)
|
||||||
|
If i And j
|
||||||
|
{
|
||||||
|
functionName := SubStr(command, 1, i - 1)
|
||||||
|
functionArguments := SubStr(command, i + 1, j - (i + 1))
|
||||||
|
StringSplit, functionArgument, functionArguments, `,
|
||||||
|
If (functionArgument0 < 2)
|
||||||
|
%functionName%(functionArguments)
|
||||||
|
Else If (functionArgument0 = 2)
|
||||||
|
{
|
||||||
|
StringTrimLeft, functionArgument2, functionArgument2, 1
|
||||||
|
%functionName%(functionArgument1, functionArgument2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Main_help:
|
Main_help:
|
||||||
Run, explore %A_ScriptDir%\docs
|
Run, explore %A_ScriptDir%\doc
|
||||||
Return
|
Return
|
||||||
|
|
||||||
Main_quit:
|
Main_quit:
|
||||||
ExitApp
|
ExitApp
|
||||||
Return
|
Return
|
||||||
|
|
||||||
; Create bug.n-specific directories.
|
; Create bug.n-specific directories.
|
||||||
Main_makeDir(dirName) {
|
Main_makeDir(dirName) {
|
||||||
IfNotExist, %dirName%
|
IfNotExist, %dirName%
|
||||||
{
|
{
|
||||||
FileCreateDir, %dirName%
|
FileCreateDir, %dirName%
|
||||||
If ErrorLevel {
|
If ErrorLevel
|
||||||
MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting.
|
{
|
||||||
ExitApp
|
MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting.
|
||||||
}
|
ExitApp
|
||||||
}
|
}
|
||||||
Else {
|
}
|
||||||
FileGetAttrib, attrib, %dirName%
|
Else
|
||||||
IfNotInString, attrib, D
|
{
|
||||||
{
|
FileGetAttrib, attrib, %dirName%
|
||||||
MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting.
|
IfNotInString, attrib, D
|
||||||
ExitApp
|
{
|
||||||
}
|
MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting.
|
||||||
}
|
ExitApp
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Main_setup() {
|
Main_setup() {
|
||||||
Local winAppDir
|
Local winAppDir
|
||||||
|
|
||||||
Main_appDir := ""
|
Main_appDir := ""
|
||||||
Main_logFile := ""
|
Main_logFile := ""
|
||||||
Main_dataDir := ""
|
Main_dataDir := ""
|
||||||
Main_autoLayout := ""
|
Main_autoLayout := ""
|
||||||
Main_autoWindowState := ""
|
Main_autoWindowState := ""
|
||||||
|
|
||||||
EnvGet, winAppDir, APPDATA
|
EnvGet, winAppDir, APPDATA
|
||||||
|
|
||||||
Main_appDir := winAppDir . "\bug.n"
|
Main_appDir := winAppDir . "\bug.n"
|
||||||
Main_logFile := Main_appDir . "\bugn_log.txt"
|
Main_logFile := Main_appDir . "\bugn_log.txt"
|
||||||
Main_dataDir := Main_appDir . "\data"
|
Main_dataDir := Main_appDir . "\data"
|
||||||
Main_autoLayout := Main_dataDir . "\_Layout.ini"
|
Main_autoLayout := Main_dataDir . "\_Layout.ini"
|
||||||
Main_autoWindowState := Main_dataDir . "\_WindowState.ini"
|
Main_autoWindowState := Main_dataDir . "\_WindowState.ini"
|
||||||
|
|
||||||
Main_makeDir(Main_appDir)
|
Main_makeDir(Main_appDir)
|
||||||
Main_makeDir(Main_dataDir)
|
Main_makeDir(Main_dataDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Main_reload() {
|
Main_reload()
|
||||||
Local i, ncm, ncmSize
|
{
|
||||||
|
Local i, ncm, ncmSize
|
||||||
|
|
||||||
; Reset border color, padding and witdh.
|
;; Reset border color, padding and witdh.
|
||||||
If Config_selBorderColor
|
If Config_selBorderColor
|
||||||
DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Manager_normBorderColor)
|
DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Manager_normBorderColor)
|
||||||
If (Config_borderWidth > 0) Or (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA) {
|
If (Config_borderWidth > 0) Or (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA)
|
||||||
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
|
{
|
||||||
NumPut(ncmSize, ncm, 0, "UInt")
|
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
|
||||||
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
NumPut(ncmSize, ncm, 0, "UInt")
|
||||||
If (Config_borderWidth > 0)
|
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
||||||
NumPut(Manager_borderWidth, ncm, 4, "Int")
|
If (Config_borderWidth > 0)
|
||||||
If (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA)
|
NumPut(Manager_borderWidth, ncm, 4, "Int")
|
||||||
NumPut(Manager_borderPadding, ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
|
If (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA)
|
||||||
DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
NumPut(Manager_borderPadding, ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
|
||||||
}
|
DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
||||||
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_REMOVE := 0x1), "UInt", &Bar_appBarData)
|
}
|
||||||
; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
|
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_REMOVE := 0x1), "UInt", &Bar_appBarData)
|
||||||
|
;; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
|
||||||
|
|
||||||
Config_init()
|
Config_init()
|
||||||
; Windows UI
|
; Windows UI
|
||||||
If Config_selBorderColor {
|
If Config_selBorderColor {
|
||||||
SetFormat, Integer, hex
|
SetFormat, Integer, hex
|
||||||
Manager_normBorderColor := DllCall("GetSysColor", "Int", 10)
|
Manager_normBorderColor := DllCall("GetSysColor", "Int", 10)
|
||||||
SetFormat, Integer, d
|
SetFormat, Integer, d
|
||||||
DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Config_selBorderColor)
|
DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Config_selBorderColor)
|
||||||
}
|
}
|
||||||
If (Config_borderWidth > 0) Or (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA) {
|
If (Config_borderWidth > 0) Or (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA) {
|
||||||
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
|
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
|
||||||
NumPut(ncmSize, ncm, 0, "UInt")
|
NumPut(ncmSize, ncm, 0, "UInt")
|
||||||
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
||||||
Manager_borderWidth := NumGet(ncm, 4, "Int")
|
Manager_borderWidth := NumGet(ncm, 4, "Int")
|
||||||
Manager_borderPadding := NumGet(ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
|
Manager_borderPadding := NumGet(ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
|
||||||
If (Config_borderWidth > 0)
|
If (Config_borderWidth > 0)
|
||||||
NumPut(Config_borderWidth, ncm, 4, "Int")
|
NumPut(Config_borderWidth, ncm, 4, "Int")
|
||||||
If (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA)
|
If (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA)
|
||||||
NumPut(Config_borderPadding, ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
|
NumPut(Config_borderPadding, ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int")
|
||||||
DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
|
||||||
}
|
}
|
||||||
Bar_getHeight()
|
Bar_getHeight()
|
||||||
Loop, % Manager_monitorCount {
|
Loop, % Manager_monitorCount
|
||||||
Monitor_getWorkArea(A_Index)
|
{
|
||||||
Bar_init(A_Index)
|
Monitor_getWorkArea(A_Index)
|
||||||
}
|
Bar_init(A_Index)
|
||||||
Bar_initCmdGui()
|
}
|
||||||
If Not (Manager_showTaskBar = Config_showTaskBar)
|
Bar_initCmdGui()
|
||||||
Monitor_toggleTaskBar()
|
If Not (Manager_showTaskBar = Config_showTaskBar)
|
||||||
Bar_updateStatus()
|
Monitor_toggleTaskBar()
|
||||||
Bar_updateTitle()
|
Bar_updateStatus()
|
||||||
Loop, % Manager_monitorCount {
|
Bar_updateTitle()
|
||||||
i := A_Index
|
Loop, % Manager_monitorCount
|
||||||
Loop, % Config_viewCount
|
{
|
||||||
Bar_updateView(i, A_Index)
|
i := A_Index
|
||||||
View_arrange(i, Monitor_#%i%_aView_#1)
|
Loop, % Config_viewCount
|
||||||
}
|
{
|
||||||
Manager_registerShellHook()
|
Bar_updateView(i, A_Index)
|
||||||
SetTimer, Bar_loop, %Config_readinInterval%
|
}
|
||||||
|
View_arrange(i, Monitor_#%i%_aView_#1)
|
||||||
|
}
|
||||||
|
Manager_registerShellHook()
|
||||||
|
SetTimer, Bar_loop, %Config_readinInterval%
|
||||||
}
|
}
|
||||||
|
|
||||||
Main_toggleBar:
|
Main_toggleBar:
|
||||||
Monitor_toggleBar()
|
Monitor_toggleBar()
|
||||||
Return
|
Return
|
||||||
|
|
||||||
#Include Log.ahk
|
#Include Log.ahk
|
||||||
|
@ -187,4 +248,5 @@ Return
|
||||||
#Include Config.ahk
|
#Include Config.ahk
|
||||||
#Include Manager.ahk
|
#Include Manager.ahk
|
||||||
#Include Monitor.ahk
|
#Include Monitor.ahk
|
||||||
|
#Include ResourceMonitor.ahk
|
||||||
#Include View.ahk
|
#Include View.ahk
|
||||||
|
|
|
@ -92,7 +92,7 @@ Manager_maintenance() {
|
||||||
; @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)
|
;Log_msg("Saving layout state: " . Main_autoLayout)
|
||||||
Config_saveSession(Main_autoLayout)
|
Config_saveSession(Config_filaPath, Main_autoLayout)
|
||||||
Manager_layoutDirty := 0
|
Manager_layoutDirty := 0
|
||||||
;}
|
;}
|
||||||
|
|
||||||
|
|
163
src/ResourceMonitor.ahk
Normal file
163
src/ResourceMonitor.ahk
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
|
ResourceMonitor_init()
|
||||||
|
{
|
||||||
|
ResourceMonitor_hDrive := DllCall("CreateFile", "Str", "\\.\PhysicalDrive0", "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 0)
|
||||||
|
ResourceMonitor_getNetworkInterface()
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceMonitor_cleanup()
|
||||||
|
{
|
||||||
|
DllCall("CloseHandle", "UInt", ResourceMonitor_hDrive) ;; used in ResourceMonitor_getDiskLoad
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceMonitor_getText()
|
||||||
|
{
|
||||||
|
Global Config_readinCpu, Config_readinDate, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad
|
||||||
|
|
||||||
|
text := ""
|
||||||
|
If Config_readinCpu
|
||||||
|
text .= " CPU: " ResourceMonitor_getSystemTimes() "% "
|
||||||
|
If Config_readinMemoryUsage
|
||||||
|
{
|
||||||
|
If Config_readinCpu
|
||||||
|
text .= "|"
|
||||||
|
text .= " RAM: " ResourceMonitor_getMemoryUsage() "% "
|
||||||
|
}
|
||||||
|
If Config_readinDiskLoad
|
||||||
|
{
|
||||||
|
If (Config_readinCpu Or Config_readinMemoryUsage)
|
||||||
|
text .= "|"
|
||||||
|
ResourceMonitor_getDiskLoad(rLoad, wLoad)
|
||||||
|
text .= " Dr: " rLoad "% | Dw: " wLoad "% "
|
||||||
|
}
|
||||||
|
If Config_readinNetworkLoad
|
||||||
|
{
|
||||||
|
If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad)
|
||||||
|
text .= "|"
|
||||||
|
ResourceMonitor_getNetworkLoad(upLoad, dnLoad)
|
||||||
|
text .= " UP: " upLoad " KB/s | dn: " dnLoad " KB/s "
|
||||||
|
}
|
||||||
|
If Config_readinDate And (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad Or Config_readinNetworkLoad)
|
||||||
|
text .= "|"
|
||||||
|
|
||||||
|
Return, text
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceMonitor_getDiskLoad(ByRef readLoad, ByRef writeLoad)
|
||||||
|
{
|
||||||
|
Global ResourceMonitor_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", ResourceMonitor_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)
|
||||||
|
|
||||||
|
ResourceMonitor_getMemoryUsage()
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
|
||||||
|
ResourceMonitor_getNetworkInterface()
|
||||||
|
{
|
||||||
|
Global ResourceMonitor_networkInterface, ResourceMonitor_networkInterfaceTable
|
||||||
|
|
||||||
|
DllCall("iphlpapi\GetNumberOfInterfaces", "UIntP", n)
|
||||||
|
nSize := 4 + 860 * n + 8
|
||||||
|
VarSetCapacity(ResourceMonitor_networkInterfaceTable, nSize)
|
||||||
|
If Not DllCall("iphlpapi\GetIfTable", "UInt", &ResourceMonitor_networkInterfaceTable, "UIntP", nSize, "Int", False)
|
||||||
|
{
|
||||||
|
Loop, 2
|
||||||
|
{
|
||||||
|
i := 0
|
||||||
|
j := A_Index
|
||||||
|
Loop, % NumGet(ResourceMonitor_networkInterfaceTable)
|
||||||
|
{
|
||||||
|
If NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 544) < 4
|
||||||
|
|| NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 516) = 24
|
||||||
|
Continue
|
||||||
|
i += 1
|
||||||
|
dn_#%i%_#%j% := NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 552)
|
||||||
|
up_#%i%_#%j% := NumGet(ResourceMonitor_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)
|
||||||
|
{
|
||||||
|
ResourceMonitor_networkInterface := i
|
||||||
|
Break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
|
||||||
|
|
||||||
|
ResourceMonitor_getNetworkLoad(ByRef upLoad, ByRef dnLoad)
|
||||||
|
{
|
||||||
|
Global ResourceMonitor_networkInterface, ResourceMonitor_networkInterfaceTable
|
||||||
|
Static dn_#0, t_#0, up_#0
|
||||||
|
|
||||||
|
DllCall("iphlpapi\GetIfEntry", "UInt", &ResourceMonitor_networkInterfaceTable + 4 + 860 * (ResourceMonitor_networkInterface - 1))
|
||||||
|
dn_#1 := NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (ResourceMonitor_networkInterface - 1) + 552) ;; Total Incoming Bytes
|
||||||
|
up_#1 := NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (ResourceMonitor_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)
|
||||||
|
|
||||||
|
ResourceMonitor_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)
|
Loading…
Reference in a new issue