From 01e5239b25e79d06a2bc61f82396dc0b76918c5f Mon Sep 17 00:00:00 2001 From: joten Date: Mon, 5 Dec 2011 22:20:38 +0100 Subject: [PATCH] updated version: 8.2.1.02 fix bug #018431: Immediate run-time errors running bug.n built from source workaround bug #018364: Evernote: new note feature #005446: Reload function --- src/Bar.ahk | 10 ++++---- src/Config.ahk | 37 ++++++++++++++++++------------ src/Main.ahk | 61 ++++++++++++++++++++++++++++++++++++++++++++++++- src/Manager.ahk | 52 +++++++++++++++++++++++++++-------------- src/Monitor.ahk | 2 +- src/View.ahk | 2 +- 6 files changed, 125 insertions(+), 39 deletions(-) diff --git a/src/Bar.ahk b/src/Bar.ahk index 282f038..b919ef4 100644 --- a/src/Bar.ahk +++ b/src/Bar.ahk @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * @version 8.2.1.01 (31.08.2011) + * @version 8.2.1.02 (05.12.2011) */ Bar_init(m) { @@ -23,7 +23,7 @@ Bar_init(m) { If (SubStr(Config_barWidth, 0) = "%") { StringTrimRight, wndWidth, Config_barWidth, 1 - wndWidth := Monitor_#%m%_width * wndWidth / 100 + wndWidth := Round(Monitor_#%m%_width * wndWidth / 100) } Else wndWidth := Config_barWidth Monitor_#%m%_barWidth := wndWidth @@ -135,9 +135,9 @@ Bar_init(m) { y1 := Monitor_#%m%_barY If Monitor_#%m%_showBar - Gui, Show, +NoActivate x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle% + Gui, Show, NoActivate x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle% Else - Gui, Show, +NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle% + Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle% wndId := WinExist(wndTitle) If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor) { trayWndId := WinExist("ahk_class Shell_TrayWnd") @@ -342,7 +342,7 @@ Bar_evaluateCommand() { Else If (Bar_command_#1 = "activate prev") Manager_activateMonitor(-1) } Else If (Bar_command_#1 = "Reload") - Reload + Main_reload() Else If (Bar_command_#1 = "Quit") ExitApp diff --git a/src/Config.ahk b/src/Config.ahk index 3165a58..d065f99 100644 --- a/src/Config.ahk +++ b/src/Config.ahk @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * @version 8.2.1.01 (14.09.2011) + * @version 8.2.1.02 (24.09.2011) */ Config_init() { @@ -29,6 +29,11 @@ Config_init() { 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. @@ -44,19 +49,20 @@ Config_init() { 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_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_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 actiated 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_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_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_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 actiated 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 := ";;<window style (hexadecimal number or blank)>; ; <is managed (1 = True or 0 = False)>; @@ -413,4 +419,7 @@ Config_saveSession() { #y::Bar_toggleCommandGui() ; Open the command GUI for executing programmes or bug.n functions. #^e::Run, edit %Config_filePath% ; Open the configuration file in the standard text editor. #^s::Config_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. + ; 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. + ; It does not reload functions. Changed rules are only applied to new windows. #^q::ExitApp ; Quit bug.n, restore the default Windows UI and show all windows. diff --git a/src/Main.ahk b/src/Main.ahk index b8cce58..d800b83 100644 --- a/src/Main.ahk +++ b/src/Main.ahk @@ -15,7 +15,7 @@ * 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.2.1.01 (14.09.2011) + * @version 8.2.1.02 (24.09.2011) */ NAME := "bug.n" @@ -65,6 +65,65 @@ Main_quit: ExitApp Return +Main_reload() { + Local i, ncm, ncmSize + + ; Reset border color, padding and witdh. + If Config_selBorderColor + DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Manager_normBorderColor) + 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") + DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0) + If (Config_borderWidth > 0) + NumPut(Manager_borderWidth, ncm, 4, "Int") + If (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA) + 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) + + Config_init() + ; Windows UI + If Config_selBorderColor { + SetFormat, Integer, hex + Manager_normBorderColor := DllCall("GetSysColor", "Int", 10) + SetFormat, Integer, d + DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Config_selBorderColor) + } + 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") + DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0) + Manager_borderWidth := NumGet(ncm, 4, "Int") + Manager_borderPadding := NumGet(ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int") + If (Config_borderWidth > 0) + NumPut(Config_borderWidth, ncm, 4, "Int") + If (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA) + NumPut(Config_borderPadding, ncm, 40 + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), "Int") + DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0) + } + Bar_getHeight() + Loop, % Manager_monitorCount { + Monitor_getWorkArea(A_Index) + Bar_init(A_Index) + } + Bar_initCmdGui() + If Not (Manager_showTaskBar = Config_showTaskBar) + Monitor_toggleTaskBar() + Bar_updateStatus() + Bar_updateTitle() + Loop, % Manager_monitorCount { + i := A_Index + Loop, % Config_viewCount + Bar_updateView(i, A_Index) + View_arrange(i, Monitor_#%i%_aView_#1) + } + Manager_registerShellHook() + SetTimer, Bar_loop, %Config_readinInterval% +} + Main_toggleBar: Monitor_toggleBar() Return diff --git a/src/Manager.ahk b/src/Manager.ahk index c618412..7a015af 100644 --- a/src/Manager.ahk +++ b/src/Manager.ahk @@ -15,7 +15,7 @@ * 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.2.1.01 (21.09.2011) + * @version 8.2.1.02 (24.09.2011) */ Manager_init() { @@ -332,7 +332,7 @@ Manager_moveWindow() { } Manager_onShellMessage(wParam, lParam) { - Local a, aWndClass, aWndHeight, aWndId, aWndTitle, aWndWidth, aWndX, aWndY, flag, m, tags, wndClass, wndId, wndPName, wndTitle, x, y + Local a, aWndClass, aWndHeight, aWndId, aWndTitle, aWndWidth, aWndX, aWndY, flag, m, t, wndClass, wndId, wndIds, wndPName, wndTitle, x, y SetFormat, Integer, hex lParam := lParam+0 @@ -353,7 +353,7 @@ Manager_onShellMessage(wParam, lParam) { } If (wParam = 1 Or wParam = 2 Or wParam = 4 Or wParam = 6 Or wParam = 32772) And lParam And Not Manager_hideShow And Not Manager_focus { - If Not (wParam = 4 Or wParam = 32772) { + If Not (wParam = 4 Or wParam = 32772) If Not wndClass And Not (wParam = 2) { WinGetClass, wndClass, ahk_id %lParam% If wndClass { @@ -362,14 +362,13 @@ Manager_onShellMessage(wParam, lParam) { } Else Sleep, %Config_shellMsgDelay% } - } If (wParam = 1 Or wParam = 6) And Not InStr(Manager_allWndIds, lParam ";") And Not InStr(Manager_managedWndIds, lParam ";") a := Manager_manage(lParam) Else { flag := True - a := Manager_sync(tags) - If tags + a := Manager_sync(wndIds) + If wndIds a := False } If a { @@ -385,12 +384,33 @@ Manager_onShellMessage(wParam, lParam) { Manager_aMonitor := m } - If tags - Loop, % Config_viewCount - If (tags & 1 << A_Index - 1) { - Monitor_activateView(A_Index) - Break + If wndIds { + If (Config_onActiveHiddenWnds = "view") { + wndId := SubStr(wndIds, 1, InStr(wndIds, ";") - 1) + Loop, % Config_viewCount + If (Manager_#%wndId%_tags & 1 << A_Index - 1) { + Monitor_activateView(A_Index) + Break + } + } Else { + StringTrimRight, wndIds, wndIds, 1 + StringSplit, wndId, wndIds, `; + If (Config_onActiveHiddenWnds = "hide") { + Loop, % wndId0 + WinHide, % "ahk_id " wndId%A_Index% + } Else If (Config_onActiveHiddenWnds = "tag") { + t := Monitor_#%Manager_aMonitor%_aView_#1 + Loop, % wndId0 { + wndId := wndId%A_Index% + View_#%Manager_aMonitor%_#%t%_wndIds := wndId ";" View_#%Manager_aMonitor%_#%t%_wndIds + View_#%Manager_aMonitor%_#%t%_aWndId := wndId + Manager_#%wndId%_tags += 1 << t - 1 + } + Bar_updateView(Manager_aMonitor, t) + View_arrange(Manager_aMonitor, t) } + } + } Bar_updateTitle() } @@ -478,8 +498,8 @@ Manager_sizeWindow() { SendMessage, WM_SYSCOMMAND, SC_SIZE, , , ahk_id %aWndId% } -Manager_sync(ByRef tags = 0) { - Local a, aWndId, flag, shownWndIds, v, visibleWndIds, wndId +Manager_sync(ByRef wndIds = "") { + Local a, flag, shownWndIds, v, visibleWndIds, wndId Loop, % Manager_monitorCount { v := Monitor_#%A_Index%_aView_#1 @@ -493,10 +513,8 @@ Manager_sync(ByRef tags = 0) { flag := Manager_manage(wndId%A_Index%) If flag a := flag - } Else { - aWndId := wndId%A_Index% - tags := Manager_#%aWndId%_tags - } + } Else + wndIds .= wndId%A_Index% ";" } visibleWndIds := visibleWndIds wndId%A_Index% ";" } diff --git a/src/Monitor.ahk b/src/Monitor.ahk index 9c0a2db..09f2670 100644 --- a/src/Monitor.ahk +++ b/src/Monitor.ahk @@ -15,7 +15,7 @@ * 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.2.1.01 (18.09.2011) + * @version 8.2.1.02 (18.09.2011) */ Monitor_init(m) { diff --git a/src/View.ahk b/src/View.ahk index 953c6a4..c48934e 100644 --- a/src/View.ahk +++ b/src/View.ahk @@ -15,7 +15,7 @@ * 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.2.1.01 (11.08.2011) + * @version 8.2.1.02 (11.08.2011) */ View_init(m, v) {