2011-07-27 17:43:34 +00:00
|
|
|
/**
|
|
|
|
* bug.n - tiling window management
|
2012-01-12 20:54:03 +00:00
|
|
|
* Copyright (c) 2010-2012 joten
|
2011-07-27 17:43:34 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
2012-05-31 15:44:05 +00:00
|
|
|
* @version 8.3.0
|
2011-07-27 17:43:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
NAME := "bug.n"
|
2012-05-31 15:44:05 +00:00
|
|
|
VERSION := "8.3.0"
|
2011-07-27 17:43:34 +00:00
|
|
|
|
|
|
|
; script settings
|
|
|
|
OnExit, Main_cleanup
|
|
|
|
SetBatchLines, -1
|
|
|
|
SetTitleMatchMode, 3
|
|
|
|
SetTitleMatchMode, fast
|
|
|
|
SetWinDelay, 10
|
|
|
|
#NoEnv
|
|
|
|
#SingleInstance force
|
|
|
|
#WinActivateForce
|
|
|
|
|
|
|
|
; pseudo main function
|
2012-06-30 16:37:13 +00:00
|
|
|
|
2012-11-25 13:56:35 +00:00
|
|
|
Main_setup()
|
2012-06-30 16:37:13 +00:00
|
|
|
|
2012-11-25 13:56:35 +00:00
|
|
|
Log_init(Main_logFile, False)
|
2012-06-30 16:37:13 +00:00
|
|
|
|
2012-06-17 14:35:57 +00:00
|
|
|
Log_msg("====== Initializing ======")
|
2011-07-27 17:43:34 +00:00
|
|
|
If 0 = 1
|
2011-09-02 17:46:07 +00:00
|
|
|
Config_filePath = %1%
|
2011-07-27 17:43:34 +00:00
|
|
|
Config_init()
|
|
|
|
|
|
|
|
Menu, Tray, Tip, %NAME% %VERSION%
|
|
|
|
IfExist %A_ScriptDir%\images\kfm.ico
|
|
|
|
Menu, Tray, Icon, %A_ScriptDir%\images\kfm.ico
|
|
|
|
Menu, Tray, NoStandard
|
|
|
|
Menu, Tray, Add, Toggle bar, Main_toggleBar
|
|
|
|
Menu, Tray, Add, Help, Main_help
|
|
|
|
Menu, Tray, Add,
|
|
|
|
Menu, Tray, Add, Exit, Main_quit
|
|
|
|
|
|
|
|
Manager_init()
|
2012-11-26 18:11:16 +00:00
|
|
|
Log_msg("====== Running ======")
|
2011-07-27 17:43:34 +00:00
|
|
|
Return ; end of the auto-execute section
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function & label definitions
|
|
|
|
*/
|
|
|
|
Main_cleanup: ; The labels with "ExitApp" or "Return" at the end and hotkeys have to be after the auto-execute section.
|
2012-06-17 14:35:57 +00:00
|
|
|
Log_msg("====== Cleaning up ======")
|
2011-07-27 17:43:34 +00:00
|
|
|
If Config_autoSaveSession
|
2012-11-25 13:56:35 +00:00
|
|
|
Config_saveSession(Config_filePath)
|
2011-07-27 17:43:34 +00:00
|
|
|
Manager_cleanup()
|
2012-11-26 18:11:16 +00:00
|
|
|
DllCall("CloseHandle", "UInt", Bar_hDrive) ; used in Bar_getDiskLoad
|
|
|
|
Log_msg("====== Exiting ======")
|
2011-07-27 17:43:34 +00:00
|
|
|
ExitApp
|
|
|
|
|
|
|
|
Main_help:
|
|
|
|
Run, explore %A_ScriptDir%\docs
|
|
|
|
Return
|
|
|
|
|
|
|
|
Main_quit:
|
|
|
|
ExitApp
|
|
|
|
Return
|
|
|
|
|
2012-11-25 13:56:35 +00:00
|
|
|
; Create bug.n-specific directories.
|
|
|
|
Main_makeDir(dirName) {
|
|
|
|
IfNotExist, %dirName%
|
|
|
|
{
|
|
|
|
FileCreateDir, %dirName%
|
|
|
|
If ErrorLevel {
|
|
|
|
MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting.
|
|
|
|
ExitApp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Else {
|
|
|
|
FileGetAttrib, attrib, %dirName%
|
|
|
|
IfNotInString, attrib, D
|
|
|
|
{
|
|
|
|
MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting.
|
|
|
|
ExitApp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Main_setup() {
|
|
|
|
Local winAppDir
|
|
|
|
|
|
|
|
Main_appDir := ""
|
|
|
|
Main_logFile := ""
|
|
|
|
Main_dataDir := ""
|
|
|
|
Main_autoLayout := ""
|
|
|
|
Main_autoWindowState := ""
|
|
|
|
|
|
|
|
EnvGet, winAppDir, APPDATA
|
|
|
|
|
|
|
|
Main_appDir := winAppDir . "\bug.n"
|
|
|
|
Main_logFile := Main_appDir . "\bugn_log.txt"
|
|
|
|
Main_dataDir := Main_appDir . "\data"
|
|
|
|
Main_autoLayout := Main_dataDir . "\_Layout.ini"
|
|
|
|
Main_autoWindowState := Main_dataDir . "\_WindowState.ini"
|
|
|
|
|
|
|
|
Main_makeDir(Main_appDir)
|
|
|
|
Main_makeDir(Main_dataDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-05 21:20:38 +00:00
|
|
|
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%
|
|
|
|
}
|
|
|
|
|
2011-07-27 17:43:34 +00:00
|
|
|
Main_toggleBar:
|
|
|
|
Monitor_toggleBar()
|
|
|
|
Return
|
|
|
|
|
2012-06-17 14:35:57 +00:00
|
|
|
#Include Log.ahk
|
2012-06-24 22:04:41 +00:00
|
|
|
#Include List.ahk
|
2011-07-27 17:43:34 +00:00
|
|
|
#Include Bar.ahk
|
|
|
|
#Include Config.ahk
|
|
|
|
#Include Manager.ahk
|
|
|
|
#Include Monitor.ahk
|
|
|
|
#Include View.ahk
|