refurbished 'Main.ahk'
This commit is contained in:
parent
590017c0b0
commit
b68451e9d3
2 changed files with 67 additions and 82 deletions
66
src/Main.ahk
66
src/Main.ahk
|
@ -21,7 +21,7 @@
|
||||||
NAME := "bug.n"
|
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,11 +31,11 @@ SetWinDelay, 10
|
||||||
#SingleInstance force
|
#SingleInstance force
|
||||||
#WinActivateForce
|
#WinActivateForce
|
||||||
|
|
||||||
; pseudo main function
|
;; Pseudo main function
|
||||||
If 0 = 1
|
If 0 = 1
|
||||||
Main_dataDir = %1%
|
Main_dataDir = %1%
|
||||||
Else
|
Else
|
||||||
Main_dataDir = %A_ScriptDir% ;; %A_ScriptDir% is the directory, in which 'Main.ahk' or the executable of bug.n is saved.
|
Main_dataDir = %A_ScriptDir%
|
||||||
Debug_initLog(Main_dataDir "\log.txt", 0, False)
|
Debug_initLog(Main_dataDir "\log.txt", 0, False)
|
||||||
Config_filePath := Main_dataDir "\config.ini"
|
Config_filePath := Main_dataDir "\config.ini"
|
||||||
Config_init()
|
Config_init()
|
||||||
|
@ -50,17 +50,15 @@ SetWinDelay, 10
|
||||||
Menu, Tray, Add, Exit, Main_quit
|
Menu, Tray, Add, Exit, Main_quit
|
||||||
|
|
||||||
Manager_init()
|
Manager_init()
|
||||||
Return ; end of the auto-execute section
|
Return ;; end of the auto-execute section
|
||||||
|
|
||||||
/**
|
;; Function & label definitions
|
||||||
* function & label definitions
|
Main_cleanup:
|
||||||
*/
|
|
||||||
Main_cleanup: ; The labels with "ExitApp" or "Return" at the end and hotkeys have to be after the auto-execute section.
|
|
||||||
Debug_logMessage("Cleaning up", 0)
|
Debug_logMessage("Cleaning up", 0)
|
||||||
If Config_autoSaveSession
|
If Config_autoSaveSession
|
||||||
Config_saveSession()
|
Config_saveSession()
|
||||||
Manager_cleanup()
|
Manager_cleanup()
|
||||||
DllCall("CloseHandle", "UInt", Bar_hDrive) ; used in Bar_getDiskLoad
|
DllCall("CloseHandle", "UInt", Bar_hDrive) ;; used in Bar_getDiskLoad
|
||||||
Debug_logMessage("Exiting bug.n", 0)
|
Debug_logMessage("Exiting bug.n", 0)
|
||||||
ExitApp
|
ExitApp
|
||||||
|
|
||||||
|
@ -72,47 +70,20 @@ Main_quit:
|
||||||
ExitApp
|
ExitApp
|
||||||
Return
|
Return
|
||||||
|
|
||||||
Main_reload() {
|
Main_reload()
|
||||||
Local i, ncm, ncmSize
|
{
|
||||||
|
Local i
|
||||||
|
|
||||||
|
Manager_resetWindowBorder()
|
||||||
|
|
||||||
; 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)
|
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)
|
;; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
|
||||||
|
|
||||||
Config_init()
|
Config_init()
|
||||||
; Windows UI
|
Manager_setWindowBorder()
|
||||||
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()
|
Bar_getHeight()
|
||||||
Loop, % Manager_monitorCount {
|
Loop, % Manager_monitorCount
|
||||||
|
{
|
||||||
Monitor_getWorkArea(A_Index)
|
Monitor_getWorkArea(A_Index)
|
||||||
Bar_init(A_Index)
|
Bar_init(A_Index)
|
||||||
}
|
}
|
||||||
|
@ -121,10 +92,13 @@ Main_reload() {
|
||||||
Monitor_toggleTaskBar()
|
Monitor_toggleTaskBar()
|
||||||
Bar_updateStatus()
|
Bar_updateStatus()
|
||||||
Bar_updateTitle()
|
Bar_updateTitle()
|
||||||
Loop, % Manager_monitorCount {
|
Loop, % Manager_monitorCount
|
||||||
|
{
|
||||||
i := A_Index
|
i := A_Index
|
||||||
Loop, % Config_viewCount
|
Loop, % Config_viewCount
|
||||||
|
{
|
||||||
Bar_updateView(i, A_Index)
|
Bar_updateView(i, A_Index)
|
||||||
|
}
|
||||||
View_arrange(i, Monitor_#%i%_aView_#1)
|
View_arrange(i, Monitor_#%i%_aView_#1)
|
||||||
}
|
}
|
||||||
Manager_registerShellHook()
|
Manager_registerShellHook()
|
||||||
|
|
|
@ -19,28 +19,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Manager_init() {
|
Manager_init() {
|
||||||
Local ncm, ncmSize
|
Global
|
||||||
|
|
||||||
; 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Manager_setWindowBorder()
|
||||||
Bar_getHeight()
|
Bar_getHeight()
|
||||||
Manager_aMonitor := 1
|
Manager_aMonitor := 1
|
||||||
Manager_taskBarMonitor := ""
|
Manager_taskBarMonitor := ""
|
||||||
|
@ -137,19 +118,7 @@ Manager_cleanup() {
|
||||||
|
|
||||||
WinGet, aWndId, ID, A
|
WinGet, aWndId, ID, A
|
||||||
|
|
||||||
; Reset border color, padding and witdh.
|
Manager_resetWindowBorder()
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
; Show borders and title bars.
|
; Show borders and title bars.
|
||||||
StringTrimRight, wndIds, Manager_managedWndIds, 1
|
StringTrimRight, wndIds, Manager_managedWndIds, 1
|
||||||
|
@ -630,6 +599,24 @@ Manager_registerShellHook() {
|
||||||
}
|
}
|
||||||
; SKAN: How to Hook on to Shell to receive its messages? (http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323)
|
; SKAN: How to Hook on to Shell to receive its messages? (http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323)
|
||||||
|
|
||||||
|
Manager_resetWindowBorder()
|
||||||
|
{
|
||||||
|
Local ncm, ncmSize
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Manager_setViewMonitor(d) {
|
Manager_setViewMonitor(d) {
|
||||||
Local aView, m, v, wndIds
|
Local aView, m, v, wndIds
|
||||||
|
|
||||||
|
@ -663,6 +650,30 @@ Manager_setViewMonitor(d) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Manager_setWindowBorder()
|
||||||
|
{
|
||||||
|
Local ncm, ncmSize
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Manager_setWindowMonitor(d) {
|
Manager_setWindowMonitor(d) {
|
||||||
Local aWndId, v
|
Local aWndId, v
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue