backlog, dos2unix pass

This commit is contained in:
Cynthia Foxwell 2023-08-31 22:13:42 -06:00
parent 1ab9e0a01a
commit a850e695be
10 changed files with 4301 additions and 4194 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,162 +1,162 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
@license GNU General Public License version 3 @license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/> ../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0 @version 9.1.0
*/ */
Debug_initLog(filename, level = 0, truncateFile = True) Debug_initLog(filename, level = 0, truncateFile = True)
{ {
Global Debug_logFilename, Debug_logLevel Global Debug_logFilename, Debug_logLevel
Debug_logFilename := filename Debug_logFilename := filename
Debug_logLevel := level Debug_logLevel := level
If truncateFile If truncateFile
If FileExist(Debug_logFilename) If FileExist(Debug_logFilename)
FileDelete, %Debug_logFilename% FileDelete, %Debug_logFilename%
} }
Debug_logHelp() Debug_logHelp()
{ {
Debug_logMessage("Help Display", 0) Debug_logMessage("Help Display", 0)
Debug_logMessage("Window list columns", 0, False) Debug_logMessage("Window list columns", 0, False)
Debug_logMessage(" ID - Windows ID. Unique, OS-assigned ID", 0, False) Debug_logMessage(" ID - Windows ID. Unique, OS-assigned ID", 0, False)
Debug_logMessage(" H - Hidden. Whether bug.n thinks this window is hidden.", 0, False) Debug_logMessage(" H - Hidden. Whether bug.n thinks this window is hidden.", 0, False)
Debug_logMessage(" W - Windows active. This window is active according to Windows.", 0, False) Debug_logMessage(" W - Windows active. This window is active according to Windows.", 0, False)
Debug_logMessage(" A - View active. This window is active according to bug.n.", 0, False) Debug_logMessage(" A - View active. This window is active according to bug.n.", 0, False)
Debug_logMessage(" F - Floating. This window should not be positioned and resized by the layout.", 0, False) Debug_logMessage(" F - Floating. This window should not be positioned and resized by the layout.", 0, False)
Debug_logMessage(" D - Decorated. Does the window have a title bar?", 0, False) Debug_logMessage(" D - Decorated. Does the window have a title bar?", 0, False)
Debug_logMessage(" R - Responsive. Is responding to messages?", 0, False) Debug_logMessage(" R - Responsive. Is responding to messages?", 0, False)
Debug_logMessage(" G - Ghost. Is this window a ghost of another hung window?", 0, False) Debug_logMessage(" G - Ghost. Is this window a ghost of another hung window?", 0, False)
Debug_logMessage(" M - Monitor number.", 0, False) Debug_logMessage(" M - Monitor number.", 0, False)
Debug_logMessage(" Tags - Bit-mask of the views in which the window is active.", 0, False) Debug_logMessage(" Tags - Bit-mask of the views in which the window is active.", 0, False)
Debug_logMessage(" X - Windows X position.", 0, False) Debug_logMessage(" X - Windows X position.", 0, False)
Debug_logMessage(" Y - Windows Y position.", 0, False) Debug_logMessage(" Y - Windows Y position.", 0, False)
Debug_logMessage(" W - Windows width.", 0, False) Debug_logMessage(" W - Windows width.", 0, False)
Debug_logMessage(" H - Windows height.", 0, False) Debug_logMessage(" H - Windows height.", 0, False)
Debug_logMessage(" Style - Windows style.", 0, False) Debug_logMessage(" Style - Windows style.", 0, False)
Debug_logMessage(" Proc / Class / Title - Process/Class/Title of the window.", 0, False) Debug_logMessage(" Proc / Class / Title - Process/Class/Title of the window.", 0, False)
} }
Debug_logManagedWindowList() Debug_logManagedWindowList()
{ {
Local wndIds Local wndIds
Debug_logMessage("Window dump for manager") Debug_logMessage("Window dump for manager")
Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False) Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False)
StringTrimRight, wndIds, Manager_managedWndIds, 1 StringTrimRight, wndIds, Manager_managedWndIds, 1
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
Debug_logWindowInfo(A_LoopField) Debug_logWindowInfo(A_LoopField)
} }
} }
Debug_logMessage(text, level = 1, includeTimestamp = True) Debug_logMessage(text, level = 1, includeTimestamp = True)
{ {
Global Debug_logFilename, Debug_logLevel Global Debug_logFilename, Debug_logLevel
If (Debug_logLevel >= level) If (Debug_logLevel >= level)
{ {
If includeTimestamp If includeTimestamp
{ {
FormatTime, time, , yyyy-MM-dd HH:mm:ss FormatTime, time, , yyyy-MM-dd HH:mm:ss
text := time " " text text := time " " text
} }
Else Else
text := " " text text := " " text
FileAppend, %text%`r`n, %Debug_logFilename% FileAppend, %text%`r`n, %Debug_logFilename%
} }
} }
Debug_logViewWindowList() Debug_logViewWindowList()
{ {
Local v, wndIds Local v, wndIds
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
Debug_logMessage("Window dump for active view (" . Manager_aMonitor . ", " . v . ")") Debug_logMessage("Window dump for active view (" . Manager_aMonitor . ", " . v . ")")
Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False) Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1 StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
Debug_logWindowInfo(A_LoopField) Debug_logWindowInfo(A_LoopField)
} }
} }
Debug_logWindowInfo(wndId) { Debug_logWindowInfo(wndId) {
Local aWndId, detectHidden, text, v Local aWndId, detectHidden, text, v
Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus
Local wndClass, wndH, wndPId, wndPName, wndStyle, wndTitle, wndW, wndX, wndY Local wndClass, wndH, wndPId, wndPName, wndStyle, wndTitle, wndW, wndX, wndY
detectHidden := A_DetectHiddenWindows detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If aWndId = %wndId% If aWndId = %wndId%
isWinFocus := "*" isWinFocus := "*"
Else Else
isWinFocus := " " isWinFocus := " "
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
If (View_getActiveWindow(Manager_aMonitor, v) = wndId) If (View_getActiveWindow(Manager_aMonitor, v) = wndId)
isBugnActive := "*" isBugnActive := "*"
Else Else
isBugnActive := " " isBugnActive := " "
WinGetTitle, wndTitle, ahk_id %wndId% WinGetTitle, wndTitle, ahk_id %wndId%
WinGetClass, wndClass, ahk_id %wndId% WinGetClass, wndClass, ahk_id %wndId%
WinGet, wndPName, ProcessName, ahk_id %wndId% WinGet, wndPName, ProcessName, ahk_id %wndId%
WinGet, wndPId, PID, ahk_id %wndId% WinGet, wndPId, PID, ahk_id %wndId%
If InStr(Bar_hideTitleWndIds, wndId . ";") If InStr(Bar_hideTitleWndIds, wndId . ";")
isHidden := "*" isHidden := "*"
Else Else
isHidden := " " isHidden := " "
If InStr(Manager_managedWndIds, wndId . ";") Or Window_#%wndId%_isFloating If InStr(Manager_managedWndIds, wndId . ";") Or Window_#%wndId%_isFloating
isFloating := "*" isFloating := "*"
Else Else
isFloating := " " isFloating := " "
If Window_#%wndId%_isDecorated If Window_#%wndId%_isDecorated
isDecorated := "*" isDecorated := "*"
Else Else
isDecorated := " " isDecorated := " "
WinGet, wndStyle, Style, ahk_id %wndId% WinGet, wndStyle, Style, ahk_id %wndId%
WinGetPos, wndX, wndY, wndW, wndH, ahk_id %wndId% WinGetPos, wndX, wndY, wndW, wndH, ahk_id %wndId%
If Window_isGhost(wndId) If Window_isGhost(wndId)
isGhost := "*" isGhost := "*"
Else Else
isGhost := " " isGhost := " "
DetectHiddenWindows, %detectHidden% DetectHiddenWindows, %detectHidden%
;; Intentionally don't detect hidden windows here to see what Manager_hungTest does ;; Intentionally don't detect hidden windows here to see what Manager_hungTest does
If Window_isHung(wndId) If Window_isHung(wndId)
isResponsive := " " isResponsive := " "
Else Else
isResponsive := "*" isResponsive := "*"
text := wndId "`t" text := wndId "`t"
text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " " text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " "
text .= Window_#%wndId%_monitor "`t" Window_#%wndId%_tags "`t" text .= Window_#%wndId%_monitor "`t" Window_#%wndId%_tags "`t"
text .= wndX "`t" wndY "`t" wndW "`t" wndH "`t" wndStyle "`t" wndPName " [" wndPId "] / " wndClass " / " wndTitle text .= wndX "`t" wndY "`t" wndW "`t" wndH "`t" wndStyle "`t" wndPName " [" wndPId "] / " wndClass " / " wndTitle
Debug_logMessage(text , 0, False) Debug_logMessage(text , 0, False)
} }
Debug_setLogLevel(i, d) { Debug_setLogLevel(i, d) {
Global Debug_logLevel Global Debug_logLevel
If (i = 0) If (i = 0)
i := Debug_logLevel i := Debug_logLevel
i += d i += d
If (i >= 0) And (i != Debug_logLevel) { If (i >= 0) And (i != Debug_logLevel) {
Debug_logLevel := i Debug_logLevel := i
If (i = 0) If (i = 0)
Debug_logMessage("Logging disabled.", 0) Debug_logMessage("Logging disabled.", 0)
Else Else
Debug_logMessage("Log level set to " i ".") Debug_logMessage("Log level set to " i ".")
} }
} }

View File

@ -1,195 +1,195 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
@license GNU General Public License version 3 @license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/> ../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0 @version 9.1.0
*/ */
NAME := "bug.n" NAME := "bug.n"
VERSION := "9.1.0" VERSION := "9.1.0"
;; Script settings ;; Script settings
OnExit, Main_cleanup OnExit, Main_cleanup
SetBatchLines, -1 SetBatchLines, -1
SetTitleMatchMode, 3 SetTitleMatchMode, 3
SetTitleMatchMode, fast SetTitleMatchMode, fast
SetWinDelay, 10 SetWinDelay, 10
#NoEnv #NoEnv
#SingleInstance force #SingleInstance force
;#Warn ; Enable warnings to assist with detecting common errors. ;#Warn ; Enable warnings to assist with detecting common errors.
#WinActivateForce #WinActivateForce
;; Pseudo main function ;; Pseudo main function
Main_appDir := "" Main_appDir := ""
If 0 = 1 If 0 = 1
Main_appDir = %1% Main_appDir = %1%
Main_setup() Main_setup()
Debug_initLog(Main_logFile, 0, False) Debug_initLog(Main_logFile, 0, False)
Debug_logMessage("====== Initializing ======", 0) Debug_logMessage("====== Initializing ======", 0)
Config_filePath := Main_appDir "\Config.ini" Config_filePath := Main_appDir "\Config.ini"
Config_init() Config_init()
Menu, Tray, Tip, %NAME% %VERSION% Menu, Tray, Tip, %NAME% %VERSION%
If A_IsCompiled If A_IsCompiled
Menu, Tray, Icon, %A_ScriptFullPath%, -159 Menu, Tray, Icon, %A_ScriptFullPath%, -159
If FileExist(A_ScriptDir . "\logo.ico") If FileExist(A_ScriptDir . "\logo.ico")
Menu, Tray, Icon, % A_ScriptDir . "\logo.ico" Menu, Tray, Icon, % A_ScriptDir . "\logo.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
ResourceMonitor_init() ResourceMonitor_init()
Manager_init() Manager_init()
Debug_logMessage("====== Running ======", 0) Debug_logMessage("====== Running ======", 0)
Return ;; end of the auto-execute section Return ;; end of the auto-execute section
;; Function & label definitions ;; Function & label definitions
Main_cleanup: Main_cleanup:
Debug_logMessage("====== Cleaning up ======", 0) Debug_logMessage("====== Cleaning up ======", 0)
;; Config_autoSaveSession as False is deprecated. ;; Config_autoSaveSession as False is deprecated.
If Not (Config_autoSaveSession = "off") And Not (Config_autoSaveSession = "False") If Not (Config_autoSaveSession = "off") And Not (Config_autoSaveSession = "False")
Manager_saveState() Manager_saveState()
Manager_cleanup() Manager_cleanup()
ResourceMonitor_cleanup() ResourceMonitor_cleanup()
Debug_logMessage("====== Exiting bug.n ======", 0) Debug_logMessage("====== Exiting bug.n ======", 0)
ExitApp ExitApp
Main_evalCommand(command) Main_evalCommand(command)
{ {
type := SubStr(command, 1, 5) type := SubStr(command, 1, 5)
If (type = "Run, ") If (type = "Run, ")
{ {
parameters := SubStr(command, 6) parameters := SubStr(command, 6)
If InStr(parameters, ", ") If InStr(parameters, ", ")
{ {
StringSplit, parameter, parameters, `, StringSplit, parameter, parameters, `,
If (parameter0 = 2) If (parameter0 = 2)
{ {
StringTrimLeft, parameter2, parameter2, 1 StringTrimLeft, parameter2, parameter2, 1
Run, %parameter1%, %parameter2% Run, %parameter1%, %parameter2%
} }
Else If (parameter0 > 2) Else If (parameter0 > 2)
{ {
StringTrimLeft, parameter2, parameter2, 1 StringTrimLeft, parameter2, parameter2, 1
StringTrimLeft, parameter3, parameter3, 1 StringTrimLeft, parameter3, parameter3, 1
Run, %parameter1%, %parameter2%, %parameter3% Run, %parameter1%, %parameter2%, %parameter3%
} }
} }
Else Else
Run, %parameters% Run, %parameters%
} }
Else If (type = "Send ") Else If (type = "Send ")
Send % SubStr(command, 6) Send % SubStr(command, 6)
Else If (command = "Reload") Else If (command = "Reload")
Reload Reload
Else If (command = "ExitApp") Else If (command = "ExitApp")
ExitApp ExitApp
Else Else
{ {
i := InStr(command, "(") i := InStr(command, "(")
j := InStr(command, ")", False, i) j := InStr(command, ")", False, i)
If i And j If i And j
{ {
functionName := SubStr(command, 1, i - 1) functionName := SubStr(command, 1, i - 1)
functionArguments := SubStr(command, i + 1, j - (i + 1)) functionArguments := SubStr(command, i + 1, j - (i + 1))
StringReplace, functionArguments, functionArguments, %A_SPACE%, , All StringReplace, functionArguments, functionArguments, %A_SPACE%, , All
StringSplit, functionArgument, functionArguments, `, StringSplit, functionArgument, functionArguments, `,
Debug_logMessage("DEBUG[1] Main_evalCommand: " functionName "(" functionArguments ")", 1) Debug_logMessage("DEBUG[1] Main_evalCommand: " functionName "(" functionArguments ")", 1)
If (functionArgument0 = 0) If (functionArgument0 = 0)
%functionName%() %functionName%()
Else If (functionArgument0 = 1) Else If (functionArgument0 = 1)
%functionName%(functionArguments) %functionName%(functionArguments)
Else If (functionArgument0 = 2) Else If (functionArgument0 = 2)
%functionName%(functionArgument1, functionArgument2) %functionName%(functionArgument1, functionArgument2)
Else If (functionArgument0 = 3) Else If (functionArgument0 = 3)
%functionName%(functionArgument1, functionArgument2, functionArgument3) %functionName%(functionArgument1, functionArgument2, functionArgument3)
Else If (functionArgument0 = 4) Else If (functionArgument0 = 4)
%functionName%(functionArgument1, functionArgument2, functionArgument3, functionArgument4) %functionName%(functionArgument1, functionArgument2, functionArgument3, functionArgument4)
} }
} }
} }
Main_help: Main_help:
Run, explore %Main_docDir% Run, explore %Main_docDir%
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. MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting.
ExitApp ExitApp
} }
} }
Else Else
{ {
FileGetAttrib, attrib, %dirName% FileGetAttrib, attrib, %dirName%
IfNotInString, attrib, D IfNotInString, attrib, D
{ {
MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting. MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting.
ExitApp ExitApp
} }
} }
} }
Main_quit: Main_quit:
ExitApp ExitApp
Return Return
Main_setup() { Main_setup() {
Local winAppDir Local winAppDir
Main_docDir := A_ScriptDir Main_docDir := A_ScriptDir
If (SubStr(A_ScriptDir, -3) = "\src") If (SubStr(A_ScriptDir, -3) = "\src")
Main_docDir .= "\.." Main_docDir .= "\.."
Main_docDir .= "\doc" Main_docDir .= "\doc"
Main_logFile := "" Main_logFile := ""
Main_dataDir := "" Main_dataDir := ""
Main_autoLayout := "" Main_autoLayout := ""
Main_autoWindowState := "" Main_autoWindowState := ""
EnvGet, winAppDir, APPDATA EnvGet, winAppDir, APPDATA
If (Main_appDir = "") If (Main_appDir = "")
Main_appDir := winAppDir . "\bug.n" Main_appDir := winAppDir . "\bug.n"
Main_logFile := Main_appDir . "\log.txt" Main_logFile := Main_appDir . "\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_toggleBar: Main_toggleBar:
Monitor_toggleBar() Monitor_toggleBar()
Return Return
#Include Bar.ahk #Include Bar.ahk
#Include Config.ahk #Include Config.ahk
#Include Debug.ahk #Include Debug.ahk
#Include Manager.ahk #Include Manager.ahk
#Include Monitor.ahk #Include Monitor.ahk
#Include ResourceMonitor.ahk #Include ResourceMonitor.ahk
#Include Tiler.ahk #Include Tiler.ahk
#Include View.ahk #Include View.ahk
#Include Window.ahk #Include Window.ahk
#Include MonitorManager.ahk #Include MonitorManager.ahk
#Include MusicBee.ahk #Include MusicBee.ahk

File diff suppressed because it is too large Load Diff

View File

@ -1,373 +1,373 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
@license GNU General Public License version 3 @license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/> ../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0 @version 9.1.0
*/ */
Monitor_init(m, doRestore) { Monitor_init(m, doRestore) {
Global Global
Monitor_#%m%_aView_#1 := 1 Monitor_#%m%_aView_#1 := 1
Monitor_#%m%_aView_#2 := 1 Monitor_#%m%_aView_#2 := 1
Monitor_#%m%_showBar := Config_showBar Monitor_#%m%_showBar := Config_showBar
Monitor_#%m%_showTaskBar := Config_showTaskBar Monitor_#%m%_showTaskBar := Config_showTaskBar
Monitor_#%m%_taskBarClass := "" Monitor_#%m%_taskBarClass := ""
Monitor_#%m%_taskBarPos := "" Monitor_#%m%_taskBarPos := ""
Loop, % Config_viewCount Loop, % Config_viewCount
View_init(m, A_Index) View_init(m, A_Index)
If doRestore If doRestore
Config_restoreLayout(Main_autoLayout, m) Config_restoreLayout(Main_autoLayout, m)
Else Else
Config_restoreLayout(Config_filePath, m) Config_restoreLayout(Config_filePath, m)
SysGet, Monitor_#%m%_name, MonitorName, %m% SysGet, Monitor_#%m%_name, MonitorName, %m%
Monitor_getWorkArea(m) Monitor_getWorkArea(m)
Debug_logMessage("DEBUG[0] Monitor_init: #" . m . ", name: " . Monitor_#%m%_name . ", x: " . Monitor_#%m%_x . ", y: " . Monitor_#%m%_y . ", w: " . Monitor_#%m%_w . ", h: " . Monitor_#%m%_h . ".", 0) Debug_logMessage("DEBUG[0] Monitor_init: #" . m . ", name: " . Monitor_#%m%_name . ", x: " . Monitor_#%m%_x . ", y: " . Monitor_#%m%_y . ", w: " . Monitor_#%m%_w . ", h: " . Monitor_#%m%_h . ".", 0)
If Not Monitor_#%m%_showTaskBar { If Not Monitor_#%m%_showTaskBar {
Monitor_#%m%_showTaskBar := True Monitor_#%m%_showTaskBar := True
Monitor_toggleTaskBar(m) Monitor_toggleTaskBar(m)
} }
Bar_init(m) Bar_init(m)
} }
Monitor_activateView(i, d = 0) { Monitor_activateView(i, d = 0) {
Local aMonitor, aView, aWndId, detectHidden, m, n, wndId, wndIds Local aMonitor, aView, aWndId, detectHidden, m, n, wndId, wndIds
aMonitor := Manager_aMonitor aMonitor := Manager_aMonitor
If (i = -1) If (i = -1)
i := Monitor_#%aMonitor%_aView_#2 i := Monitor_#%aMonitor%_aView_#2
Else If (i = 0) Else If (i = 0)
i := Monitor_#%aMonitor%_aView_#1 i := Monitor_#%aMonitor%_aView_#1
i := Manager_loop(i, d, 1, Config_viewCount) i := Manager_loop(i, d, 1, Config_viewCount)
Debug_logMessage("DEBUG[1] Monitor_activateView; i: " . i . ", d: " . d . ", Manager_aMonitor: " . aMonitor . ", wndIds: " . View_#%Manager_aMonitor%_#%i%_wndIds, 1) Debug_logMessage("DEBUG[1] Monitor_activateView; i: " . i . ", d: " . d . ", Manager_aMonitor: " . aMonitor . ", wndIds: " . View_#%Manager_aMonitor%_#%i%_wndIds, 1)
If (i <= 0) Or (i > Config_viewCount) Or Manager_hideShow If (i <= 0) Or (i > Config_viewCount) Or Manager_hideShow
Return Return
;; Re-arrange the windows on the active view. ;; Re-arrange the windows on the active view.
If (i = Monitor_#%aMonitor%_aView_#1) { If (i = Monitor_#%aMonitor%_aView_#1) {
View_arrange(aMonitor, i) View_arrange(aMonitor, i)
Return Return
} }
aView := Monitor_#%aMonitor%_aView_#1 aView := Monitor_#%aMonitor%_aView_#1
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) And InStr(View_#%aMonitor%_#%aView%_wndIds, aWndId ";") And Window_isProg(aWndId) If WinExist("ahk_id" aWndId) And InStr(View_#%aMonitor%_#%aView%_wndIds, aWndId ";") And Window_isProg(aWndId)
View_setActiveWindow(aMonitor, aView, aWndId) View_setActiveWindow(aMonitor, aView, aWndId)
n := Config_syncMonitorViews n := Config_syncMonitorViews
If (n = 1) If (n = 1)
n := Manager_monitorCount n := Manager_monitorCount
Else If (n < 1) Else If (n < 1)
n := 1 n := 1
Loop, % n { Loop, % n {
If (n = 1) If (n = 1)
m := aMonitor m := aMonitor
Else Else
m := A_Index m := A_Index
Monitor_#%m%_aView_#2 := aView Monitor_#%m%_aView_#2 := aView
Monitor_#%m%_aView_#1 := i Monitor_#%m%_aView_#1 := i
Manager_hideShow := True Manager_hideShow := True
SetWinDelay, 0 SetWinDelay, 0
StringTrimRight, wndIds, View_#%m%_#%aView%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%aView%_wndIds, 1
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
If A_LoopField And Not (Window_#%A_LoopField%_tags & (1 << i - 1)) If A_LoopField And Not (Window_#%A_LoopField%_tags & (1 << i - 1))
Window_hide(A_LoopField) Window_hide(A_LoopField)
} }
SetWinDelay, 10 SetWinDelay, 10
detectHidden := A_DetectHiddenWindows detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
wndId := View_getActiveWindow(m, i) wndId := View_getActiveWindow(m, i)
If wndId If wndId
Window_set(wndId, "AlwaysOnTop", "On") Window_set(wndId, "AlwaysOnTop", "On")
View_arrange(m, i) View_arrange(m, i)
DetectHiddenWindows, %detectHidden% DetectHiddenWindows, %detectHidden%
StringTrimRight, wndIds, View_#%m%_#%i%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%i%_wndIds, 1
SetWinDelay, 0 SetWinDelay, 0
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
Window_show(A_LoopField) Window_show(A_LoopField)
} }
Window_set(wndId, "AlwaysOnTop", "Off") Window_set(wndId, "AlwaysOnTop", "Off")
SetWinDelay, 10 SetWinDelay, 10
Manager_hideShow := False Manager_hideShow := False
Bar_updateView(m, aView) Bar_updateView(m, aView)
Bar_updateView(m, i) Bar_updateView(m, i)
} }
wndId := View_getActiveWindow(aMonitor, i) wndId := View_getActiveWindow(aMonitor, i)
Manager_winActivate(wndId) Manager_winActivate(wndId)
} }
Monitor_find(d, n) { Monitor_find(d, n) {
Local mName Local mName
If (d < 0 Or d > 0) { If (d < 0 Or d > 0) {
Loop, % n { Loop, % n {
SysGet, mName, MonitorName, %A_Index% SysGet, mName, MonitorName, %A_Index%
If Not (mName = Monitor_#%A_Index%_name) If Not (mName = Monitor_#%A_Index%_name)
Return, A_Index Return, A_Index
} }
} }
Return, 0 Return, 0
} }
Monitor_get(x, y) Monitor_get(x, y)
{ {
Local m Local m
m := 0 m := 0
Loop, % Manager_monitorCount Loop, % Manager_monitorCount
{ ;; Check if the window is on this monitor. { ;; Check if the window is on this monitor.
If (x >= Monitor_#%A_Index%_x && x <= Monitor_#%A_Index%_x+Monitor_#%A_Index%_width && y >= Monitor_#%A_Index%_y && y <= Monitor_#%A_Index%_y+Monitor_#%A_Index%_height) If (x >= Monitor_#%A_Index%_x && x <= Monitor_#%A_Index%_x+Monitor_#%A_Index%_width && y >= Monitor_#%A_Index%_y && y <= Monitor_#%A_Index%_y+Monitor_#%A_Index%_height)
{ {
m := A_Index m := A_Index
Break Break
} }
} }
Return, m Return, m
} }
Monitor_getWorkArea(m) { Monitor_getWorkArea(m) {
Local bHeight, bTop, x, y Local bHeight, bTop, x, y
Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop
Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY
SysGet, monitor, Monitor, %m% SysGet, monitor, Monitor, %m%
Debug_logMessage("DEBUG[0] Monitor_getWorkArea: #" . m . ", l: " . monitorLeft . ", r: " . monitorRight . ", t: " . monitorTop . ", b: " . monitorBottom . ".", 0) Debug_logMessage("DEBUG[0] Monitor_getWorkArea: #" . m . ", l: " . monitorLeft . ", r: " . monitorRight . ", t: " . monitorTop . ", b: " . monitorBottom . ".", 0)
wndClasses := "Shell_TrayWnd;Shell_SecondaryTrayWnd" wndClasses := "Shell_TrayWnd;Shell_SecondaryTrayWnd"
;; @TODO What about third and so forth TrayWnd? ;; @TODO What about third and so forth TrayWnd?
If Config_bbCompatibility If Config_bbCompatibility
wndClasses .= ";bbLeanBar;bbSlit;BBToolbar;SystemBarEx" wndClasses .= ";bbLeanBar;bbSlit;BBToolbar;SystemBarEx"
Loop, PARSE, wndClasses, `; Loop, PARSE, wndClasses, `;
{ {
wndId := WinExist("ahk_class " A_LoopField) wndId := WinExist("ahk_class " A_LoopField)
If wndId { If wndId {
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId% WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
x := wndX + wndWidth / 2 x := wndX + wndWidth / 2
y := wndY + wndHeight / 2 y := wndY + wndHeight / 2
If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom) { If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom) {
If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd") If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd")
Monitor_#%m%_taskBarClass := A_LoopField Monitor_#%m%_taskBarClass := A_LoopField
Debug_logMessage("DEBUG[3] Monitor_getWorkArea: #" . m . ", window class: " . A_LoopField . ", x: " . wndX . ", y: " . wndY . ", w: " . wndWidth . ", h: " . wndHeight . ".", 3) Debug_logMessage("DEBUG[3] Monitor_getWorkArea: #" . m . ", window class: " . A_LoopField . ", x: " . wndX . ", y: " . wndY . ", w: " . wndWidth . ", h: " . wndHeight . ".", 3)
If (wndHeight < wndWidth) { If (wndHeight < wndWidth) {
;; Horizontal ;; Horizontal
If (wndY <= monitorTop) { If (wndY <= monitorTop) {
;; Top ;; Top
wndHeight += wndY - monitorTop wndHeight += wndY - monitorTop
monitorTop += wndHeight monitorTop += wndHeight
If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd") If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd")
Monitor_#%m%_taskBarPos := "top" Monitor_#%m%_taskBarPos := "top"
} Else { } Else {
;; Bottom ;; Bottom
wndHeight := monitorBottom - wndY wndHeight := monitorBottom - wndY
monitorBottom -= wndHeight monitorBottom -= wndHeight
} }
} Else { } Else {
;; Vertical ;; Vertical
If (wndX <= monitorLeft) { If (wndX <= monitorLeft) {
;; Left ;; Left
wndWidth += wndX wndWidth += wndX
monitorLeft += wndWidth monitorLeft += wndWidth
} Else { } Else {
;; Right ;; Right
wndWidth := monitorRight - wndX wndWidth := monitorRight - wndX
monitorRight -= wndWidth monitorRight -= wndWidth
} }
} }
} }
} }
} }
bHeight := Round(Bar_height / Config_scalingFactor) bHeight := Round(Bar_height / Config_scalingFactor)
bTop := 0 bTop := 0
If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray") And Not Monitor_#%m%_taskBarClass { If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray") And Not Monitor_#%m%_taskBarClass {
bTop := monitorTop bTop := monitorTop
If Monitor_#%m%_showBar If Monitor_#%m%_showBar
monitorTop += bHeight monitorTop += bHeight
} Else If (Config_verticalBarPos = "bottom") { } Else If (Config_verticalBarPos = "bottom") {
bTop := monitorBottom - bHeight bTop := monitorBottom - bHeight
If Monitor_#%m%_showBar If Monitor_#%m%_showBar
monitorBottom -= bHeight monitorBottom -= bHeight
} }
Monitor_#%m%_height := monitorBottom - monitorTop Monitor_#%m%_height := monitorBottom - monitorTop
Monitor_#%m%_width := monitorRight - monitorLeft Monitor_#%m%_width := monitorRight - monitorLeft
Monitor_#%m%_x := monitorLeft Monitor_#%m%_x := monitorLeft
Monitor_#%m%_y := monitorTop Monitor_#%m%_y := monitorTop
Monitor_#%m%_barY := bTop Monitor_#%m%_barY := bTop
Monitor_setWorkArea(monitorLeft, monitorTop, monitorRight, monitorBottom) Monitor_setWorkArea(monitorLeft, monitorTop, monitorRight, monitorBottom)
} }
Monitor_moveToIndex(m, n) { Monitor_moveToIndex(m, n) {
Global Global
Monitor_#%n%_aView_#1 := Monitor_#%m%_aView_#1 Monitor_#%n%_aView_#1 := Monitor_#%m%_aView_#1
Monitor_#%n%_aView_#2 := Monitor_#%m%_aView_#2 Monitor_#%n%_aView_#2 := Monitor_#%m%_aView_#2
Monitor_#%n%_name := Monitor_#%m%_name Monitor_#%n%_name := Monitor_#%m%_name
Monitor_#%n%_showBar := Monitor_#%m%_showBar Monitor_#%n%_showBar := Monitor_#%m%_showBar
Monitor_#%n%_showTaskBar := Monitor_#%m%_showTaskBar Monitor_#%n%_showTaskBar := Monitor_#%m%_showTaskBar
Monitor_#%n%_taskBarClass := Monitor_#%m%_taskBarClass Monitor_#%n%_taskBarClass := Monitor_#%m%_taskBarClass
Monitor_#%n%_taskBarPos := Monitor_#%m%_taskBarPos Monitor_#%n%_taskBarPos := Monitor_#%m%_taskBarPos
Monitor_#%n%_height := Monitor_#%m%_height Monitor_#%n%_height := Monitor_#%m%_height
Monitor_#%n%_width := Monitor_#%m%_width Monitor_#%n%_width := Monitor_#%m%_width
Monitor_#%n%_x := Monitor_#%m%_x Monitor_#%n%_x := Monitor_#%m%_x
Monitor_#%n%_y := Monitor_#%m%_y Monitor_#%n%_y := Monitor_#%m%_y
Monitor_#%n%_barY := Monitor_#%m%_barY Monitor_#%n%_barY := Monitor_#%m%_barY
Loop, % Config_viewCount Loop, % Config_viewCount
View_moveToIndex(m, A_Index, n, A_Index) View_moveToIndex(m, A_Index, n, A_Index)
} }
Monitor_setWindowTag(i, d = 0) { Monitor_setWindowTag(i, d = 0) {
Local aView, aWndId, wndId Local aView, aWndId, wndId
If (i = 0) If (i = 0)
i := Monitor_#%Manager_aMonitor%_aView_#1 i := Monitor_#%Manager_aMonitor%_aView_#1
If Not (i = 10) If Not (i = 10)
i := Manager_loop(i, d, 1, Config_viewCount) i := Manager_loop(i, d, 1, Config_viewCount)
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If InStr(Manager_managedWndIds, aWndId ";") And (i > 0) And (i <= Config_viewCount Or i = 10) { If InStr(Manager_managedWndIds, aWndId ";") And (i > 0) And (i <= Config_viewCount Or i = 10) {
If (i = 10) { If (i = 10) {
Loop, % Config_viewCount { Loop, % Config_viewCount {
If Not (Window_#%aWndId%_tags & (1 << A_Index - 1)) { If Not (Window_#%aWndId%_tags & (1 << A_Index - 1)) {
View_#%Manager_aMonitor%_#%A_Index%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%A_Index%_wndIds View_#%Manager_aMonitor%_#%A_Index%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%A_Index%_wndIds
View_setActiveWindow(Manager_aMonitor, A_Index, aWndId) View_setActiveWindow(Manager_aMonitor, A_Index, aWndId)
Bar_updateView(Manager_aMonitor, A_Index) Bar_updateView(Manager_aMonitor, A_Index)
Window_#%aWndId%_tags += 1 << A_Index - 1 Window_#%aWndId%_tags += 1 << A_Index - 1
} }
} }
} Else { } Else {
Loop, % Config_viewCount { Loop, % Config_viewCount {
If Not (A_index = i) { If Not (A_index = i) {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;, StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;,
View_setActiveWindow(Manager_aMonitor, A_Index, 0) View_setActiveWindow(Manager_aMonitor, A_Index, 0)
Bar_updateView(Manager_aMonitor, A_Index) Bar_updateView(Manager_aMonitor, A_Index)
} }
} }
If Not (Window_#%aWndId%_tags & (1 << i - 1)) If Not (Window_#%aWndId%_tags & (1 << i - 1))
View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds
View_setActiveWindow(Manager_aMonitor, i, aWndId) View_setActiveWindow(Manager_aMonitor, i, aWndId)
Window_#%aWndId%_tags := 1 << i - 1 Window_#%aWndId%_tags := 1 << i - 1
aView := Monitor_#%Manager_aMonitor%_aView_#1 aView := Monitor_#%Manager_aMonitor%_aView_#1
If Not (i = aView) { If Not (i = aView) {
Manager_hideShow := True Manager_hideShow := True
wndId := SubStr(View_#%Manager_aMonitor%_#%aView%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, ";") - 1) wndId := SubStr(View_#%Manager_aMonitor%_#%aView%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, ";") - 1)
Manager_winActivate(wndId) Manager_winActivate(wndId)
Manager_hideShow := False Manager_hideShow := False
If Config_viewFollowsTagged If Config_viewFollowsTagged
Monitor_activateView(i) Monitor_activateView(i)
Else { Else {
Manager_hideShow := True Manager_hideShow := True
Window_hide(aWndId) Window_hide(aWndId)
Manager_hideShow := False Manager_hideShow := False
If Config_dynamicTiling If Config_dynamicTiling
View_arrange(Manager_aMonitor, aView) View_arrange(Manager_aMonitor, aView)
Bar_updateView(Manager_aMonitor, i) Bar_updateView(Manager_aMonitor, i)
} }
} }
} }
} }
} }
Monitor_setWorkArea(left, top, right, bottom) { Monitor_setWorkArea(left, top, right, bottom) {
VarSetCapacity(area, 16) VarSetCapacity(area, 16)
NumPut(left, area, 0) NumPut(left, area, 0)
NumPut(top, area, 4) NumPut(top, area, 4)
NumPut(right, area, 8) NumPut(right, area, 8)
NumPut(bottom, area, 12) NumPut(bottom, area, 12)
DllCall("SystemParametersInfo", UInt, 0x2F, UInt, 0, UInt, &area, UInt, 0) ; 0x2F = SPI_SETWORKAREA DllCall("SystemParametersInfo", UInt, 0x2F, UInt, 0, UInt, &area, UInt, 0) ; 0x2F = SPI_SETWORKAREA
} }
;; flashkid: Send SetWorkArea to second Monitor (http://www.autohotkey.com/board/topic/42564-send-setworkarea-to-second-monitor/) ;; flashkid: Send SetWorkArea to second Monitor (http://www.autohotkey.com/board/topic/42564-send-setworkarea-to-second-monitor/)
Monitor_toggleBar() Monitor_toggleBar()
{ {
Global Global
Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar
Bar_toggleVisibility(Manager_aMonitor) Bar_toggleVisibility(Manager_aMonitor)
Monitor_getWorkArea(Manager_aMonitor) Monitor_getWorkArea(Manager_aMonitor)
View_arrange(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1) View_arrange(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
} }
Monitor_toggleNotifyIconOverflowWindow() { Monitor_toggleNotifyIconOverflowWindow() {
Static wndId Static wndId
If Not WinExist("ahk_class NotifyIconOverflowWindow") { If Not WinExist("ahk_class NotifyIconOverflowWindow") {
WinGet, wndId, ID, A WinGet, wndId, ID, A
detectHidden := A_DetectHiddenWindows detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
WinShow, ahk_class NotifyIconOverflowWindow WinShow, ahk_class NotifyIconOverflowWindow
WinActivate, ahk_class NotifyIconOverflowWindow WinActivate, ahk_class NotifyIconOverflowWindow
DetectHiddenWindows, %detectHidden% DetectHiddenWindows, %detectHidden%
} Else { } Else {
WinHide, ahk_class NotifyIconOverflowWindow WinHide, ahk_class NotifyIconOverflowWindow
WinActivate, ahk_id %wndId% WinActivate, ahk_id %wndId%
} }
} }
Monitor_toggleTaskBar(m := 0) { Monitor_toggleTaskBar(m := 0) {
Global Global
m := m ? m : Manager_aMonitor m := m ? m : Manager_aMonitor
If Monitor_#%m%_taskBarClass { If Monitor_#%m%_taskBarClass {
Monitor_#%m%_showTaskBar := Not Monitor_#%m%_showTaskBar Monitor_#%m%_showTaskBar := Not Monitor_#%m%_showTaskBar
Manager_hideShow := True Manager_hideShow := True
If Not Monitor_#%m%_showTaskBar { If Not Monitor_#%m%_showTaskBar {
WinHide, Start ahk_class Button WinHide, Start ahk_class Button
WinHide, % "ahk_class " Monitor_#%m%_taskBarClass WinHide, % "ahk_class " Monitor_#%m%_taskBarClass
} Else { } Else {
WinShow, Start ahk_class Button WinShow, Start ahk_class Button
WinShow, % "ahk_class " Monitor_#%m%_taskBarClass WinShow, % "ahk_class " Monitor_#%m%_taskBarClass
} }
Manager_hideShow := False Manager_hideShow := False
Monitor_getWorkArea(m) Monitor_getWorkArea(m)
Bar_move(m) Bar_move(m)
View_arrange(m, Monitor_#%m%_aView_#1) View_arrange(m, Monitor_#%m%_aView_#1)
} }
} }
Monitor_toggleWindowTag(i, d = 0) { Monitor_toggleWindowTag(i, d = 0) {
Local aWndId, wndId Local aWndId, wndId
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If (InStr(Manager_managedWndIds, aWndId ";") And i >= 0 And i <= Config_viewCount) { If (InStr(Manager_managedWndIds, aWndId ";") And i >= 0 And i <= Config_viewCount) {
If (Window_#%aWndId%_tags & (1 << i - 1)) { If (Window_#%aWndId%_tags & (1 << i - 1)) {
If Not ((Window_#%aWndId%_tags - (1 << i - 1)) = 0) { If Not ((Window_#%aWndId%_tags - (1 << i - 1)) = 0) {
Window_#%aWndId%_tags -= 1 << i - 1 Window_#%aWndId%_tags -= 1 << i - 1
StringReplace, View_#%Manager_aMonitor%_#%i%_wndIds, View_#%Manager_aMonitor%_#%i%_wndIds, %aWndId%`;, StringReplace, View_#%Manager_aMonitor%_#%i%_wndIds, View_#%Manager_aMonitor%_#%i%_wndIds, %aWndId%`;,
Bar_updateView(Manager_aMonitor, i) Bar_updateView(Manager_aMonitor, i)
If (i = Monitor_#%Manager_aMonitor%_aView_#1) { If (i = Monitor_#%Manager_aMonitor%_aView_#1) {
Manager_hideShow := True Manager_hideShow := True
Window_hide(aWndId) Window_hide(aWndId)
Manager_hideShow := False Manager_hideShow := False
wndId := SubStr(View_#%Manager_aMonitor%_#%i%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%i%_wndIds, ";")-1) wndId := SubStr(View_#%Manager_aMonitor%_#%i%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%i%_wndIds, ";")-1)
Manager_winActivate(wndId) Manager_winActivate(wndId)
If Config_dynamicTiling If Config_dynamicTiling
View_arrange(Manager_aMonitor, i) View_arrange(Manager_aMonitor, i)
} }
} }
} Else { } Else {
View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds
View_setActiveWindow(Manager_aMonitor, i, aWndId) View_setActiveWindow(Manager_aMonitor, i, aWndId)
Bar_updateView(Manager_aMonitor, i) Bar_updateView(Manager_aMonitor, i)
Window_#%aWndId%_tags += 1 << i - 1 Window_#%aWndId%_tags += 1 << i - 1
} }
} }
} }

View File

@ -1,191 +1,191 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
@license GNU General Public License version 3 @license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/> ../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0 @version 9.1.0
*/ */
ResourceMonitor_init() { ResourceMonitor_init() {
Global Config_readinDiskLoad, Config_readinNetworkLoad, ResourceMonitor_hDrive Global Config_readinDiskLoad, Config_readinNetworkLoad, ResourceMonitor_hDrive
If Config_readinDiskLoad If Config_readinDiskLoad
ResourceMonitor_hDrive := DllCall("CreateFile", "Str", "\\.\PhysicalDrive0", "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 0) ResourceMonitor_hDrive := DllCall("CreateFile", "Str", "\\.\PhysicalDrive0", "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 0)
;; This call may lead to bug.n hanging (bug 019005). ;; This call may lead to bug.n hanging (bug 019005).
If Config_readinNetworkLoad If Config_readinNetworkLoad
ResourceMonitor_getNetworkInterface() ResourceMonitor_getNetworkInterface()
} }
ResourceMonitor_cleanup() { ResourceMonitor_cleanup() {
Global Config_readinDiskLoad, ResourceMonitor_hDrive Global Config_readinDiskLoad, ResourceMonitor_hDrive
If Config_readinDiskLoad If Config_readinDiskLoad
DllCall("CloseHandle", "UInt", ResourceMonitor_hDrive) ;; used in ResourceMonitor_getDiskLoad DllCall("CloseHandle", "UInt", ResourceMonitor_hDrive) ;; used in ResourceMonitor_getDiskLoad
} }
ResourceMonitor_bytesToString(b) { ResourceMonitor_bytesToString(b) {
If (b > 1047527424) { If (b > 1047527424) {
b /= 1024 * 1024 * 1024 b /= 1024 * 1024 * 1024
unit := "GB" unit := "GB"
} Else If (b > 1022976) { } Else If (b > 1022976) {
b /= 1024 * 1024 b /= 1024 * 1024
unit := "MB" unit := "MB"
} Else If (b > 999) { } Else If (b > 999) {
b /= 1024 b /= 1024
unit := "kB" unit := "kB"
} Else { } Else {
unit := " B" unit := " B"
} }
b := Round(b, 1) b := Round(b, 1)
If (b > 99.9 Or unit = " B") If (b > 99.9 Or unit = " B")
b := Round(b, 0) b := Round(b, 0)
Return, SubStr(" " b, -3) . unit Return, SubStr(" " b, -3) . unit
} }
ResourceMonitor_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) { ResourceMonitor_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) {
VarSetCapacity(powerStatus, (1 + 1 + 1 + 1 + 4 + 4)) VarSetCapacity(powerStatus, (1 + 1 + 1 + 1 + 4 + 4))
success := DllCall("GetSystemPowerStatus", "UInt", &powerStatus) success := DllCall("GetSystemPowerStatus", "UInt", &powerStatus)
If (ErrorLevel != 0 Or success = 0) { If (ErrorLevel != 0 Or success = 0) {
MsgBox 16, Power Status, Can't get the power status... MsgBox 16, Power Status, Can't get the power status...
Return Return
} }
acLineStatus := NumGet(powerStatus, 0, "Char") acLineStatus := NumGet(powerStatus, 0, "Char")
batteryLifePercent := NumGet(powerStatus, 2, "Char") batteryLifePercent := NumGet(powerStatus, 2, "Char")
If acLineStatus = 0 If acLineStatus = 0
acLineStatus = off acLineStatus = off
Else If acLineStatus = 1 Else If acLineStatus = 1
acLineStatus = on acLineStatus = on
Else If acLineStatus = 255 Else If acLineStatus = 255
acLineStatus = ? acLineStatus = ?
If batteryLifePercent = 255 If batteryLifePercent = 255
batteryLifePercent = ??? batteryLifePercent = ???
} }
;; PhiLho: AC/Battery status (http://www.autohotkey.com/forum/topic7633.html) ;; PhiLho: AC/Battery status (http://www.autohotkey.com/forum/topic7633.html)
ResourceMonitor_getDiskLoad(ByRef readLoad, ByRef writeLoad) { ResourceMonitor_getDiskLoad(ByRef readLoad, ByRef writeLoad) {
Global ResourceMonitor_hDrive Global ResourceMonitor_hDrive
Static oldReadCount, oldWriteCount Static oldReadCount, oldWriteCount
nReturn := oldReadCount := oldWriteCount := 0 nReturn := oldReadCount := oldWriteCount := 0
dpSize := 5 * 8 + 4 + 4 + 4 + 4 + 8 + 4 + 8 * (A_IsUnicode ? 2 : 1) + 12 ;; 88? dpSize := 5 * 8 + 4 + 4 + 4 + 4 + 8 + 4 + 8 * (A_IsUnicode ? 2 : 1) + 12 ;; 88?
VarSetCapacity(dp, dpSize) 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 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) newReadCount := NumGet(dp, 40)
newWriteCount := NumGet(dp, 44) newWriteCount := NumGet(dp, 44)
readLoad := SubStr(" " Round((1 - 1 / (1 + newReadCount - oldReadCount)) * 100), -2) readLoad := SubStr(" " Round((1 - 1 / (1 + newReadCount - oldReadCount)) * 100), -2)
writeLoad := SubStr(" " Round((1 - 1 / (1 + newWriteCount - oldWriteCount)) * 100), -2) writeLoad := SubStr(" " Round((1 - 1 / (1 + newWriteCount - oldWriteCount)) * 100), -2)
oldReadCount := newReadCount oldReadCount := newReadCount
oldWriteCount := newWriteCount oldWriteCount := newWriteCount
} }
;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329) ;; 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) ;; SKAN: HDD Activity Monitoring LED (http://www.autohotkey.com/community/viewtopic.php?p=113890&sid=64d9824fdf252697ff4d5026faba91f8#p113890)
ResourceMonitor_getMemoryUsage() { ResourceMonitor_getMemoryUsage() {
VarSetCapacity(memoryStatus, 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4) VarSetCapacity(memoryStatus, 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4)
DllCall("kernel32.dll\GlobalMemoryStatus", "UInt", &memoryStatus) DllCall("kernel32.dll\GlobalMemoryStatus", "UInt", &memoryStatus)
Return, SubStr(" " Round(*(&memoryStatus + 4)), -2) ;; LS byte is enough, 0..100 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) ;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
ResourceMonitor_getNetworkInterface() { ResourceMonitor_getNetworkInterface() {
Global Config_readinNetworkLoad, ResourceMonitor_networkInterface Global Config_readinNetworkLoad, ResourceMonitor_networkInterface
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2") objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . A_ComputerName . "\root\cimv2")
WQLQuery := "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface WHERE Name LIKE '%" . Config_readinNetworkLoad . "%'" WQLQuery := "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface WHERE Name LIKE '%" . Config_readinNetworkLoad . "%'"
ResourceMonitor_networkInterface := objWMIService.ExecQuery(WQLQuery).ItemIndex(0) ResourceMonitor_networkInterface := objWMIService.ExecQuery(WQLQuery).ItemIndex(0)
} }
;; Pillus: System monitor (HDD/Wired/Wireless) using keyboard LEDs (http://www.autohotkey.com/board/topic/65308-system-monitor-hddwiredwireless-using-keyboard-leds/) ;; Pillus: System monitor (HDD/Wired/Wireless) using keyboard LEDs (http://www.autohotkey.com/board/topic/65308-system-monitor-hddwiredwireless-using-keyboard-leds/)
ResourceMonitor_getNetworkLoad(ByRef upLoad, ByRef dnLoad) { ResourceMonitor_getNetworkLoad(ByRef upLoad, ByRef dnLoad) {
Global ResourceMonitor_networkInterface Global ResourceMonitor_networkInterface
ResourceMonitor_networkInterface.Refresh_ ResourceMonitor_networkInterface.Refresh_
dnLoad := ResourceMonitor_bytesToString(ResourceMonitor_networkInterface.BytesReceivedPerSec) . "/s" dnLoad := ResourceMonitor_bytesToString(ResourceMonitor_networkInterface.BytesReceivedPerSec) . "/s"
upLoad := ResourceMonitor_bytesToString(ResourceMonitor_networkInterface.BytesSentPerSec) . "/s" upLoad := ResourceMonitor_bytesToString(ResourceMonitor_networkInterface.BytesSentPerSec) . "/s"
} }
;; Pillus: System monitor (HDD/Wired/Wireless) using keyboard LEDs (http://www.autohotkey.com/board/topic/65308-system-monitor-hddwiredwireless-using-keyboard-leds/) ;; Pillus: System monitor (HDD/Wired/Wireless) using keyboard LEDs (http://www.autohotkey.com/board/topic/65308-system-monitor-hddwiredwireless-using-keyboard-leds/)
ResourceMonitor_getSystemTimes() { ResourceMonitor_getSystemTimes() {
;; Total CPU Load ;; Total CPU Load
Static oldIdleTime, oldKrnlTime, oldUserTime Static oldIdleTime, oldKrnlTime, oldUserTime
Static newIdleTime, newKrnlTime, newUserTime Static newIdleTime, newKrnlTime, newUserTime
newIdleTime := newKrnlTime := newUserTime := 0 newIdleTime := newKrnlTime := newUserTime := 0
oldIdleTime := newIdleTime oldIdleTime := newIdleTime
oldKrnlTime := newKrnlTime oldKrnlTime := newKrnlTime
oldUserTime := newUserTime oldUserTime := newUserTime
DllCall("GetSystemTimes", "Int64P", newIdleTime, "Int64P", newKrnlTime, "Int64P", newUserTime) DllCall("GetSystemTimes", "Int64P", newIdleTime, "Int64P", newKrnlTime, "Int64P", newUserTime)
sysTime := Round((1 - (newIdleTime - oldIdleTime) / (newKrnlTime - oldKrnlTime+newUserTime - oldUserTime)) * 100) sysTime := Round((1 - (newIdleTime - oldIdleTime) / (newKrnlTime - oldKrnlTime+newUserTime - oldUserTime)) * 100)
Return, sysTime ;; system time in percent Return, sysTime ;; system time in percent
} }
;; Sean: CPU LoadTimes (http://www.autohotkey.com/forum/topic18913.html) ;; Sean: CPU LoadTimes (http://www.autohotkey.com/forum/topic18913.html)
ResourceMonitor_getText() { ResourceMonitor_getText() {
Global Config_readinCpu, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad Global Config_readinCpu, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad
text := "" text := ""
If Config_readinCpu If Config_readinCpu
text .= " CPU: " ResourceMonitor_getSystemTimes() "% " text .= " CPU: " ResourceMonitor_getSystemTimes() "% "
If Config_readinMemoryUsage { If Config_readinMemoryUsage {
If (Config_readinCpu) If (Config_readinCpu)
text .= "|" text .= "|"
text .= " RAM: " ResourceMonitor_getMemoryUsage() "% " text .= " RAM: " ResourceMonitor_getMemoryUsage() "% "
} }
If Config_readinDiskLoad { If Config_readinDiskLoad {
If (Config_readinCpu Or Config_readinMemoryUsage) If (Config_readinCpu Or Config_readinMemoryUsage)
text .= "|" text .= "|"
ResourceMonitor_getDiskLoad(rLoad, wLoad) ResourceMonitor_getDiskLoad(rLoad, wLoad)
text .= " Dr: " rLoad "% | Dw: " wLoad "% " text .= " Dr: " rLoad "% | Dw: " wLoad "% "
} }
If Config_readinNetworkLoad { If Config_readinNetworkLoad {
If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad) If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad)
text .= "|" text .= "|"
ResourceMonitor_getNetworkLoad(upLoad, dnLoad) ResourceMonitor_getNetworkLoad(upLoad, dnLoad)
text .= " UP: " upLoad " | dn: " dnLoad " " text .= " UP: " upLoad " | dn: " dnLoad " "
} }
Return, text Return, text
} }
ResourceMonitor_getSystemTimes2(ByRef IdleTime) { ResourceMonitor_getSystemTimes2(ByRef IdleTime) {
DllCall("GetSystemTimes", "Int64P", IdleTime, "Int64P", KernelTime, "Int64P", UserTime) DllCall("GetSystemTimes", "Int64P", IdleTime, "Int64P", KernelTime, "Int64P", UserTime)
Return KernelTime + UserTime Return KernelTime + UserTime
} }
ResourceMonitor_getCpuLoad(period := 500) { ResourceMonitor_getCpuLoad(period := 500) {
total := ResourceMonitor_getSystemTimes2(idle) total := ResourceMonitor_getSystemTimes2(idle)
Sleep, % period Sleep, % period
total2 := ResourceMonitor_getSystemTimes2(idle2) total2 := ResourceMonitor_getSystemTimes2(idle2)
Return 100*(1 - (idle2 - idle)/(total2 - total)) Return 100*(1 - (idle2 - idle)/(total2 - total))
} }
ResourceMonitor_getCpuText() { ResourceMonitor_getCpuText() {
Return, Floor(ResourceMonitor_getCpuLoad()) . "%" Return, Floor(ResourceMonitor_getCpuLoad()) . "%"
} }
ResourceMonitor_GlobalMemoryStatusEx() ResourceMonitor_GlobalMemoryStatusEx()
{ {
static MSEX, init := NumPut(VarSetCapacity(MSEX, 64, 0), MSEX, "uint") static MSEX, init := NumPut(VarSetCapacity(MSEX, 64, 0), MSEX, "uint")
if !(DllCall("GlobalMemoryStatusEx", "ptr", &MSEX)) if !(DllCall("GlobalMemoryStatusEx", "ptr", &MSEX))
throw Exception("Call to GlobalMemoryStatusEx failed: " A_LastError, -1) throw Exception("Call to GlobalMemoryStatusEx failed: " A_LastError, -1)
return { MemoryLoad: NumGet(MSEX, 4, "uint"), TotalPhys: NumGet(MSEX, 8, "uint64"), AvailPhys: NumGet(MSEX, 16, "uint64") } return { MemoryLoad: NumGet(MSEX, 4, "uint"), TotalPhys: NumGet(MSEX, 8, "uint64"), AvailPhys: NumGet(MSEX, 16, "uint64") }
} }
ResourceMonitor_getRamText() { ResourceMonitor_getRamText() {
GMSEx := ResourceMonitor_GlobalMemoryStatusEx() GMSEx := ResourceMonitor_GlobalMemoryStatusEx()
TotalMem := GMSEx.TotalPhys TotalMem := GMSEx.TotalPhys
AvailMem := GMSEx.AvailPhys AvailMem := GMSEx.AvailPhys
mem := RegExReplace(Floor((TotalMem - AvailMem) / 1048576), "(\d)(?=(?:\d{3})+(?:\.|$))", "$1,") mem := RegExReplace(Floor((TotalMem - AvailMem) / 1048576), "(\d)(?=(?:\d{3})+(?:\.|$))", "$1,")
Return, mem . " MB" Return, mem . " MB"
} }

View File

@ -114,7 +114,7 @@ Tiler_isActive(m, v) {
Tiler_layoutTiles(m, v, x, y, w, h, type = "") { Tiler_layoutTiles(m, v, x, y, w, h, type = "") {
Local axis1, axis2, axis3, gapW, hasStackArea, mFact, mSplit, mXSet, mYSet, mYActual, n Local axis1, axis2, axis3, gapW, hasStackArea, mFact, mSplit, mXSet, mYSet, mYActual, n
Local h1, h2, mWndCount, stackLen, subAreaCount, subAreaWndCount, subH1, subW1, subX1, subY1, w1, w2, x1, x2, y1, y2 Local h1, h2, mWndCount, indexMod, leftArray, leftArrayCount, rightArray, rightArrayCount, stackLen, subAreaCount, subAreaWndCount, subH1, subW1, subX1, subY1, w1, w2, x1, x2, y1, y2
axis1 := Abs(View_#%m%_#%v%_layoutAxis_#1) axis1 := Abs(View_#%m%_#%v%_layoutAxis_#1)
axis2 := View_#%m%_#%v%_layoutAxis_#2 axis2 := View_#%m%_#%v%_layoutAxis_#2
@ -140,53 +140,89 @@ Tiler_layoutTiles(m, v, x, y, w, h, type = "") {
mSplit := View_tiledWndId0 mSplit := View_tiledWndId0
} }
;; Areas (master and stack)
x1 := x x1 := x
y1 := y y1 := y
w1 := w w1 := w
h1 := h h1 := h
If hasStackArea {
leftArray := []
leftArrayCount := 0
rightArray := []
rightArrayCount := 0
if hasStackArea {
;; split in half
If (View_#%m%_#%v%_layoutAxis_#1 < 0) If (View_#%m%_#%v%_layoutAxis_#1 < 0)
Tiler_splitArea(axis1 - 1, 1 - mFact, x1, y1, w1, h1, gapW, x2, y2, w2, h2, x1, y1, w1, h1) Tiler_splitArea(axis1 - 1, 1 - mFact, x1, y1, w1, h1, gapW, x2, y2, w2, h2, x1, y1, w1, h1)
Else Else
Tiler_splitArea(axis1 - 1, mFact, x1, y1, w1, h1, gapW, x1, y1, w1, h1, x2, y2, w2, h2) Tiler_splitArea(axis1 - 1, mFact, x1, y1, w1, h1, gapW, x1, y1, w1, h1, x2, y2, w2, h2)
indexMod := false
Loop % View_tiledWndId0 {
if indexMod {
leftArrayCount += 1
leftArray[leftArrayCount] := View_tiledWndId%A_Index%
indexMod := false
} else {
rightArrayCount += 1
rightArray[rightArrayCount] := View_tiledWndId%A_Index%
indexMod := true
}
}
Tiler_stackArrayTiles(m, v, rightArray, rightArrayCount, +1, 2, x2, y2, w2, h2, gapW, type)
Tiler_stackArrayTiles(m, v, leftArray, leftArrayCount, +1, 2, x1, y1, w1, h1, gapW, type)
} else {
Tiler_stackTiles(m, v, 1, 1, +1, axis2, x1, y1, w1, h1, 0, type)
} }
; Areas (master and stack)
;x1 := x
;y1 := y
;w1 := w
;h1 := h
;If hasStackArea {
; If (View_#%m%_#%v%_layoutAxis_#1 < 0)
; Tiler_splitArea(axis1 - 1, 1 - mFact, x1, y1, w1, h1, gapW, x2, y2, w2, h2, x1, y1, w1, h1)
; Else
; Tiler_splitArea(axis1 - 1, mFact, x1, y1, w1, h1, gapW, x1, y1, w1, h1, x2, y2, w2, h2)
;}
;; Master ;; Master
If (axis2 = 3) ;If (axis2 = 3)
Tiler_stackTiles(m, v, 1, mSplit, +1, 3, x1, y1, w1, h1, 0, type) ; Tiler_stackTiles(m, v, 1, mSplit, +1, 3, x1, y1, w1, h1, 0, type)
Else { ;Else {
mYActual := (type = "blank") ? mYSet : Ceil(mSplit / mXSet) ; mYActual := (type = "blank") ? mYSet : Ceil(mSplit / mXSet)
subAreaCount := mYActual ; subAreaCount := mYActual
mWndCount := mSplit ; mWndCount := mSplit
Loop, % mYActual { ; Loop, % mYActual {
Tiler_splitArea(Not (axis2 - 1), 1 / subAreaCount, x1, y1, w1, h1, gapW, subX1, subY1, subW1, subH1, x1, y1, w1, h1) ; Tiler_splitArea(Not (axis2 - 1), 1 / subAreaCount, x1, y1, w1, h1, gapW, subX1, subY1, subW1, subH1, x1, y1, w1, h1)
subAreaWndCount := mXSet ; subAreaWndCount := mXSet
If (mWndCount < subAreaWndCount) ; If (mWndCount < subAreaWndCount)
subAreaWndCount := mWndCount ; subAreaWndCount := mWndCount
Debug_logMessage("DEBUG[2] Tiler_layoutTiles: Master subArea #" A_Index, 2) ; Debug_logMessage("DEBUG[2] Tiler_layoutTiles: Master subArea #" A_Index, 2)
Tiler_stackTiles(m, v, mSplit - mWndCount + 1, subAreaWndCount, +1, axis2, subX1, subY1, subW1, subH1, gapW, type) ; Tiler_stackTiles(m, v, mSplit - mWndCount + 1, subAreaWndCount, +1, axis2, subX1, subY1, subW1, subH1, gapW, type)
mWndCount -= subAreaWndCount ; mWndCount -= subAreaWndCount
subAreaCount -= 1 ; subAreaCount -= 1
} ; }
} ;}
;
;; Stack ;;; Stack
If hasStackArea { ;If hasStackArea {
If (type = "blank") { ; If (type = "blank") {
Debug_logMessage("DEBUG[2] Tiler_layoutTiles: Stack subArea #" A_Index, 2) ; Debug_logMessage("DEBUG[2] Tiler_layoutTiles: Stack subArea #" A_Index, 2)
Tiler_stackTiles(m, v, mSplit + 1, 1, +1, 3, x2, y2, w2, h2, 0, type) ; Tiler_stackTiles(m, v, mSplit + 1, 1, +1, 3, x2, y2, w2, h2, 0, type)
} Else { ; } Else {
stackLen := View_tiledWndId0 - mSplit ; stackLen := View_tiledWndId0 - mSplit
;; 161 is the minimal width of an Windows-Explorer window, below which it cannot be resized. ; ;; 161 is the minimal width of an Windows-Explorer window, below which it cannot be resized.
;; The minimal height is 243, but this seems too high for being a limit here; ; ;; The minimal height is 243, but this seems too high for being a limit here;
;; therefor '2 * Bar_height' is used for the minimal height of a window. ; ;; therefor '2 * Bar_height' is used for the minimal height of a window.
If (axis3 = 3 Or (axis3 = 1 And (w2 - (stackLen - 1) * gapW) / stackLen < 161) Or (axis3 = 2 And (h2 - (stackLen - 1) * gapW) / stackLen < 2 * Bar_height)) ; If (axis3 = 3 Or (axis3 = 1 And (w2 - (stackLen - 1) * gapW) / stackLen < 161) Or (axis3 = 2 And (h2 - (stackLen - 1) * gapW) / stackLen < 2 * Bar_height))
Tiler_stackTiles(m, v, mSplit + 1, stackLen, +1, 3, x2, y2, w2, h2, 0, type) ; Tiler_stackTiles(m, v, mSplit + 1, stackLen, +1, 3, x2, y2, w2, h2, 0, type)
Else ; Else
Tiler_stackTiles(m, v, mSplit + 1, stackLen, +1, axis3, x2, y2, w2, h2, gapW, type) ; Tiler_stackTiles(m, v, mSplit + 1, stackLen, +1, axis3, x2, y2, w2, h2, gapW, type)
} ; }
} ;}
} }
Tiler_setAxis(m, v, id, d) { Tiler_setAxis(m, v, id, d) {
@ -332,6 +368,39 @@ Tiler_stackTiles(m, v, i, len, d, axis, x, y, w, h, padding, type = "") {
} }
} }
Tiler_stackArrayTiles(m, v, arr, len, d, axis, x, y, w, h, padding, type = "") {
Local i, dx, dy, tileH, tileW, tileX, tileY
tileX := x
tileY := y
tileW := w
tileH := h
dx := 0
dy := 0
dw := (w - (len - 1) * padding) / len
dh := (h - (len - 1) * padding) / len
If (axis = 1) {
tileW := (w - (len - 1) * padding) / len
dx := tileW + padding
} Else If (axis = 2) {
tileH := (h - (len - 1) * padding) / len
dy := tileH + padding
}
;; Else (axis = 3) and nothing to do
Debug_logMessage("DEBUG[2] Tiler_stackArrayTiles: start = " i ", length = " len, 2)
i := 1
Loop, % len {
If (type = "blank")
Tiler_addSubArea(m, v, i, tileX, tileY, tileW, tileH)
Else
Window_move(arr[i], tileX, tileY, tileW, tileH)
i += d
tileX += dx
tileY += dy
}
}
Tiler_toggleStackArea(m ,v) { Tiler_toggleStackArea(m ,v) {
Global Global

View File

@ -1,435 +1,433 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
@license GNU General Public License version 3 @license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/> ../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0 @version 9.1.0
*/ */
View_init(m, v) View_init(m, v) {
{ Global
Global
View_#%m%_#%v%_area_#0 := 0
View_#%m%_#%v%_area_#0 := 0 View_#%m%_#%v%_aWndIds := "0;"
View_#%m%_#%v%_aWndIds := "0;" View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layout_#1 := 1 View_#%m%_#%v%_layout_#2 := 1
View_#%m%_#%v%_layout_#2 := 1 View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1 View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2
View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2 View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3
View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3 View_#%m%_#%v%_layoutGapWidth := Config_layoutGapWidth
View_#%m%_#%v%_layoutGapWidth := Config_layoutGapWidth View_#%m%_#%v%_layoutMFact := Config_layoutMFactor
View_#%m%_#%v%_layoutMFact := Config_layoutMFactor View_#%m%_#%v%_layoutMX := 1
View_#%m%_#%v%_layoutMX := 1 View_#%m%_#%v%_layoutMY := 1
View_#%m%_#%v%_layoutMY := 1 View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1 View_#%m%_#%v%_margins := "0;0;0;0"
View_#%m%_#%v%_margins := "0;0;0;0" View_#%m%_#%v%_showStackArea := True
View_#%m%_#%v%_showStackArea := True StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `;
StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `; View_#%m%_#%v%_wndIds := ""
View_#%m%_#%v%_wndIds := "" }
}
View_activateWindow(i, d = 0) {
View_activateWindow(i, d = 0) { Local aWndId, direction, failure, j, v, wndId, wndId0, wndIds
Local aWndId, direction, failure, j, v, wndId, wndId0, wndIds
Debug_logMessage("DEBUG[1] View_activateWindow(" . i . ", " . d . ")", 1)
Debug_logMessage("DEBUG[1] View_activateWindow(" . i . ", " . d . ")", 1) If (i = 0) And (d = 0)
If (i = 0) And (d = 0) Return
Return
WinGet, aWndId, ID, A
WinGet, aWndId, ID, A Debug_logMessage("DEBUG[2] Active Windows ID: " . aWndId, 2, False)
Debug_logMessage("DEBUG[2] Active Windows ID: " . aWndId, 2, False) v := Monitor_#%Manager_aMonitor%_aView_#1
v := Monitor_#%Manager_aMonitor%_aView_#1 Debug_logMessage("DEBUG[2] View (" . v . ") wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 2, False)
Debug_logMessage("DEBUG[2] View (" . v . ") wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 2, False) StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1 StringSplit, wndId, wndIds, `;
StringSplit, wndId, wndIds, `; Debug_logMessage("DEBUG[2] wndId count: " . wndId0, 2, False)
Debug_logMessage("DEBUG[2] wndId count: " . wndId0, 2, False) If (i > 0) And (i <= wndId0) And (d = 0) {
If (i > 0) And (i <= wndId0) And (d = 0) { wndId := wndId%i%
wndId := wndId%i% Window_set(wndId, "AlwaysOnTop", "On")
Window_set(wndId, "AlwaysOnTop", "On") Window_set(wndId, "AlwaysOnTop", "Off")
Window_set(wndId, "AlwaysOnTop", "Off") Window_#%wndId%_isMinimized := False
Window_#%wndId%_isMinimized := False Manager_winActivate(wndId)
Manager_winActivate(wndId) } Else If (wndId0 > 1) {
} Else If (wndId0 > 1) { If Not InStr(Manager_managedWndIds, aWndId . ";") Or Window_#%aWndId%_isFloating
If Not InStr(Manager_managedWndIds, aWndId . ";") Or Window_#%aWndId%_isFloating Window_set(aWndId, "Bottom", "")
Window_set(aWndId, "Bottom", "") Loop, % wndId0 {
Loop, % wndId0 { If (wndId%A_Index% = aWndId) {
If (wndId%A_Index% = aWndId) { j := A_Index
j := A_Index Break
Break }
} }
} Debug_logMessage("DEBUG[2] Current wndId index: " . j, 2, False)
Debug_logMessage("DEBUG[2] Current wndId index: " . j, 2, False)
If (d > 0)
If (d > 0) direction = 1
direction = 1 Else
Else direction = -1
direction = -1 i := Manager_loop(j, d, 1, wndId0)
i := Manager_loop(j, d, 1, wndId0) Loop, % wndId0 {
Loop, % wndId0 { Debug_logMessage("DEBUG[2] Next wndId index: " . i, 2, False)
Debug_logMessage("DEBUG[2] Next wndId index: " . i, 2, False) wndId := wndId%i%
wndId := wndId%i% If Not Window_#%wndId%_isMinimized {
If Not Window_#%wndId%_isMinimized { Window_set(wndId, "AlwaysOnTop", "On")
Window_set(wndId, "AlwaysOnTop", "On") Window_set(wndId, "AlwaysOnTop", "Off")
Window_set(wndId, "AlwaysOnTop", "Off")
;; If there are hung windows on the screen, we still want to be able to cycle through them.
;; If there are hung windows on the screen, we still want to be able to cycle through them. failure := Manager_winActivate(wndId)
failure := Manager_winActivate(wndId) If Not failure
If Not failure Break
Break }
} i := Manager_loop(i, direction, 1, wndId0)
i := Manager_loop(i, direction, 1, wndId0) }
} }
} }
}
View_addWindow(m, v, wndId) {
View_addWindow(m, v, wndId) { Local i, mSplit, n, replace, search
Local i, mSplit, n, replace, search
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, % wndId ";",, All
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, % wndId ";",, All If Tiler_isActive(m, v) And ((Config_newWndPosition = "masterBottom") Or (Config_newWndPosition = "stackTop")) {
If Tiler_isActive(m, v) And ((Config_newWndPosition = "masterBottom") Or (Config_newWndPosition = "stackTop")) { n := View_getTiledWndIds(m, v)
n := View_getTiledWndIds(m, v) mSplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY
mSplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY If (mSplit = 1 And Config_newWndPosition = "masterBottom")
If (mSplit = 1 And Config_newWndPosition = "masterBottom") View_#%m%_#%v%_wndIds := wndId ";" . View_#%m%_#%v%_wndIds
View_#%m%_#%v%_wndIds := wndId ";" . View_#%m%_#%v%_wndIds Else If ((Config_newWndPosition = "masterBottom" And n < mSplit) Or (Config_newWndPosition = "stackTop" And n <= mSplit))
Else If ((Config_newWndPosition = "masterBottom" And n < mSplit) Or (Config_newWndPosition = "stackTop" And n <= mSplit)) View_#%m%_#%v%_wndIds .= wndId ";"
View_#%m%_#%v%_wndIds .= wndId ";" Else {
Else { If (Config_newWndPosition = "masterBottom")
If (Config_newWndPosition = "masterBottom") i := mSplit - 1
i := mSplit - 1 Else
Else i := mSplit
i := mSplit search := View_tiledWndId%i% ";"
search := View_tiledWndId%i% ";" replace := search wndId ";"
replace := search wndId ";" StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace% }
} }
} Else If (Config_newWndPosition = "bottom")
Else If (Config_newWndPosition = "bottom") View_#%m%_#%v%_wndIds .= wndId ";"
View_#%m%_#%v%_wndIds .= wndId ";" Else
Else View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds
View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds }
}
View_arrange(m, v, setLayout = False) {
View_arrange(m, v, setLayout = False) { Local fn, h, l, w, x, y
Local fn, h, l, w, x, y
Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1)
Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1)
l := View_#%m%_#%v%_layout_#1
l := View_#%m%_#%v%_layout_#1 fn := Config_layoutFunction_#%l%
fn := Config_layoutFunction_#%l% If fn {
If fn { x := Monitor_#%m%_x + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin4
x := Monitor_#%m%_x + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin4 y := Monitor_#%m%_y + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin1
y := Monitor_#%m%_y + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin1 w := Monitor_#%m%_width - 2 * View_#%m%_#%v%_layoutGapWidth - View_#%m%_#%v%_margin4 - View_#%m%_#%v%_margin2
w := Monitor_#%m%_width - 2 * View_#%m%_#%v%_layoutGapWidth - View_#%m%_#%v%_margin4 - View_#%m%_#%v%_margin2 h := Monitor_#%m%_height - 2 * View_#%m%_#%v%_layoutGapWidth - View_#%m%_#%v%_margin1 - View_#%m%_#%v%_margin3
h := Monitor_#%m%_height - 2 * View_#%m%_#%v%_layoutGapWidth - View_#%m%_#%v%_margin1 - View_#%m%_#%v%_margin3
;; All window actions are performed on independent windows. A delay won't help.
;; All window actions are performed on independent windows. A delay won't help. SetWinDelay, 0
SetWinDelay, 0 If Config_dynamicTiling Or setLayout {
If Config_dynamicTiling Or setLayout { View_getTiledWndIds(m, v)
View_getTiledWndIds(m, v) If (fn = "monocle") {
If (fn = "monocle") { ;; 'View_getLayoutSymbol_monocle'
;; 'View_getLayoutSymbol_monocle' View_#%m%_#%v%_layoutSymbol := "[" View_tiledWndId0 "]"
View_#%m%_#%v%_layoutSymbol := "[" View_tiledWndId0 "]" ;; 'View_arrange_monocle'
;; 'View_arrange_monocle' Tiler_stackTiles(0, 0, 1, View_tiledWndId0, +1, 3, x, y, w, h, 0)
Tiler_stackTiles(0, 0, 1, View_tiledWndId0, +1, 3, x, y, w, h, 0) } Else ;; (fn = "tile")
} Else ;; (fn = "tile") Tiler_layoutTiles(m, v, x, y, w, h)
Tiler_layoutTiles(m, v, x, y, w, h) } Else If (fn = "tile") {
} Else If (fn = "tile") { Tiler_layoutTiles(m, v, x, y, w, h, "blank")
Tiler_layoutTiles(m, v, x, y, w, h, "blank") If Config_continuouslyTraceAreas
If Config_continuouslyTraceAreas View_traceAreas(True)
View_traceAreas(True) }
} SetWinDelay, 10
SetWinDelay, 10 }
} Else ;; floating layout (no 'View_arrange_', following is 'View_getLayoutSymbol_')'
Else ;; floating layout (no 'View_arrange_', following is 'View_getLayoutSymbol_')' View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#%l%
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#%l%
;Bar_updateLayout(m)
Bar_updateLayout(m) }
}
View_getActiveWindow(m, v) {
View_getActiveWindow(m, v) { Local listId, listIds, wndId
Local listId, listIds, wndId
listIds := "aWndIds;wndIds"
listIds := "aWndIds;wndIds" wndId := 0
wndId := 0 Loop, Parse, listIds, `;
Loop, Parse, listIds, `; {
{ listId := A_LoopField
listId := A_LoopField Loop, Parse, View_#%m%_#%v%_%listId%, `;
Loop, Parse, View_#%m%_#%v%_%listId%, `; {
{ If Not A_LoopField
If Not A_LoopField Break
Break Else If Not WinExist("ahk_id" A_LoopField) Or Window_#%A_LoopField%_isMinimized
Else If Not WinExist("ahk_id" A_LoopField) Or Window_#%A_LoopField%_isMinimized Continue
Continue Else {
Else { wndId := A_LoopField
wndId := A_LoopField Break
Break }
} }
} If wndId {
If wndId { If (listId = "wndIds")
If (listId = "wndIds") View_setActiveWindow(m, v, wndId)
View_setActiveWindow(m, v, wndId) Break
Break }
} }
}
Return, wndId
Return, wndId }
}
View_getTiledWndIds(m, v)
View_getTiledWndIds(m, v) {
{ Local n, tiledWndIds, wndIds
Local n, tiledWndIds, wndIds
n := 0
n := 0 tiledWndIds := ""
tiledWndIds := "" StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1 Loop, PARSE, wndIds, `;
Loop, PARSE, wndIds, `; {
{ If A_LoopField And Not Window_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Window_isHung(A_LoopField)
If A_LoopField And Not Window_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Window_isHung(A_LoopField) {
{ n += 1
n += 1 tiledWndIds .= A_LoopField ";"
tiledWndIds .= A_LoopField ";" }
} }
} View_tiledWndIds := tiledWndIds
View_tiledWndIds := tiledWndIds StringTrimRight, tiledWndIds, tiledWndIds, 1
StringTrimRight, tiledWndIds, tiledWndIds, 1 StringSplit, View_tiledWndId, tiledWndIds, `;
StringSplit, View_tiledWndId, tiledWndIds, `;
Return, n
Return, n }
}
View_ghostWindow(m, v, bodyWndId, ghostWndId)
View_ghostWindow(m, v, bodyWndId, ghostWndId) {
{ Local search, replace
Local search, replace
search := bodyWndId ";"
search := bodyWndId ";" replace := search ghostWndId ";"
replace := search ghostWndId ";" StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace% }
}
View_moveToIndex(m, v, n, w) {
View_moveToIndex(m, v, n, w) { Local wndIds
Local wndIds
View_#%n%_#%w%_area_#0 := View_#%m%_#%v%_area_#0
View_#%n%_#%w%_area_#0 := View_#%m%_#%v%_area_#0 View_#%n%_#%w%_aWndIds := View_#%m%_#%v%_aWndIds
View_#%n%_#%w%_aWndIds := View_#%m%_#%v%_aWndIds View_#%n%_#%w%_layout_#1 := View_#%m%_#%v%_layout_#1
View_#%n%_#%w%_layout_#1 := View_#%m%_#%v%_layout_#1 View_#%n%_#%w%_layout_#2 := View_#%m%_#%v%_layout_#2
View_#%n%_#%w%_layout_#2 := View_#%m%_#%v%_layout_#2 View_#%n%_#%w%_layoutAxis_#1 := View_#%m%_#%v%_layoutAxis_#1
View_#%n%_#%w%_layoutAxis_#1 := View_#%m%_#%v%_layoutAxis_#1 View_#%n%_#%w%_layoutAxis_#2 := View_#%m%_#%v%_layoutAxis_#2
View_#%n%_#%w%_layoutAxis_#2 := View_#%m%_#%v%_layoutAxis_#2 View_#%n%_#%w%_layoutAxis_#3 := View_#%m%_#%v%_layoutAxis_#3
View_#%n%_#%w%_layoutAxis_#3 := View_#%m%_#%v%_layoutAxis_#3 View_#%n%_#%w%_layoutGapWidth := View_#%m%_#%v%_layoutGapWidth
View_#%n%_#%w%_layoutGapWidth := View_#%m%_#%v%_layoutGapWidth View_#%n%_#%w%_layoutMFact := View_#%m%_#%v%_layoutMFact
View_#%n%_#%w%_layoutMFact := View_#%m%_#%v%_layoutMFact View_#%n%_#%w%_layoutMX := View_#%m%_#%v%_layoutMX
View_#%n%_#%w%_layoutMX := View_#%m%_#%v%_layoutMX View_#%n%_#%w%_layoutMY := View_#%m%_#%v%_layoutMY
View_#%n%_#%w%_layoutMY := View_#%m%_#%v%_layoutMY View_#%n%_#%w%_layoutSymbol := View_#%m%_#%v%_layoutSymbol
View_#%n%_#%w%_layoutSymbol := View_#%m%_#%v%_layoutSymbol View_#%n%_#%w%_margins := View_#%m%_#%v%_margins
View_#%n%_#%w%_margins := View_#%m%_#%v%_margins View_#%n%_#%w%_showStackArea := View_#%m%_#%v%_showStackArea
View_#%n%_#%w%_showStackArea := View_#%m%_#%v%_showStackArea View_#%n%_#%w%_wndIds := View_#%m%_#%v%_wndIds
View_#%n%_#%w%_wndIds := View_#%m%_#%v%_wndIds StringSplit, View_#%n%_#%w%_margin, View_#%n%_#%w%_margins, `;
StringSplit, View_#%n%_#%w%_margin, View_#%n%_#%w%_margins, `; StringTrimRight, wndIds, View_#%n%_#%w%_wndIds, 1
StringTrimRight, wndIds, View_#%n%_#%w%_wndIds, 1 Loop, PARSE, wndIds, `;
Loop, PARSE, wndIds, `; {
{ Window_#%A_LoopField%_monitor := n
Window_#%A_LoopField%_monitor := n Window_#%A_LoopField%_tags -= 1 << v - 1
Window_#%A_LoopField%_tags -= 1 << v - 1 Window_#%A_LoopField%_tags += 1 << w - 1
Window_#%A_LoopField%_tags += 1 << w - 1 }
} }
}
; @TODO: Theoretically, something is wrong here. From the hotkeys this should be manual tiling, but the function says otherwise.
; @TODO: Theoretically, something is wrong here. From the hotkeys this should be manual tiling, but the function says otherwise. View_moveWindow(i=0, d=0) {
View_moveWindow(i=0, d=0) { Local aWndId, m, v
Local aWndId, m, v
WinGet, aWndId, ID, A
WinGet, aWndId, ID, A m := Manager_aMonitor
m := Manager_aMonitor v := Monitor_#%m%_aView_#1
v := Monitor_#%m%_aView_#1 If Tiler_isActive(Manager_aMonitor, v) And InStr(Manager_managedWndIds, aWndId ";") And Not (i = 0 And d = 0) And View_#%m%_#%v%_area_#0 And (i <= View_#%m%_#%v%_area_#0) {
If Tiler_isActive(Manager_aMonitor, v) And InStr(Manager_managedWndIds, aWndId ";") And Not (i = 0 And d = 0) And View_#%m%_#%v%_area_#0 And (i <= View_#%m%_#%v%_area_#0) { If (i = 0)
If (i = 0) i := Manager_loop(Window_#%aWndId%_area, d, 1, View_#%m%_#%v%_area_#0)
i := Manager_loop(Window_#%aWndId%_area, d, 1, View_#%m%_#%v%_area_#0) Window_move(aWndId, View_#%m%_#%v%_area_#%i%_x, View_#%m%_#%v%_area_#%i%_y, View_#%m%_#%v%_area_#%i%_width, View_#%m%_#%v%_area_#%i%_height)
Window_move(aWndId, View_#%m%_#%v%_area_#%i%_x, View_#%m%_#%v%_area_#%i%_y, View_#%m%_#%v%_area_#%i%_width, View_#%m%_#%v%_area_#%i%_height) Window_#%aWndId%_area := i
Window_#%aWndId%_area := i Manager_setCursor(aWndId)
Manager_setCursor(aWndId) }
} }
}
View_resetTileLayout() {
View_resetTileLayout() { Local m, v
Local m, v
m := Manager_aMonitor
m := Manager_aMonitor v := Monitor_#%m%_aView_#1
v := Monitor_#%m%_aView_#1
View_#%m%_#%v%_area_#0 := 0
View_#%m%_#%v%_area_#0 := 0 View_#%m%_#%v%_layout_#2 := View_#%m%_#%v%_layout_#1
View_#%m%_#%v%_layout_#2 := View_#%m%_#%v%_layout_#1 View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layout_#1 := 1 View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1 View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2
View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2 View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3
View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3 View_#%m%_#%v%_layoutGapWidth := Config_layoutGapWidth
View_#%m%_#%v%_layoutGapWidth := Config_layoutGapWidth View_#%m%_#%v%_layoutMFact := Config_layoutMFactor
View_#%m%_#%v%_layoutMFact := Config_layoutMFactor View_#%m%_#%v%_layoutMX := 1
View_#%m%_#%v%_layoutMX := 1 View_#%m%_#%v%_layoutMY := 1
View_#%m%_#%v%_layoutMY := 1 View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1 View_#%m%_#%v%_margins := "0;0;0;0"
View_#%m%_#%v%_margins := "0;0;0;0" View_#%m%_#%v%_showStackArea := True
View_#%m%_#%v%_showStackArea := True StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `;
StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `;
If Tiler_isActive(m, v)
If Tiler_isActive(m, v) View_arrange(m, v)
View_arrange(m, v) }
}
View_setActiveWindow(m, v, wndId) {
View_setActiveWindow(m, v, wndId) { Global
Global
If wndId {
If wndId { StringReplace, View_#%m%_#%v%_aWndIds, View_#%m%_#%v%_aWndIds, % wndId ";", All
StringReplace, View_#%m%_#%v%_aWndIds, View_#%m%_#%v%_aWndIds, % wndId ";", All View_#%m%_#%v%_aWndIds := wndId ";" View_#%m%_#%v%_aWndIds
View_#%m%_#%v%_aWndIds := wndId ";" View_#%m%_#%v%_aWndIds }
} }
}
View_setGapWidth(i, d = 0) {
View_setGapWidth(i, d = 0) { Local v
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
v := Monitor_#%Manager_aMonitor%_aView_#1 If (i = 0) And (d != 0)
If (i = 0) And (d != 0) i := View_#%Manager_aMonitor%_#%v%_layoutGapWidth
i := View_#%Manager_aMonitor%_#%v%_layoutGapWidth i += d
i += d If (i >= 0 And i < Monitor_#%Manager_aMonitor%_height And i < Monitor_#%Manager_aMonitor%_width) {
If (i >= 0 And i < Monitor_#%Manager_aMonitor%_height And i < Monitor_#%Manager_aMonitor%_width) { i := Ceil(i / 2) * 2
i := Ceil(i / 2) * 2 View_#%Manager_aMonitor%_#%v%_layoutGapWidth := i
View_#%Manager_aMonitor%_#%v%_layoutGapWidth := i Return, 1
Return, 1 } Else
} Else Return, 0
Return, 0 }
}
View_setLayout(i, d = 0) {
View_setLayout(i, d = 0) { Local v
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
v := Monitor_#%Manager_aMonitor%_aView_#1 If (i = -1)
If (i = -1) i := View_#%Manager_aMonitor%_#%v%_layout_#2
i := View_#%Manager_aMonitor%_#%v%_layout_#2 Else If (i = 0)
Else If (i = 0) i := View_#%Manager_aMonitor%_#%v%_layout_#1
i := View_#%Manager_aMonitor%_#%v%_layout_#1 i := Manager_loop(i, d, 1, Config_layoutCount)
i := Manager_loop(i, d, 1, Config_layoutCount) If (i > 0) And (i <= Config_layoutCount) {
If (i > 0) And (i <= Config_layoutCount) { If Not (i = View_#%Manager_aMonitor%_#%v%_layout_#1) {
If Not (i = View_#%Manager_aMonitor%_#%v%_layout_#1) { View_#%Manager_aMonitor%_#%v%_layout_#2 := View_#%Manager_aMonitor%_#%v%_layout_#1
View_#%Manager_aMonitor%_#%v%_layout_#2 := View_#%Manager_aMonitor%_#%v%_layout_#1 View_#%Manager_aMonitor%_#%v%_layout_#1 := i
View_#%Manager_aMonitor%_#%v%_layout_#1 := i }
} View_arrange(Manager_aMonitor, v, True)
View_arrange(Manager_aMonitor, v, True) }
} }
}
View_setLayoutProperty(name, i, d, opt = 0) {
View_setLayoutProperty(name, i, d, opt = 0) { Local a, l, v
Local a, l, v
a := False
a := False v := Monitor_#%Manager_aMonitor%_aView_#1
v := Monitor_#%Manager_aMonitor%_aView_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 If Tiler_isActive(Manager_aMonitor, v) {
If Tiler_isActive(Manager_aMonitor, v) { If (name = "Axis")
If (name = "Axis") a := Tiler_setAxis(Manager_aMonitor, v, opt, d)
a := Tiler_setAxis(Manager_aMonitor, v, opt, d) Else If (name = "MFactor") {
Else If (name = "MFactor") { If (opt = 0)
If (opt = 0) opt := 1
opt := 1 a := Tiler_setMFactor(Manager_aMonitor, v, i, d, opt)
a := Tiler_setMFactor(Manager_aMonitor, v, i, d, opt) } Else If (name = "MX")
} Else If (name = "MX") a := Tiler_setMX(Manager_aMonitor, v, d)
a := Tiler_setMX(Manager_aMonitor, v, d) Else If (name = "MY")
Else If (name = "MY") a := Tiler_setMY(Manager_aMonitor, v, d)
a := Tiler_setMY(Manager_aMonitor, v, d) }
} If (name = "GapWidth") And (Tiler_isActive(Manager_aMonitor, v) Or (Config_layoutFunction_#%l% = "monocle"))
If (name = "GapWidth") And (Tiler_isActive(Manager_aMonitor, v) Or (Config_layoutFunction_#%l% = "monocle")) a := View_setGapWidth(i, d)
a := View_setGapWidth(i, d)
If a
If a View_arrange(Manager_aMonitor, v)
View_arrange(Manager_aMonitor, v) }
}
View_shuffleWindow(i, d = 0) {
View_shuffleWindow(i, d = 0) { Local aWndId, j, replace, v
Local aWndId, j, replace, v
Debug_logMessage("DEBUG[2] View_shuffleWindow(" . i . ", " . d . ")", 2)
Debug_logMessage("DEBUG[2] View_shuffleWindow(" . i . ", " . d . ")", 2) v := Monitor_#%Manager_aMonitor%_aView_#1
v := Monitor_#%Manager_aMonitor%_aView_#1 If Tiler_isActive(Manager_aMonitor, v) {
If Tiler_isActive(Manager_aMonitor, v) { View_getTiledWndIds(Manager_aMonitor, v)
View_getTiledWndIds(Manager_aMonitor, v) WinGet, aWndId, ID, A
WinGet, aWndId, ID, A If InStr(View_tiledWndIds, aWndId ";") And (View_tiledWndId0 > 1) {
If InStr(View_tiledWndIds, aWndId ";") And (View_tiledWndId0 > 1) { Loop, % View_tiledWndId0 {
Loop, % View_tiledWndId0 { If (View_tiledWndId%A_Index% = aWndId) {
If (View_tiledWndId%A_Index% = aWndId) { j := A_Index
j := A_Index Break
Break }
} }
} If (i = 0)
If (i = 0) i := j
i := j Else If (i = 1 And j = 1)
Else If (i = 1 And j = 1) i := 2
i := 2 i := Manager_loop(i, d, 1, View_tiledWndId0)
i := Manager_loop(i, d, 1, View_tiledWndId0) Debug_logMessage("DEBUG[2] View_shuffleWindow: " . j . " -> " . i, 2)
Debug_logMessage("DEBUG[2] View_shuffleWindow: " . j . " -> " . i, 2) If (i != j) {
If (i != j) { If (i < j)
If (i < j) replace := aWndId ";" View_tiledWndId%i% ";"
replace := aWndId ";" View_tiledWndId%i% ";" Else
Else replace := View_tiledWndId%i% ";" aWndId ";"
replace := View_tiledWndId%i% ";" aWndId ";" StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, % aWndId ";",
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, % aWndId ";", StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, % View_tiledWndId%i% ";", %replace%
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, % View_tiledWndId%i% ";", %replace% View_arrange(Manager_aMonitor, v)
View_arrange(Manager_aMonitor, v) Manager_setCursor(aWndId)
Manager_setCursor(aWndId) }
} }
} }
} }
}
View_toggleFloatingWindow(wndId = 0) {
View_toggleFloatingWindow(wndId = 0) { Local l, v
Local l, v
If (wndId = 0)
If (wndId = 0) WinGet, wndId, ID, A
WinGet, wndId, ID, A v := Monitor_#%Manager_aMonitor%_aView_#1
v := Monitor_#%Manager_aMonitor%_aView_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 Debug_logMessage("DEBUG[2] View_toggleFloatingWindow; wndId: " . wndId, 2)
Debug_logMessage("DEBUG[2] View_toggleFloatingWindow; wndId: " . wndId, 2) If (Config_layoutFunction_#%l% And InStr(Manager_managedWndIds, wndId ";")) {
If (Config_layoutFunction_#%l% And InStr(Manager_managedWndIds, wndId ";")) { Window_#%wndId%_isFloating := Not Window_#%wndId%_isFloating
Window_#%wndId%_isFloating := Not Window_#%wndId%_isFloating View_arrange(Manager_aMonitor, v)
View_arrange(Manager_aMonitor, v) Bar_updateTitle()
Bar_updateTitle() }
} }
}
View_toggleMargins()
View_toggleMargins() {
{ Local v
Local v
If Not (Config_viewMargins = "0;0;0;0")
{
If Not (Config_viewMargins = "0;0;0;0") v := Monitor_#%Manager_aMonitor%_aView_#1
{ Debug_logMessage("DEBUG[3] View_toggleMargins(" . View_#%Manager_aMonitor%_#%v%_margin1 . ", " . View_#%Manager_aMonitor%_#%v%_margin2 . ", " . View_#%Manager_aMonitor%_#%v%_margin3 . ", " . View_#%Manager_aMonitor%_#%v%_margin4 . ")", 3)
v := Monitor_#%Manager_aMonitor%_aView_#1 If (View_#%Manager_aMonitor%_#%v%_margins = "0;0;0;0")
Debug_logMessage("DEBUG[3] View_toggleMargins(" . View_#%Manager_aMonitor%_#%v%_margin1 . ", " . View_#%Manager_aMonitor%_#%v%_margin2 . ", " . View_#%Manager_aMonitor%_#%v%_margin3 . ", " . View_#%Manager_aMonitor%_#%v%_margin4 . ")", 3) View_#%Manager_aMonitor%_#%v%_margins := Config_viewMargins
If (View_#%Manager_aMonitor%_#%v%_margins = "0;0;0;0") Else
View_#%Manager_aMonitor%_#%v%_margins := Config_viewMargins View_#%Manager_aMonitor%_#%v%_margins := "0;0;0;0"
Else StringSplit, View_#%Manager_aMonitor%_#%v%_margin, View_#%Manager_aMonitor%_#%v%_margins, `;
View_#%Manager_aMonitor%_#%v%_margins := "0;0;0;0" View_arrange(Manager_aMonitor, v)
StringSplit, View_#%Manager_aMonitor%_#%v%_margin, View_#%Manager_aMonitor%_#%v%_margins, `; }
View_arrange(Manager_aMonitor, v) }
}
} View_toggleStackArea() {
Local v
View_toggleStackArea() {
Local v v := Monitor_#%Manager_aMonitor%_aView_#1
If Tiler_isActive(Manager_aMonitor, v) And Not Config_dynamicTiling {
v := Monitor_#%Manager_aMonitor%_aView_#1 Tiler_toggleStackArea(Manager_aMonitor, v)
If Tiler_isActive(Manager_aMonitor, v) And Not Config_dynamicTiling { View_arrange(Manager_aMonitor, v)
Tiler_toggleStackArea(Manager_aMonitor, v) }
View_arrange(Manager_aMonitor, v) }
}
} View_traceAreas(continuously = False) {
Local v
View_traceAreas(continuously = False) {
Local v v := Monitor_#%Manager_aMonitor%_aView_#1
If Tiler_isActive(Manager_aMonitor, v) And Not Config_dynamicTiling
v := Monitor_#%Manager_aMonitor%_aView_#1 Tiler_traceAreas(Manager_aMonitor, v, continuously)
If Tiler_isActive(Manager_aMonitor, v) And Not Config_dynamicTiling }
Tiler_traceAreas(Manager_aMonitor, v, continuously)
}

View File

@ -1,187 +1,187 @@
/** /**
* hul! - Find and restore (hidden) windows * hul! - Find and restore (hidden) windows
* Copyright (c) 2011 joten * Copyright (c) 2011 joten
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* @version 0.1.0.01 (02.10.2011) * @version 0.1.0.01 (02.10.2011)
*/ */
NAME := "hul!" NAME := "hul!"
VERSION := "0.1.0" VERSION := "0.1.0"
HELP := HELP :=
(Join (Join
"USAGE`n "USAGE`n
`n `n
Specify one, two or all of the following search criteria:`n Specify one, two or all of the following search criteria:`n
- Type a regular expression in the field next to 'Partial title'.`n - Type a regular expression in the field next to 'Partial title'.`n
- Type a class name (exact match) in the field next to 'Class name'.`n - Type a class name (exact match) in the field next to 'Class name'.`n
- Type a process name (e. g. the name of an exeutable, exact match) in the field next to 'Process name'.`n - Type a process name (e. g. the name of an exeutable, exact match) in the field next to 'Process name'.`n
`n `n
The search will be done on typing the search criteria.`n The search will be done on typing the search criteria.`n
`n `n
You may navigate between the input fields by pressing Tab (forward) or Shift+Tab (back).`n You may navigate between the input fields by pressing Tab (forward) or Shift+Tab (back).`n
Press Enter to go to the list box, which contains the search results.`n Press Enter to go to the list box, which contains the search results.`n
Select an entry and press Enter again to restore the selected window.`n Select an entry and press Enter again to restore the selected window.`n
`n `n
Press the Escape (Esc) key to clear all fields and go back to entering the search criteria.`n" Press the Escape (Esc) key to clear all fields and go back to entering the search criteria.`n"
) )
/** /**
* Script settings * Script settings
*/ */
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#NoTrayIcon #NoTrayIcon
#SingleInstance force #SingleInstance force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; DetectHiddenWindows, On ; DetectHiddenWindows, On
; SetFormat, Integer, h ; SetFormat, Integer, h
/** /**
* Pseudo main function * Pseudo main function
*/ */
WinGet, Main_aWndId, ID, A WinGet, Main_aWndId, ID, A
; BEGIN: Init GUI ; BEGIN: Init GUI
IfWinExist, %NAME% IfWinExist, %NAME%
Gui, Destroy Gui, Destroy
Gui, +LastFound +0xCF0000 -0x80000000 Gui, +LastFound +0xCF0000 -0x80000000
Gui, Add, Text, yp+11, Partial Title: Gui, Add, Text, yp+11, Partial Title:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_title, Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_title,
Gui, Add, Text, xm, Class Name: Gui, Add, Text, xm, Class Name:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_class, Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_class,
Gui, Add, Text, xm, Process Name: Gui, Add, Text, xm, Process Name:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_pName, Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_pName,
; Gui, Add, Button, xm w800 vGui_search, Search ; Gui, Add, Button, xm w800 vGui_search, Search
Gui, Add, ListBox, +0x100 t36 xm w800 vGui_wnds, Gui, Add, ListBox, +0x100 t36 xm w800 vGui_wnds,
Gui, Add, Button, Default Hidden w800 vGui_restore, Restore Gui, Add, Button, Default Hidden w800 vGui_restore, Restore
Gui, Show, AutoSize, %NAME% Gui, Show, AutoSize, %NAME%
Gui_wndId := WinExist() Gui_wndId := WinExist()
Main_resize() Main_resize()
; END: Init GUI ; END: Init GUI
Return ; end of the auto-execute section Return ; end of the auto-execute section
/** /**
* Hotkeys, function & label definitions * Hotkeys, function & label definitions
*/ */
#IfWinActive hul! ahk_class AutoHotkeyGUI #IfWinActive hul! ahk_class AutoHotkeyGUI
{ {
^h::MsgBox %HELP% ^h::MsgBox %HELP%
} }
ButtonRestore: ButtonRestore:
Main_restore() Main_restore()
Return Return
ButtonSearch: ButtonSearch:
Main_search() Main_search()
Return Return
GuiClose: GuiClose:
ExitApp ExitApp
Return Return
GuiEscape: GuiEscape:
GuiControl, , Gui_title, GuiControl, , Gui_title,
GuiControl, , Gui_class, GuiControl, , Gui_class,
GuiControl, , Gui_pName, GuiControl, , Gui_pName,
GuiControl, , Gui_wnds, | GuiControl, , Gui_wnds, |
GuiControl, Focus, Gui_title GuiControl, Focus, Gui_title
Return Return
GuiSize: GuiSize:
Main_resize(A_GuiWidth, A_GuiHeight) Main_resize(A_GuiWidth, A_GuiHeight)
Return Return
Main_resize(w = 0, h = 0) { Main_resize(w = 0, h = 0) {
Global Gui_wndId Global Gui_wndId
If (w = 0 Or h = 0) { If (w = 0 Or h = 0) {
Sleep, 250 Sleep, 250
WinGetPos, x, y, w, h, ahk_id %Gui_wndId% WinGetPos, x, y, w, h, ahk_id %Gui_wndId%
h += 1 h += 1
WinMove, ahk_id %Gui_wndId%, , x, y, w, h WinMove, ahk_id %Gui_wndId%, , x, y, w, h
} Else { } Else {
w -= 2 * 10 w -= 2 * 10
w1 := w - (72 + 10) w1 := w - (72 + 10)
h -= 3 * 30 h -= 3 * 30
; y := 8 + (3 * 30) + h + 8 ; y := 8 + (3 * 30) + h + 8
GuiControl, Move, Gui_title, w%w1% GuiControl, Move, Gui_title, w%w1%
GuiControl, Move, Gui_class, w%w1% GuiControl, Move, Gui_class, w%w1%
GuiControl, Move, Gui_pName, w%w1% GuiControl, Move, Gui_pName, w%w1%
; GuiControl, Move, Gui_search, w%w% ; GuiControl, Move, Gui_search, w%w%
GuiControl, Move, Gui_wnds, w%w% h%h% GuiControl, Move, Gui_wnds, w%w% h%h%
; GuiControl, Move, Gui_restore, y%y% w%w% ; GuiControl, Move, Gui_restore, y%y% w%w%
} }
} }
Main_restore() { Main_restore() {
Global Gui_wnds Global Gui_wnds
GuiControlGet, wnd, , Gui_wnds GuiControlGet, wnd, , Gui_wnds
If wnd { If wnd {
wndId := SubStr(wnd, 1, InStr(wnd, ": ") - 1) wndId := SubStr(wnd, 1, InStr(wnd, ": ") - 1)
WinShow, ahk_id %wndId% WinShow, ahk_id %wndId%
WinRestore, ahk_id %wndId% WinRestore, ahk_id %wndId%
WinSet, AlwaysOnTop, On, ahk_id %wndId% WinSet, AlwaysOnTop, On, ahk_id %wndId%
WinSet, AlwaysOnTop, Off, ahk_id %wndId% WinSet, AlwaysOnTop, Off, ahk_id %wndId%
WinMove, ahk_id %wndId%, , 0, 0, 800, 600 WinMove, ahk_id %wndId%, , 0, 0, 800, 600
} Else } Else
GuiControl, Focus, Gui_wnds GuiControl, Focus, Gui_wnds
} }
Main_search() { Main_search() {
Global Gui_class, Gui_pName, Gui_title, Gui_wndId, Gui_wnds Global Gui_class, Gui_pName, Gui_title, Gui_wndId, Gui_wnds
GuiControl, , Gui_wnds, | GuiControl, , Gui_wnds, |
GuiControlGet, title, , Gui_title GuiControlGet, title, , Gui_title
GuiControlGet, class, , Gui_class GuiControlGet, class, , Gui_class
If class If class
criteria .= " ahk_class " class criteria .= " ahk_class " class
GuiControlGet, pName, , Gui_pName GuiControlGet, pName, , Gui_pName
If pName { If pName {
Process, Exist, %pName% Process, Exist, %pName%
If ErrorLevel If ErrorLevel
criteria .= " ahk_pid " ErrorLevel criteria .= " ahk_pid " ErrorLevel
} }
If Not (criteria Or title) If Not (criteria Or title)
criteria := "A" criteria := "A"
wndListString := "" wndListString := ""
DetectHiddenWindows, On DetectHiddenWindows, On
WinGet, wndId, List, % criteria WinGet, wndId, List, % criteria
Loop, % wndId { Loop, % wndId {
WinGetTitle, wndTitle, % "ahk_id " wndId%A_Index% WinGetTitle, wndTitle, % "ahk_id " wndId%A_Index%
If Not (wndId%A_Index% = Gui_wndId) And (Not title Or RegExmatch(wndTitle, title)) { If Not (wndId%A_Index% = Gui_wndId) And (Not title Or RegExmatch(wndTitle, title)) {
WinGetClass, wndClass, % "ahk_id " wndId%A_Index% WinGetClass, wndClass, % "ahk_id " wndId%A_Index%
WinGet, wndPName, ProcessName, % "ahk_id " wndId%A_Index% WinGet, wndPName, ProcessName, % "ahk_id " wndId%A_Index%
WinGet, wndStyle, Style, % "ahk_id " wndId%A_Index% WinGet, wndStyle, Style, % "ahk_id " wndId%A_Index%
WinGetPos, wndPosX, wndPosY, wndPosW, wndPosH, % "ahk_id " wndId%A_Index% WinGetPos, wndPosX, wndPosY, wndPosW, wndPosH, % "ahk_id " wndId%A_Index%
wndListString .= "|" wndId%A_Index% ": `t" wndTitle " (" wndClass ", " wndPName ", " wndStyle ", " wndPosX ", " wndPosY ", " wndPosW ", " wndPosH ")" wndListString .= "|" wndId%A_Index% ": `t" wndTitle " (" wndClass ", " wndPName ", " wndStyle ", " wndPosX ", " wndPosY ", " wndPosW ", " wndPosH ")"
} }
} }
DetectHiddenWindows, Off DetectHiddenWindows, Off
GuiControl, , Gui_wnds, % wndListString GuiControl, , Gui_wnds, % wndListString
} }