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
Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0
*/
Debug_initLog(filename, level = 0, truncateFile = True)
{
Global Debug_logFilename, Debug_logLevel
Debug_logFilename := filename
Debug_logLevel := level
If truncateFile
If FileExist(Debug_logFilename)
FileDelete, %Debug_logFilename%
}
Debug_logHelp()
{
Debug_logMessage("Help Display", 0)
Debug_logMessage("Window list columns", 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(" 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(" 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(" 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(" M - Monitor number.", 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(" Y - Windows Y position.", 0, False)
Debug_logMessage(" W - Windows width.", 0, False)
Debug_logMessage(" H - Windows height.", 0, False)
Debug_logMessage(" Style - Windows style.", 0, False)
Debug_logMessage(" Proc / Class / Title - Process/Class/Title of the window.", 0, False)
}
Debug_logManagedWindowList()
{
Local wndIds
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)
StringTrimRight, wndIds, Manager_managedWndIds, 1
Loop, PARSE, wndIds, `;
{
Debug_logWindowInfo(A_LoopField)
}
}
Debug_logMessage(text, level = 1, includeTimestamp = True)
{
Global Debug_logFilename, Debug_logLevel
If (Debug_logLevel >= level)
{
If includeTimestamp
{
FormatTime, time, , yyyy-MM-dd HH:mm:ss
text := time " " text
}
Else
text := " " text
FileAppend, %text%`r`n, %Debug_logFilename%
}
}
Debug_logViewWindowList()
{
Local v, wndIds
v := Monitor_#%Manager_aMonitor%_aView_#1
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)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
Debug_logWindowInfo(A_LoopField)
}
}
Debug_logWindowInfo(wndId) {
Local aWndId, detectHidden, text, v
Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus
Local wndClass, wndH, wndPId, wndPName, wndStyle, wndTitle, wndW, wndX, wndY
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On
WinGet, aWndId, ID, A
If aWndId = %wndId%
isWinFocus := "*"
Else
isWinFocus := " "
v := Monitor_#%Manager_aMonitor%_aView_#1
If (View_getActiveWindow(Manager_aMonitor, v) = wndId)
isBugnActive := "*"
Else
isBugnActive := " "
WinGetTitle, wndTitle, ahk_id %wndId%
WinGetClass, wndClass, ahk_id %wndId%
WinGet, wndPName, ProcessName, ahk_id %wndId%
WinGet, wndPId, PID, ahk_id %wndId%
If InStr(Bar_hideTitleWndIds, wndId . ";")
isHidden := "*"
Else
isHidden := " "
If InStr(Manager_managedWndIds, wndId . ";") Or Window_#%wndId%_isFloating
isFloating := "*"
Else
isFloating := " "
If Window_#%wndId%_isDecorated
isDecorated := "*"
Else
isDecorated := " "
WinGet, wndStyle, Style, ahk_id %wndId%
WinGetPos, wndX, wndY, wndW, wndH, ahk_id %wndId%
If Window_isGhost(wndId)
isGhost := "*"
Else
isGhost := " "
DetectHiddenWindows, %detectHidden%
;; Intentionally don't detect hidden windows here to see what Manager_hungTest does
If Window_isHung(wndId)
isResponsive := " "
Else
isResponsive := "*"
text := wndId "`t"
text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " "
text .= Window_#%wndId%_monitor "`t" Window_#%wndId%_tags "`t"
text .= wndX "`t" wndY "`t" wndW "`t" wndH "`t" wndStyle "`t" wndPName " [" wndPId "] / " wndClass " / " wndTitle
Debug_logMessage(text , 0, False)
}
Debug_setLogLevel(i, d) {
Global Debug_logLevel
If (i = 0)
i := Debug_logLevel
i += d
If (i >= 0) And (i != Debug_logLevel) {
Debug_logLevel := i
If (i = 0)
Debug_logMessage("Logging disabled.", 0)
Else
Debug_logMessage("Log level set to " i ".")
}
}
/*
bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0
*/
Debug_initLog(filename, level = 0, truncateFile = True)
{
Global Debug_logFilename, Debug_logLevel
Debug_logFilename := filename
Debug_logLevel := level
If truncateFile
If FileExist(Debug_logFilename)
FileDelete, %Debug_logFilename%
}
Debug_logHelp()
{
Debug_logMessage("Help Display", 0)
Debug_logMessage("Window list columns", 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(" 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(" 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(" 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(" M - Monitor number.", 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(" Y - Windows Y position.", 0, False)
Debug_logMessage(" W - Windows width.", 0, False)
Debug_logMessage(" H - Windows height.", 0, False)
Debug_logMessage(" Style - Windows style.", 0, False)
Debug_logMessage(" Proc / Class / Title - Process/Class/Title of the window.", 0, False)
}
Debug_logManagedWindowList()
{
Local wndIds
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)
StringTrimRight, wndIds, Manager_managedWndIds, 1
Loop, PARSE, wndIds, `;
{
Debug_logWindowInfo(A_LoopField)
}
}
Debug_logMessage(text, level = 1, includeTimestamp = True)
{
Global Debug_logFilename, Debug_logLevel
If (Debug_logLevel >= level)
{
If includeTimestamp
{
FormatTime, time, , yyyy-MM-dd HH:mm:ss
text := time " " text
}
Else
text := " " text
FileAppend, %text%`r`n, %Debug_logFilename%
}
}
Debug_logViewWindowList()
{
Local v, wndIds
v := Monitor_#%Manager_aMonitor%_aView_#1
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)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
Debug_logWindowInfo(A_LoopField)
}
}
Debug_logWindowInfo(wndId) {
Local aWndId, detectHidden, text, v
Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus
Local wndClass, wndH, wndPId, wndPName, wndStyle, wndTitle, wndW, wndX, wndY
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On
WinGet, aWndId, ID, A
If aWndId = %wndId%
isWinFocus := "*"
Else
isWinFocus := " "
v := Monitor_#%Manager_aMonitor%_aView_#1
If (View_getActiveWindow(Manager_aMonitor, v) = wndId)
isBugnActive := "*"
Else
isBugnActive := " "
WinGetTitle, wndTitle, ahk_id %wndId%
WinGetClass, wndClass, ahk_id %wndId%
WinGet, wndPName, ProcessName, ahk_id %wndId%
WinGet, wndPId, PID, ahk_id %wndId%
If InStr(Bar_hideTitleWndIds, wndId . ";")
isHidden := "*"
Else
isHidden := " "
If InStr(Manager_managedWndIds, wndId . ";") Or Window_#%wndId%_isFloating
isFloating := "*"
Else
isFloating := " "
If Window_#%wndId%_isDecorated
isDecorated := "*"
Else
isDecorated := " "
WinGet, wndStyle, Style, ahk_id %wndId%
WinGetPos, wndX, wndY, wndW, wndH, ahk_id %wndId%
If Window_isGhost(wndId)
isGhost := "*"
Else
isGhost := " "
DetectHiddenWindows, %detectHidden%
;; Intentionally don't detect hidden windows here to see what Manager_hungTest does
If Window_isHung(wndId)
isResponsive := " "
Else
isResponsive := "*"
text := wndId "`t"
text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " "
text .= Window_#%wndId%_monitor "`t" Window_#%wndId%_tags "`t"
text .= wndX "`t" wndY "`t" wndW "`t" wndH "`t" wndStyle "`t" wndPName " [" wndPId "] / " wndClass " / " wndTitle
Debug_logMessage(text , 0, False)
}
Debug_setLogLevel(i, d) {
Global Debug_logLevel
If (i = 0)
i := Debug_logLevel
i += d
If (i >= 0) And (i != Debug_logLevel) {
Debug_logLevel := i
If (i = 0)
Debug_logMessage("Logging disabled.", 0)
Else
Debug_logMessage("Log level set to " i ".")
}
}

View file

@ -1,195 +1,195 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0
*/
NAME := "bug.n"
VERSION := "9.1.0"
;; Script settings
OnExit, Main_cleanup
SetBatchLines, -1
SetTitleMatchMode, 3
SetTitleMatchMode, fast
SetWinDelay, 10
#NoEnv
#SingleInstance force
;#Warn ; Enable warnings to assist with detecting common errors.
#WinActivateForce
;; Pseudo main function
Main_appDir := ""
If 0 = 1
Main_appDir = %1%
Main_setup()
Debug_initLog(Main_logFile, 0, False)
Debug_logMessage("====== Initializing ======", 0)
Config_filePath := Main_appDir "\Config.ini"
Config_init()
Menu, Tray, Tip, %NAME% %VERSION%
If A_IsCompiled
Menu, Tray, Icon, %A_ScriptFullPath%, -159
If FileExist(A_ScriptDir . "\logo.ico")
Menu, Tray, Icon, % A_ScriptDir . "\logo.ico"
Menu, Tray, NoStandard
Menu, Tray, Add, Toggle bar, Main_toggleBar
Menu, Tray, Add, Help, Main_help
Menu, Tray, Add,
Menu, Tray, Add, Exit, Main_quit
ResourceMonitor_init()
Manager_init()
Debug_logMessage("====== Running ======", 0)
Return ;; end of the auto-execute section
;; Function & label definitions
Main_cleanup:
Debug_logMessage("====== Cleaning up ======", 0)
;; Config_autoSaveSession as False is deprecated.
If Not (Config_autoSaveSession = "off") And Not (Config_autoSaveSession = "False")
Manager_saveState()
Manager_cleanup()
ResourceMonitor_cleanup()
Debug_logMessage("====== Exiting bug.n ======", 0)
ExitApp
Main_evalCommand(command)
{
type := SubStr(command, 1, 5)
If (type = "Run, ")
{
parameters := SubStr(command, 6)
If InStr(parameters, ", ")
{
StringSplit, parameter, parameters, `,
If (parameter0 = 2)
{
StringTrimLeft, parameter2, parameter2, 1
Run, %parameter1%, %parameter2%
}
Else If (parameter0 > 2)
{
StringTrimLeft, parameter2, parameter2, 1
StringTrimLeft, parameter3, parameter3, 1
Run, %parameter1%, %parameter2%, %parameter3%
}
}
Else
Run, %parameters%
}
Else If (type = "Send ")
Send % SubStr(command, 6)
Else If (command = "Reload")
Reload
Else If (command = "ExitApp")
ExitApp
Else
{
i := InStr(command, "(")
j := InStr(command, ")", False, i)
If i And j
{
functionName := SubStr(command, 1, i - 1)
functionArguments := SubStr(command, i + 1, j - (i + 1))
StringReplace, functionArguments, functionArguments, %A_SPACE%, , All
StringSplit, functionArgument, functionArguments, `,
Debug_logMessage("DEBUG[1] Main_evalCommand: " functionName "(" functionArguments ")", 1)
If (functionArgument0 = 0)
%functionName%()
Else If (functionArgument0 = 1)
%functionName%(functionArguments)
Else If (functionArgument0 = 2)
%functionName%(functionArgument1, functionArgument2)
Else If (functionArgument0 = 3)
%functionName%(functionArgument1, functionArgument2, functionArgument3)
Else If (functionArgument0 = 4)
%functionName%(functionArgument1, functionArgument2, functionArgument3, functionArgument4)
}
}
}
Main_help:
Run, explore %Main_docDir%
Return
;; Create bug.n-specific directories.
Main_makeDir(dirName) {
IfNotExist, %dirName%
{
FileCreateDir, %dirName%
If ErrorLevel
{
MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting.
ExitApp
}
}
Else
{
FileGetAttrib, attrib, %dirName%
IfNotInString, attrib, D
{
MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting.
ExitApp
}
}
}
Main_quit:
ExitApp
Return
Main_setup() {
Local winAppDir
Main_docDir := A_ScriptDir
If (SubStr(A_ScriptDir, -3) = "\src")
Main_docDir .= "\.."
Main_docDir .= "\doc"
Main_logFile := ""
Main_dataDir := ""
Main_autoLayout := ""
Main_autoWindowState := ""
EnvGet, winAppDir, APPDATA
If (Main_appDir = "")
Main_appDir := winAppDir . "\bug.n"
Main_logFile := Main_appDir . "\log.txt"
Main_dataDir := Main_appDir . "\data"
Main_autoLayout := Main_dataDir . "\_Layout.ini"
Main_autoWindowState := Main_dataDir . "\_WindowState.ini"
Main_makeDir(Main_appDir)
Main_makeDir(Main_dataDir)
}
Main_toggleBar:
Monitor_toggleBar()
Return
#Include Bar.ahk
#Include Config.ahk
#Include Debug.ahk
#Include Manager.ahk
#Include Monitor.ahk
#Include ResourceMonitor.ahk
#Include Tiler.ahk
#Include View.ahk
#Include Window.ahk
#Include MonitorManager.ahk
#Include MusicBee.ahk
/*
bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0
*/
NAME := "bug.n"
VERSION := "9.1.0"
;; Script settings
OnExit, Main_cleanup
SetBatchLines, -1
SetTitleMatchMode, 3
SetTitleMatchMode, fast
SetWinDelay, 10
#NoEnv
#SingleInstance force
;#Warn ; Enable warnings to assist with detecting common errors.
#WinActivateForce
;; Pseudo main function
Main_appDir := ""
If 0 = 1
Main_appDir = %1%
Main_setup()
Debug_initLog(Main_logFile, 0, False)
Debug_logMessage("====== Initializing ======", 0)
Config_filePath := Main_appDir "\Config.ini"
Config_init()
Menu, Tray, Tip, %NAME% %VERSION%
If A_IsCompiled
Menu, Tray, Icon, %A_ScriptFullPath%, -159
If FileExist(A_ScriptDir . "\logo.ico")
Menu, Tray, Icon, % A_ScriptDir . "\logo.ico"
Menu, Tray, NoStandard
Menu, Tray, Add, Toggle bar, Main_toggleBar
Menu, Tray, Add, Help, Main_help
Menu, Tray, Add,
Menu, Tray, Add, Exit, Main_quit
ResourceMonitor_init()
Manager_init()
Debug_logMessage("====== Running ======", 0)
Return ;; end of the auto-execute section
;; Function & label definitions
Main_cleanup:
Debug_logMessage("====== Cleaning up ======", 0)
;; Config_autoSaveSession as False is deprecated.
If Not (Config_autoSaveSession = "off") And Not (Config_autoSaveSession = "False")
Manager_saveState()
Manager_cleanup()
ResourceMonitor_cleanup()
Debug_logMessage("====== Exiting bug.n ======", 0)
ExitApp
Main_evalCommand(command)
{
type := SubStr(command, 1, 5)
If (type = "Run, ")
{
parameters := SubStr(command, 6)
If InStr(parameters, ", ")
{
StringSplit, parameter, parameters, `,
If (parameter0 = 2)
{
StringTrimLeft, parameter2, parameter2, 1
Run, %parameter1%, %parameter2%
}
Else If (parameter0 > 2)
{
StringTrimLeft, parameter2, parameter2, 1
StringTrimLeft, parameter3, parameter3, 1
Run, %parameter1%, %parameter2%, %parameter3%
}
}
Else
Run, %parameters%
}
Else If (type = "Send ")
Send % SubStr(command, 6)
Else If (command = "Reload")
Reload
Else If (command = "ExitApp")
ExitApp
Else
{
i := InStr(command, "(")
j := InStr(command, ")", False, i)
If i And j
{
functionName := SubStr(command, 1, i - 1)
functionArguments := SubStr(command, i + 1, j - (i + 1))
StringReplace, functionArguments, functionArguments, %A_SPACE%, , All
StringSplit, functionArgument, functionArguments, `,
Debug_logMessage("DEBUG[1] Main_evalCommand: " functionName "(" functionArguments ")", 1)
If (functionArgument0 = 0)
%functionName%()
Else If (functionArgument0 = 1)
%functionName%(functionArguments)
Else If (functionArgument0 = 2)
%functionName%(functionArgument1, functionArgument2)
Else If (functionArgument0 = 3)
%functionName%(functionArgument1, functionArgument2, functionArgument3)
Else If (functionArgument0 = 4)
%functionName%(functionArgument1, functionArgument2, functionArgument3, functionArgument4)
}
}
}
Main_help:
Run, explore %Main_docDir%
Return
;; Create bug.n-specific directories.
Main_makeDir(dirName) {
IfNotExist, %dirName%
{
FileCreateDir, %dirName%
If ErrorLevel
{
MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting.
ExitApp
}
}
Else
{
FileGetAttrib, attrib, %dirName%
IfNotInString, attrib, D
{
MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting.
ExitApp
}
}
}
Main_quit:
ExitApp
Return
Main_setup() {
Local winAppDir
Main_docDir := A_ScriptDir
If (SubStr(A_ScriptDir, -3) = "\src")
Main_docDir .= "\.."
Main_docDir .= "\doc"
Main_logFile := ""
Main_dataDir := ""
Main_autoLayout := ""
Main_autoWindowState := ""
EnvGet, winAppDir, APPDATA
If (Main_appDir = "")
Main_appDir := winAppDir . "\bug.n"
Main_logFile := Main_appDir . "\log.txt"
Main_dataDir := Main_appDir . "\data"
Main_autoLayout := Main_dataDir . "\_Layout.ini"
Main_autoWindowState := Main_dataDir . "\_WindowState.ini"
Main_makeDir(Main_appDir)
Main_makeDir(Main_dataDir)
}
Main_toggleBar:
Monitor_toggleBar()
Return
#Include Bar.ahk
#Include Config.ahk
#Include Debug.ahk
#Include Manager.ahk
#Include Monitor.ahk
#Include ResourceMonitor.ahk
#Include Tiler.ahk
#Include View.ahk
#Include Window.ahk
#Include MonitorManager.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
Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0
*/
Monitor_init(m, doRestore) {
Global
Monitor_#%m%_aView_#1 := 1
Monitor_#%m%_aView_#2 := 1
Monitor_#%m%_showBar := Config_showBar
Monitor_#%m%_showTaskBar := Config_showTaskBar
Monitor_#%m%_taskBarClass := ""
Monitor_#%m%_taskBarPos := ""
Loop, % Config_viewCount
View_init(m, A_Index)
If doRestore
Config_restoreLayout(Main_autoLayout, m)
Else
Config_restoreLayout(Config_filePath, m)
SysGet, Monitor_#%m%_name, MonitorName, %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)
If Not Monitor_#%m%_showTaskBar {
Monitor_#%m%_showTaskBar := True
Monitor_toggleTaskBar(m)
}
Bar_init(m)
}
Monitor_activateView(i, d = 0) {
Local aMonitor, aView, aWndId, detectHidden, m, n, wndId, wndIds
aMonitor := Manager_aMonitor
If (i = -1)
i := Monitor_#%aMonitor%_aView_#2
Else If (i = 0)
i := Monitor_#%aMonitor%_aView_#1
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)
If (i <= 0) Or (i > Config_viewCount) Or Manager_hideShow
Return
;; Re-arrange the windows on the active view.
If (i = Monitor_#%aMonitor%_aView_#1) {
View_arrange(aMonitor, i)
Return
}
aView := Monitor_#%aMonitor%_aView_#1
WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) And InStr(View_#%aMonitor%_#%aView%_wndIds, aWndId ";") And Window_isProg(aWndId)
View_setActiveWindow(aMonitor, aView, aWndId)
n := Config_syncMonitorViews
If (n = 1)
n := Manager_monitorCount
Else If (n < 1)
n := 1
Loop, % n {
If (n = 1)
m := aMonitor
Else
m := A_Index
Monitor_#%m%_aView_#2 := aView
Monitor_#%m%_aView_#1 := i
Manager_hideShow := True
SetWinDelay, 0
StringTrimRight, wndIds, View_#%m%_#%aView%_wndIds, 1
Loop, PARSE, wndIds, `;
{
If A_LoopField And Not (Window_#%A_LoopField%_tags & (1 << i - 1))
Window_hide(A_LoopField)
}
SetWinDelay, 10
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On
wndId := View_getActiveWindow(m, i)
If wndId
Window_set(wndId, "AlwaysOnTop", "On")
View_arrange(m, i)
DetectHiddenWindows, %detectHidden%
StringTrimRight, wndIds, View_#%m%_#%i%_wndIds, 1
SetWinDelay, 0
Loop, PARSE, wndIds, `;
{
Window_show(A_LoopField)
}
Window_set(wndId, "AlwaysOnTop", "Off")
SetWinDelay, 10
Manager_hideShow := False
Bar_updateView(m, aView)
Bar_updateView(m, i)
}
wndId := View_getActiveWindow(aMonitor, i)
Manager_winActivate(wndId)
}
Monitor_find(d, n) {
Local mName
If (d < 0 Or d > 0) {
Loop, % n {
SysGet, mName, MonitorName, %A_Index%
If Not (mName = Monitor_#%A_Index%_name)
Return, A_Index
}
}
Return, 0
}
Monitor_get(x, y)
{
Local m
m := 0
Loop, % Manager_monitorCount
{ ;; 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)
{
m := A_Index
Break
}
}
Return, m
}
Monitor_getWorkArea(m) {
Local bHeight, bTop, x, y
Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop
Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY
SysGet, monitor, Monitor, %m%
Debug_logMessage("DEBUG[0] Monitor_getWorkArea: #" . m . ", l: " . monitorLeft . ", r: " . monitorRight . ", t: " . monitorTop . ", b: " . monitorBottom . ".", 0)
wndClasses := "Shell_TrayWnd;Shell_SecondaryTrayWnd"
;; @TODO What about third and so forth TrayWnd?
If Config_bbCompatibility
wndClasses .= ";bbLeanBar;bbSlit;BBToolbar;SystemBarEx"
Loop, PARSE, wndClasses, `;
{
wndId := WinExist("ahk_class " A_LoopField)
If wndId {
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
x := wndX + wndWidth / 2
y := wndY + wndHeight / 2
If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom) {
If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd")
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)
If (wndHeight < wndWidth) {
;; Horizontal
If (wndY <= monitorTop) {
;; Top
wndHeight += wndY - monitorTop
monitorTop += wndHeight
If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd")
Monitor_#%m%_taskBarPos := "top"
} Else {
;; Bottom
wndHeight := monitorBottom - wndY
monitorBottom -= wndHeight
}
} Else {
;; Vertical
If (wndX <= monitorLeft) {
;; Left
wndWidth += wndX
monitorLeft += wndWidth
} Else {
;; Right
wndWidth := monitorRight - wndX
monitorRight -= wndWidth
}
}
}
}
}
bHeight := Round(Bar_height / Config_scalingFactor)
bTop := 0
If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray") And Not Monitor_#%m%_taskBarClass {
bTop := monitorTop
If Monitor_#%m%_showBar
monitorTop += bHeight
} Else If (Config_verticalBarPos = "bottom") {
bTop := monitorBottom - bHeight
If Monitor_#%m%_showBar
monitorBottom -= bHeight
}
Monitor_#%m%_height := monitorBottom - monitorTop
Monitor_#%m%_width := monitorRight - monitorLeft
Monitor_#%m%_x := monitorLeft
Monitor_#%m%_y := monitorTop
Monitor_#%m%_barY := bTop
Monitor_setWorkArea(monitorLeft, monitorTop, monitorRight, monitorBottom)
}
Monitor_moveToIndex(m, n) {
Global
Monitor_#%n%_aView_#1 := Monitor_#%m%_aView_#1
Monitor_#%n%_aView_#2 := Monitor_#%m%_aView_#2
Monitor_#%n%_name := Monitor_#%m%_name
Monitor_#%n%_showBar := Monitor_#%m%_showBar
Monitor_#%n%_showTaskBar := Monitor_#%m%_showTaskBar
Monitor_#%n%_taskBarClass := Monitor_#%m%_taskBarClass
Monitor_#%n%_taskBarPos := Monitor_#%m%_taskBarPos
Monitor_#%n%_height := Monitor_#%m%_height
Monitor_#%n%_width := Monitor_#%m%_width
Monitor_#%n%_x := Monitor_#%m%_x
Monitor_#%n%_y := Monitor_#%m%_y
Monitor_#%n%_barY := Monitor_#%m%_barY
Loop, % Config_viewCount
View_moveToIndex(m, A_Index, n, A_Index)
}
Monitor_setWindowTag(i, d = 0) {
Local aView, aWndId, wndId
If (i = 0)
i := Monitor_#%Manager_aMonitor%_aView_#1
If Not (i = 10)
i := Manager_loop(i, d, 1, Config_viewCount)
WinGet, aWndId, ID, A
If InStr(Manager_managedWndIds, aWndId ";") And (i > 0) And (i <= Config_viewCount Or i = 10) {
If (i = 10) {
Loop, % Config_viewCount {
If Not (Window_#%aWndId%_tags & (1 << A_Index - 1)) {
View_#%Manager_aMonitor%_#%A_Index%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%A_Index%_wndIds
View_setActiveWindow(Manager_aMonitor, A_Index, aWndId)
Bar_updateView(Manager_aMonitor, A_Index)
Window_#%aWndId%_tags += 1 << A_Index - 1
}
}
} Else {
Loop, % Config_viewCount {
If Not (A_index = i) {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;,
View_setActiveWindow(Manager_aMonitor, A_Index, 0)
Bar_updateView(Manager_aMonitor, A_Index)
}
}
If Not (Window_#%aWndId%_tags & (1 << i - 1))
View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds
View_setActiveWindow(Manager_aMonitor, i, aWndId)
Window_#%aWndId%_tags := 1 << i - 1
aView := Monitor_#%Manager_aMonitor%_aView_#1
If Not (i = aView) {
Manager_hideShow := True
wndId := SubStr(View_#%Manager_aMonitor%_#%aView%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, ";") - 1)
Manager_winActivate(wndId)
Manager_hideShow := False
If Config_viewFollowsTagged
Monitor_activateView(i)
Else {
Manager_hideShow := True
Window_hide(aWndId)
Manager_hideShow := False
If Config_dynamicTiling
View_arrange(Manager_aMonitor, aView)
Bar_updateView(Manager_aMonitor, i)
}
}
}
}
}
Monitor_setWorkArea(left, top, right, bottom) {
VarSetCapacity(area, 16)
NumPut(left, area, 0)
NumPut(top, area, 4)
NumPut(right, area, 8)
NumPut(bottom, area, 12)
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/)
Monitor_toggleBar()
{
Global
Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar
Bar_toggleVisibility(Manager_aMonitor)
Monitor_getWorkArea(Manager_aMonitor)
View_arrange(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
Manager_winActivate(Bar_aWndId)
}
Monitor_toggleNotifyIconOverflowWindow() {
Static wndId
If Not WinExist("ahk_class NotifyIconOverflowWindow") {
WinGet, wndId, ID, A
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On
WinShow, ahk_class NotifyIconOverflowWindow
WinActivate, ahk_class NotifyIconOverflowWindow
DetectHiddenWindows, %detectHidden%
} Else {
WinHide, ahk_class NotifyIconOverflowWindow
WinActivate, ahk_id %wndId%
}
}
Monitor_toggleTaskBar(m := 0) {
Global
m := m ? m : Manager_aMonitor
If Monitor_#%m%_taskBarClass {
Monitor_#%m%_showTaskBar := Not Monitor_#%m%_showTaskBar
Manager_hideShow := True
If Not Monitor_#%m%_showTaskBar {
WinHide, Start ahk_class Button
WinHide, % "ahk_class " Monitor_#%m%_taskBarClass
} Else {
WinShow, Start ahk_class Button
WinShow, % "ahk_class " Monitor_#%m%_taskBarClass
}
Manager_hideShow := False
Monitor_getWorkArea(m)
Bar_move(m)
View_arrange(m, Monitor_#%m%_aView_#1)
}
}
Monitor_toggleWindowTag(i, d = 0) {
Local aWndId, wndId
WinGet, aWndId, ID, A
If (InStr(Manager_managedWndIds, aWndId ";") And i >= 0 And i <= Config_viewCount) {
If (Window_#%aWndId%_tags & (1 << i - 1)) {
If Not ((Window_#%aWndId%_tags - (1 << i - 1)) = 0) {
Window_#%aWndId%_tags -= 1 << i - 1
StringReplace, View_#%Manager_aMonitor%_#%i%_wndIds, View_#%Manager_aMonitor%_#%i%_wndIds, %aWndId%`;,
Bar_updateView(Manager_aMonitor, i)
If (i = Monitor_#%Manager_aMonitor%_aView_#1) {
Manager_hideShow := True
Window_hide(aWndId)
Manager_hideShow := False
wndId := SubStr(View_#%Manager_aMonitor%_#%i%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%i%_wndIds, ";")-1)
Manager_winActivate(wndId)
If Config_dynamicTiling
View_arrange(Manager_aMonitor, i)
}
}
} Else {
View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds
View_setActiveWindow(Manager_aMonitor, i, aWndId)
Bar_updateView(Manager_aMonitor, i)
Window_#%aWndId%_tags += 1 << i - 1
}
}
}
/*
bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0
*/
Monitor_init(m, doRestore) {
Global
Monitor_#%m%_aView_#1 := 1
Monitor_#%m%_aView_#2 := 1
Monitor_#%m%_showBar := Config_showBar
Monitor_#%m%_showTaskBar := Config_showTaskBar
Monitor_#%m%_taskBarClass := ""
Monitor_#%m%_taskBarPos := ""
Loop, % Config_viewCount
View_init(m, A_Index)
If doRestore
Config_restoreLayout(Main_autoLayout, m)
Else
Config_restoreLayout(Config_filePath, m)
SysGet, Monitor_#%m%_name, MonitorName, %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)
If Not Monitor_#%m%_showTaskBar {
Monitor_#%m%_showTaskBar := True
Monitor_toggleTaskBar(m)
}
Bar_init(m)
}
Monitor_activateView(i, d = 0) {
Local aMonitor, aView, aWndId, detectHidden, m, n, wndId, wndIds
aMonitor := Manager_aMonitor
If (i = -1)
i := Monitor_#%aMonitor%_aView_#2
Else If (i = 0)
i := Monitor_#%aMonitor%_aView_#1
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)
If (i <= 0) Or (i > Config_viewCount) Or Manager_hideShow
Return
;; Re-arrange the windows on the active view.
If (i = Monitor_#%aMonitor%_aView_#1) {
View_arrange(aMonitor, i)
Return
}
aView := Monitor_#%aMonitor%_aView_#1
WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) And InStr(View_#%aMonitor%_#%aView%_wndIds, aWndId ";") And Window_isProg(aWndId)
View_setActiveWindow(aMonitor, aView, aWndId)
n := Config_syncMonitorViews
If (n = 1)
n := Manager_monitorCount
Else If (n < 1)
n := 1
Loop, % n {
If (n = 1)
m := aMonitor
Else
m := A_Index
Monitor_#%m%_aView_#2 := aView
Monitor_#%m%_aView_#1 := i
Manager_hideShow := True
SetWinDelay, 0
StringTrimRight, wndIds, View_#%m%_#%aView%_wndIds, 1
Loop, PARSE, wndIds, `;
{
If A_LoopField And Not (Window_#%A_LoopField%_tags & (1 << i - 1))
Window_hide(A_LoopField)
}
SetWinDelay, 10
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On
wndId := View_getActiveWindow(m, i)
If wndId
Window_set(wndId, "AlwaysOnTop", "On")
View_arrange(m, i)
DetectHiddenWindows, %detectHidden%
StringTrimRight, wndIds, View_#%m%_#%i%_wndIds, 1
SetWinDelay, 0
Loop, PARSE, wndIds, `;
{
Window_show(A_LoopField)
}
Window_set(wndId, "AlwaysOnTop", "Off")
SetWinDelay, 10
Manager_hideShow := False
Bar_updateView(m, aView)
Bar_updateView(m, i)
}
wndId := View_getActiveWindow(aMonitor, i)
Manager_winActivate(wndId)
}
Monitor_find(d, n) {
Local mName
If (d < 0 Or d > 0) {
Loop, % n {
SysGet, mName, MonitorName, %A_Index%
If Not (mName = Monitor_#%A_Index%_name)
Return, A_Index
}
}
Return, 0
}
Monitor_get(x, y)
{
Local m
m := 0
Loop, % Manager_monitorCount
{ ;; 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)
{
m := A_Index
Break
}
}
Return, m
}
Monitor_getWorkArea(m) {
Local bHeight, bTop, x, y
Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop
Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY
SysGet, monitor, Monitor, %m%
Debug_logMessage("DEBUG[0] Monitor_getWorkArea: #" . m . ", l: " . monitorLeft . ", r: " . monitorRight . ", t: " . monitorTop . ", b: " . monitorBottom . ".", 0)
wndClasses := "Shell_TrayWnd;Shell_SecondaryTrayWnd"
;; @TODO What about third and so forth TrayWnd?
If Config_bbCompatibility
wndClasses .= ";bbLeanBar;bbSlit;BBToolbar;SystemBarEx"
Loop, PARSE, wndClasses, `;
{
wndId := WinExist("ahk_class " A_LoopField)
If wndId {
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
x := wndX + wndWidth / 2
y := wndY + wndHeight / 2
If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom) {
If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd")
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)
If (wndHeight < wndWidth) {
;; Horizontal
If (wndY <= monitorTop) {
;; Top
wndHeight += wndY - monitorTop
monitorTop += wndHeight
If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd")
Monitor_#%m%_taskBarPos := "top"
} Else {
;; Bottom
wndHeight := monitorBottom - wndY
monitorBottom -= wndHeight
}
} Else {
;; Vertical
If (wndX <= monitorLeft) {
;; Left
wndWidth += wndX
monitorLeft += wndWidth
} Else {
;; Right
wndWidth := monitorRight - wndX
monitorRight -= wndWidth
}
}
}
}
}
bHeight := Round(Bar_height / Config_scalingFactor)
bTop := 0
If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray") And Not Monitor_#%m%_taskBarClass {
bTop := monitorTop
If Monitor_#%m%_showBar
monitorTop += bHeight
} Else If (Config_verticalBarPos = "bottom") {
bTop := monitorBottom - bHeight
If Monitor_#%m%_showBar
monitorBottom -= bHeight
}
Monitor_#%m%_height := monitorBottom - monitorTop
Monitor_#%m%_width := monitorRight - monitorLeft
Monitor_#%m%_x := monitorLeft
Monitor_#%m%_y := monitorTop
Monitor_#%m%_barY := bTop
Monitor_setWorkArea(monitorLeft, monitorTop, monitorRight, monitorBottom)
}
Monitor_moveToIndex(m, n) {
Global
Monitor_#%n%_aView_#1 := Monitor_#%m%_aView_#1
Monitor_#%n%_aView_#2 := Monitor_#%m%_aView_#2
Monitor_#%n%_name := Monitor_#%m%_name
Monitor_#%n%_showBar := Monitor_#%m%_showBar
Monitor_#%n%_showTaskBar := Monitor_#%m%_showTaskBar
Monitor_#%n%_taskBarClass := Monitor_#%m%_taskBarClass
Monitor_#%n%_taskBarPos := Monitor_#%m%_taskBarPos
Monitor_#%n%_height := Monitor_#%m%_height
Monitor_#%n%_width := Monitor_#%m%_width
Monitor_#%n%_x := Monitor_#%m%_x
Monitor_#%n%_y := Monitor_#%m%_y
Monitor_#%n%_barY := Monitor_#%m%_barY
Loop, % Config_viewCount
View_moveToIndex(m, A_Index, n, A_Index)
}
Monitor_setWindowTag(i, d = 0) {
Local aView, aWndId, wndId
If (i = 0)
i := Monitor_#%Manager_aMonitor%_aView_#1
If Not (i = 10)
i := Manager_loop(i, d, 1, Config_viewCount)
WinGet, aWndId, ID, A
If InStr(Manager_managedWndIds, aWndId ";") And (i > 0) And (i <= Config_viewCount Or i = 10) {
If (i = 10) {
Loop, % Config_viewCount {
If Not (Window_#%aWndId%_tags & (1 << A_Index - 1)) {
View_#%Manager_aMonitor%_#%A_Index%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%A_Index%_wndIds
View_setActiveWindow(Manager_aMonitor, A_Index, aWndId)
Bar_updateView(Manager_aMonitor, A_Index)
Window_#%aWndId%_tags += 1 << A_Index - 1
}
}
} Else {
Loop, % Config_viewCount {
If Not (A_index = i) {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;,
View_setActiveWindow(Manager_aMonitor, A_Index, 0)
Bar_updateView(Manager_aMonitor, A_Index)
}
}
If Not (Window_#%aWndId%_tags & (1 << i - 1))
View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds
View_setActiveWindow(Manager_aMonitor, i, aWndId)
Window_#%aWndId%_tags := 1 << i - 1
aView := Monitor_#%Manager_aMonitor%_aView_#1
If Not (i = aView) {
Manager_hideShow := True
wndId := SubStr(View_#%Manager_aMonitor%_#%aView%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, ";") - 1)
Manager_winActivate(wndId)
Manager_hideShow := False
If Config_viewFollowsTagged
Monitor_activateView(i)
Else {
Manager_hideShow := True
Window_hide(aWndId)
Manager_hideShow := False
If Config_dynamicTiling
View_arrange(Manager_aMonitor, aView)
Bar_updateView(Manager_aMonitor, i)
}
}
}
}
}
Monitor_setWorkArea(left, top, right, bottom) {
VarSetCapacity(area, 16)
NumPut(left, area, 0)
NumPut(top, area, 4)
NumPut(right, area, 8)
NumPut(bottom, area, 12)
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/)
Monitor_toggleBar()
{
Global
Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar
Bar_toggleVisibility(Manager_aMonitor)
Monitor_getWorkArea(Manager_aMonitor)
View_arrange(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
Manager_winActivate(Bar_aWndId)
}
Monitor_toggleNotifyIconOverflowWindow() {
Static wndId
If Not WinExist("ahk_class NotifyIconOverflowWindow") {
WinGet, wndId, ID, A
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On
WinShow, ahk_class NotifyIconOverflowWindow
WinActivate, ahk_class NotifyIconOverflowWindow
DetectHiddenWindows, %detectHidden%
} Else {
WinHide, ahk_class NotifyIconOverflowWindow
WinActivate, ahk_id %wndId%
}
}
Monitor_toggleTaskBar(m := 0) {
Global
m := m ? m : Manager_aMonitor
If Monitor_#%m%_taskBarClass {
Monitor_#%m%_showTaskBar := Not Monitor_#%m%_showTaskBar
Manager_hideShow := True
If Not Monitor_#%m%_showTaskBar {
WinHide, Start ahk_class Button
WinHide, % "ahk_class " Monitor_#%m%_taskBarClass
} Else {
WinShow, Start ahk_class Button
WinShow, % "ahk_class " Monitor_#%m%_taskBarClass
}
Manager_hideShow := False
Monitor_getWorkArea(m)
Bar_move(m)
View_arrange(m, Monitor_#%m%_aView_#1)
}
}
Monitor_toggleWindowTag(i, d = 0) {
Local aWndId, wndId
WinGet, aWndId, ID, A
If (InStr(Manager_managedWndIds, aWndId ";") And i >= 0 And i <= Config_viewCount) {
If (Window_#%aWndId%_tags & (1 << i - 1)) {
If Not ((Window_#%aWndId%_tags - (1 << i - 1)) = 0) {
Window_#%aWndId%_tags -= 1 << i - 1
StringReplace, View_#%Manager_aMonitor%_#%i%_wndIds, View_#%Manager_aMonitor%_#%i%_wndIds, %aWndId%`;,
Bar_updateView(Manager_aMonitor, i)
If (i = Monitor_#%Manager_aMonitor%_aView_#1) {
Manager_hideShow := True
Window_hide(aWndId)
Manager_hideShow := False
wndId := SubStr(View_#%Manager_aMonitor%_#%i%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%i%_wndIds, ";")-1)
Manager_winActivate(wndId)
If Config_dynamicTiling
View_arrange(Manager_aMonitor, i)
}
}
} Else {
View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds
View_setActiveWindow(Manager_aMonitor, i, aWndId)
Bar_updateView(Manager_aMonitor, i)
Window_#%aWndId%_tags += 1 << i - 1
}
}
}

View file

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

View file

@ -114,7 +114,7 @@ Tiler_isActive(m, v) {
Tiler_layoutTiles(m, v, x, y, w, h, type = "") {
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)
axis2 := View_#%m%_#%v%_layoutAxis_#2
@ -140,53 +140,89 @@ Tiler_layoutTiles(m, v, x, y, w, h, type = "") {
mSplit := View_tiledWndId0
}
;; Areas (master and stack)
x1 := x
y1 := y
w1 := w
h1 := h
If hasStackArea {
leftArray := []
leftArrayCount := 0
rightArray := []
rightArrayCount := 0
if hasStackArea {
;; split in half
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)
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
If (axis2 = 3)
Tiler_stackTiles(m, v, 1, mSplit, +1, 3, x1, y1, w1, h1, 0, type)
Else {
mYActual := (type = "blank") ? mYSet : Ceil(mSplit / mXSet)
subAreaCount := mYActual
mWndCount := mSplit
Loop, % mYActual {
Tiler_splitArea(Not (axis2 - 1), 1 / subAreaCount, x1, y1, w1, h1, gapW, subX1, subY1, subW1, subH1, x1, y1, w1, h1)
subAreaWndCount := mXSet
If (mWndCount < subAreaWndCount)
subAreaWndCount := mWndCount
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)
mWndCount -= subAreaWndCount
subAreaCount -= 1
}
}
;; Stack
If hasStackArea {
If (type = "blank") {
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)
} Else {
stackLen := View_tiledWndId0 - mSplit
;; 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;
;; 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))
Tiler_stackTiles(m, v, mSplit + 1, stackLen, +1, 3, x2, y2, w2, h2, 0, type)
Else
Tiler_stackTiles(m, v, mSplit + 1, stackLen, +1, axis3, x2, y2, w2, h2, gapW, type)
}
}
;If (axis2 = 3)
; Tiler_stackTiles(m, v, 1, mSplit, +1, 3, x1, y1, w1, h1, 0, type)
;Else {
; mYActual := (type = "blank") ? mYSet : Ceil(mSplit / mXSet)
; subAreaCount := mYActual
; mWndCount := mSplit
; Loop, % mYActual {
; Tiler_splitArea(Not (axis2 - 1), 1 / subAreaCount, x1, y1, w1, h1, gapW, subX1, subY1, subW1, subH1, x1, y1, w1, h1)
; subAreaWndCount := mXSet
; If (mWndCount < subAreaWndCount)
; subAreaWndCount := mWndCount
; 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)
; mWndCount -= subAreaWndCount
; subAreaCount -= 1
; }
;}
;
;;; Stack
;If hasStackArea {
; If (type = "blank") {
; 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)
; } Else {
; stackLen := View_tiledWndId0 - mSplit
; ;; 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;
; ;; 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))
; Tiler_stackTiles(m, v, mSplit + 1, stackLen, +1, 3, x2, y2, w2, h2, 0, type)
; Else
; Tiler_stackTiles(m, v, mSplit + 1, stackLen, +1, axis3, x2, y2, w2, h2, gapW, type)
; }
;}
}
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) {
Global

View file

@ -1,435 +1,433 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0
*/
View_init(m, v)
{
Global
View_#%m%_#%v%_area_#0 := 0
View_#%m%_#%v%_aWndIds := "0;"
View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layout_#2 := 1
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2
View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3
View_#%m%_#%v%_layoutGapWidth := Config_layoutGapWidth
View_#%m%_#%v%_layoutMFact := Config_layoutMFactor
View_#%m%_#%v%_layoutMX := 1
View_#%m%_#%v%_layoutMY := 1
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1
View_#%m%_#%v%_margins := "0;0;0;0"
View_#%m%_#%v%_showStackArea := True
StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `;
View_#%m%_#%v%_wndIds := ""
}
View_activateWindow(i, d = 0) {
Local aWndId, direction, failure, j, v, wndId, wndId0, wndIds
Debug_logMessage("DEBUG[1] View_activateWindow(" . i . ", " . d . ")", 1)
If (i = 0) And (d = 0)
Return
WinGet, aWndId, ID, A
Debug_logMessage("DEBUG[2] Active Windows ID: " . aWndId, 2, False)
v := Monitor_#%Manager_aMonitor%_aView_#1
Debug_logMessage("DEBUG[2] View (" . v . ") wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 2, False)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
StringSplit, wndId, wndIds, `;
Debug_logMessage("DEBUG[2] wndId count: " . wndId0, 2, False)
If (i > 0) And (i <= wndId0) And (d = 0) {
wndId := wndId%i%
Window_set(wndId, "AlwaysOnTop", "On")
Window_set(wndId, "AlwaysOnTop", "Off")
Window_#%wndId%_isMinimized := False
Manager_winActivate(wndId)
} Else If (wndId0 > 1) {
If Not InStr(Manager_managedWndIds, aWndId . ";") Or Window_#%aWndId%_isFloating
Window_set(aWndId, "Bottom", "")
Loop, % wndId0 {
If (wndId%A_Index% = aWndId) {
j := A_Index
Break
}
}
Debug_logMessage("DEBUG[2] Current wndId index: " . j, 2, False)
If (d > 0)
direction = 1
Else
direction = -1
i := Manager_loop(j, d, 1, wndId0)
Loop, % wndId0 {
Debug_logMessage("DEBUG[2] Next wndId index: " . i, 2, False)
wndId := wndId%i%
If Not Window_#%wndId%_isMinimized {
Window_set(wndId, "AlwaysOnTop", "On")
Window_set(wndId, "AlwaysOnTop", "Off")
;; If there are hung windows on the screen, we still want to be able to cycle through them.
failure := Manager_winActivate(wndId)
If Not failure
Break
}
i := Manager_loop(i, direction, 1, wndId0)
}
}
}
View_addWindow(m, v, wndId) {
Local i, mSplit, n, replace, search
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, % wndId ";",, All
If Tiler_isActive(m, v) And ((Config_newWndPosition = "masterBottom") Or (Config_newWndPosition = "stackTop")) {
n := View_getTiledWndIds(m, v)
mSplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY
If (mSplit = 1 And Config_newWndPosition = "masterBottom")
View_#%m%_#%v%_wndIds := wndId ";" . View_#%m%_#%v%_wndIds
Else If ((Config_newWndPosition = "masterBottom" And n < mSplit) Or (Config_newWndPosition = "stackTop" And n <= mSplit))
View_#%m%_#%v%_wndIds .= wndId ";"
Else {
If (Config_newWndPosition = "masterBottom")
i := mSplit - 1
Else
i := mSplit
search := View_tiledWndId%i% ";"
replace := search wndId ";"
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
}
}
Else If (Config_newWndPosition = "bottom")
View_#%m%_#%v%_wndIds .= wndId ";"
Else
View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds
}
View_arrange(m, v, setLayout = False) {
Local fn, h, l, w, x, y
Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1)
l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l%
If fn {
x := Monitor_#%m%_x + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin4
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
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.
SetWinDelay, 0
If Config_dynamicTiling Or setLayout {
View_getTiledWndIds(m, v)
If (fn = "monocle") {
;; 'View_getLayoutSymbol_monocle'
View_#%m%_#%v%_layoutSymbol := "[" View_tiledWndId0 "]"
;; 'View_arrange_monocle'
Tiler_stackTiles(0, 0, 1, View_tiledWndId0, +1, 3, x, y, w, h, 0)
} Else ;; (fn = "tile")
Tiler_layoutTiles(m, v, x, y, w, h)
} Else If (fn = "tile") {
Tiler_layoutTiles(m, v, x, y, w, h, "blank")
If Config_continuouslyTraceAreas
View_traceAreas(True)
}
SetWinDelay, 10
}
Else ;; floating layout (no 'View_arrange_', following is 'View_getLayoutSymbol_')'
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#%l%
Bar_updateLayout(m)
}
View_getActiveWindow(m, v) {
Local listId, listIds, wndId
listIds := "aWndIds;wndIds"
wndId := 0
Loop, Parse, listIds, `;
{
listId := A_LoopField
Loop, Parse, View_#%m%_#%v%_%listId%, `;
{
If Not A_LoopField
Break
Else If Not WinExist("ahk_id" A_LoopField) Or Window_#%A_LoopField%_isMinimized
Continue
Else {
wndId := A_LoopField
Break
}
}
If wndId {
If (listId = "wndIds")
View_setActiveWindow(m, v, wndId)
Break
}
}
Return, wndId
}
View_getTiledWndIds(m, v)
{
Local n, tiledWndIds, wndIds
n := 0
tiledWndIds := ""
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
If A_LoopField And Not Window_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Window_isHung(A_LoopField)
{
n += 1
tiledWndIds .= A_LoopField ";"
}
}
View_tiledWndIds := tiledWndIds
StringTrimRight, tiledWndIds, tiledWndIds, 1
StringSplit, View_tiledWndId, tiledWndIds, `;
Return, n
}
View_ghostWindow(m, v, bodyWndId, ghostWndId)
{
Local search, replace
search := bodyWndId ";"
replace := search ghostWndId ";"
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
}
View_moveToIndex(m, v, n, w) {
Local wndIds
View_#%n%_#%w%_area_#0 := View_#%m%_#%v%_area_#0
View_#%n%_#%w%_aWndIds := View_#%m%_#%v%_aWndIds
View_#%n%_#%w%_layout_#1 := View_#%m%_#%v%_layout_#1
View_#%n%_#%w%_layout_#2 := View_#%m%_#%v%_layout_#2
View_#%n%_#%w%_layoutAxis_#1 := View_#%m%_#%v%_layoutAxis_#1
View_#%n%_#%w%_layoutAxis_#2 := View_#%m%_#%v%_layoutAxis_#2
View_#%n%_#%w%_layoutAxis_#3 := View_#%m%_#%v%_layoutAxis_#3
View_#%n%_#%w%_layoutGapWidth := View_#%m%_#%v%_layoutGapWidth
View_#%n%_#%w%_layoutMFact := View_#%m%_#%v%_layoutMFact
View_#%n%_#%w%_layoutMX := View_#%m%_#%v%_layoutMX
View_#%n%_#%w%_layoutMY := View_#%m%_#%v%_layoutMY
View_#%n%_#%w%_layoutSymbol := View_#%m%_#%v%_layoutSymbol
View_#%n%_#%w%_margins := View_#%m%_#%v%_margins
View_#%n%_#%w%_showStackArea := View_#%m%_#%v%_showStackArea
View_#%n%_#%w%_wndIds := View_#%m%_#%v%_wndIds
StringSplit, View_#%n%_#%w%_margin, View_#%n%_#%w%_margins, `;
StringTrimRight, wndIds, View_#%n%_#%w%_wndIds, 1
Loop, PARSE, wndIds, `;
{
Window_#%A_LoopField%_monitor := n
Window_#%A_LoopField%_tags -= 1 << v - 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.
View_moveWindow(i=0, d=0) {
Local aWndId, m, v
WinGet, aWndId, ID, A
m := Manager_aMonitor
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 (i = 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_#%aWndId%_area := i
Manager_setCursor(aWndId)
}
}
View_resetTileLayout() {
Local m, v
m := Manager_aMonitor
v := Monitor_#%m%_aView_#1
View_#%m%_#%v%_area_#0 := 0
View_#%m%_#%v%_layout_#2 := View_#%m%_#%v%_layout_#1
View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2
View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3
View_#%m%_#%v%_layoutGapWidth := Config_layoutGapWidth
View_#%m%_#%v%_layoutMFact := Config_layoutMFactor
View_#%m%_#%v%_layoutMX := 1
View_#%m%_#%v%_layoutMY := 1
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1
View_#%m%_#%v%_margins := "0;0;0;0"
View_#%m%_#%v%_showStackArea := True
StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `;
If Tiler_isActive(m, v)
View_arrange(m, v)
}
View_setActiveWindow(m, v, wndId) {
Global
If wndId {
StringReplace, View_#%m%_#%v%_aWndIds, View_#%m%_#%v%_aWndIds, % wndId ";", All
View_#%m%_#%v%_aWndIds := wndId ";" View_#%m%_#%v%_aWndIds
}
}
View_setGapWidth(i, d = 0) {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If (i = 0) And (d != 0)
i := View_#%Manager_aMonitor%_#%v%_layoutGapWidth
i += d
If (i >= 0 And i < Monitor_#%Manager_aMonitor%_height And i < Monitor_#%Manager_aMonitor%_width) {
i := Ceil(i / 2) * 2
View_#%Manager_aMonitor%_#%v%_layoutGapWidth := i
Return, 1
} Else
Return, 0
}
View_setLayout(i, d = 0) {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If (i = -1)
i := View_#%Manager_aMonitor%_#%v%_layout_#2
Else If (i = 0)
i := View_#%Manager_aMonitor%_#%v%_layout_#1
i := Manager_loop(i, d, 1, Config_layoutCount)
If (i > 0) And (i <= Config_layoutCount) {
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_#1 := i
}
View_arrange(Manager_aMonitor, v, True)
}
}
View_setLayoutProperty(name, i, d, opt = 0) {
Local a, l, v
a := False
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Tiler_isActive(Manager_aMonitor, v) {
If (name = "Axis")
a := Tiler_setAxis(Manager_aMonitor, v, opt, d)
Else If (name = "MFactor") {
If (opt = 0)
opt := 1
a := Tiler_setMFactor(Manager_aMonitor, v, i, d, opt)
} Else If (name = "MX")
a := Tiler_setMX(Manager_aMonitor, v, d)
Else If (name = "MY")
a := Tiler_setMY(Manager_aMonitor, v, d)
}
If (name = "GapWidth") And (Tiler_isActive(Manager_aMonitor, v) Or (Config_layoutFunction_#%l% = "monocle"))
a := View_setGapWidth(i, d)
If a
View_arrange(Manager_aMonitor, v)
}
View_shuffleWindow(i, d = 0) {
Local aWndId, j, replace, v
Debug_logMessage("DEBUG[2] View_shuffleWindow(" . i . ", " . d . ")", 2)
v := Monitor_#%Manager_aMonitor%_aView_#1
If Tiler_isActive(Manager_aMonitor, v) {
View_getTiledWndIds(Manager_aMonitor, v)
WinGet, aWndId, ID, A
If InStr(View_tiledWndIds, aWndId ";") And (View_tiledWndId0 > 1) {
Loop, % View_tiledWndId0 {
If (View_tiledWndId%A_Index% = aWndId) {
j := A_Index
Break
}
}
If (i = 0)
i := j
Else If (i = 1 And j = 1)
i := 2
i := Manager_loop(i, d, 1, View_tiledWndId0)
Debug_logMessage("DEBUG[2] View_shuffleWindow: " . j . " -> " . i, 2)
If (i != j) {
If (i < j)
replace := aWndId ";" View_tiledWndId%i% ";"
Else
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, % View_tiledWndId%i% ";", %replace%
View_arrange(Manager_aMonitor, v)
Manager_setCursor(aWndId)
}
}
}
}
View_toggleFloatingWindow(wndId = 0) {
Local l, v
If (wndId = 0)
WinGet, wndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
Debug_logMessage("DEBUG[2] View_toggleFloatingWindow; wndId: " . wndId, 2)
If (Config_layoutFunction_#%l% And InStr(Manager_managedWndIds, wndId ";")) {
Window_#%wndId%_isFloating := Not Window_#%wndId%_isFloating
View_arrange(Manager_aMonitor, v)
Bar_updateTitle()
}
}
View_toggleMargins()
{
Local v
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)
If (View_#%Manager_aMonitor%_#%v%_margins = "0;0;0;0")
View_#%Manager_aMonitor%_#%v%_margins := Config_viewMargins
Else
View_#%Manager_aMonitor%_#%v%_margins := "0;0;0;0"
StringSplit, View_#%Manager_aMonitor%_#%v%_margin, View_#%Manager_aMonitor%_#%v%_margins, `;
View_arrange(Manager_aMonitor, v)
}
}
View_toggleStackArea() {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If Tiler_isActive(Manager_aMonitor, v) And Not Config_dynamicTiling {
Tiler_toggleStackArea(Manager_aMonitor, v)
View_arrange(Manager_aMonitor, v)
}
}
View_traceAreas(continuously = False) {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If Tiler_isActive(Manager_aMonitor, v) And Not Config_dynamicTiling
Tiler_traceAreas(Manager_aMonitor, v, continuously)
}
/*
bug.n -- tiling window management
Copyright (c) 2010-2019 Joshua Fuhs, joten
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@license GNU General Public License version 3
../LICENSE.md or <http://www.gnu.org/licenses/>
@version 9.1.0
*/
View_init(m, v) {
Global
View_#%m%_#%v%_area_#0 := 0
View_#%m%_#%v%_aWndIds := "0;"
View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layout_#2 := 1
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2
View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3
View_#%m%_#%v%_layoutGapWidth := Config_layoutGapWidth
View_#%m%_#%v%_layoutMFact := Config_layoutMFactor
View_#%m%_#%v%_layoutMX := 1
View_#%m%_#%v%_layoutMY := 1
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1
View_#%m%_#%v%_margins := "0;0;0;0"
View_#%m%_#%v%_showStackArea := True
StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `;
View_#%m%_#%v%_wndIds := ""
}
View_activateWindow(i, d = 0) {
Local aWndId, direction, failure, j, v, wndId, wndId0, wndIds
Debug_logMessage("DEBUG[1] View_activateWindow(" . i . ", " . d . ")", 1)
If (i = 0) And (d = 0)
Return
WinGet, aWndId, ID, A
Debug_logMessage("DEBUG[2] Active Windows ID: " . aWndId, 2, False)
v := Monitor_#%Manager_aMonitor%_aView_#1
Debug_logMessage("DEBUG[2] View (" . v . ") wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 2, False)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
StringSplit, wndId, wndIds, `;
Debug_logMessage("DEBUG[2] wndId count: " . wndId0, 2, False)
If (i > 0) And (i <= wndId0) And (d = 0) {
wndId := wndId%i%
Window_set(wndId, "AlwaysOnTop", "On")
Window_set(wndId, "AlwaysOnTop", "Off")
Window_#%wndId%_isMinimized := False
Manager_winActivate(wndId)
} Else If (wndId0 > 1) {
If Not InStr(Manager_managedWndIds, aWndId . ";") Or Window_#%aWndId%_isFloating
Window_set(aWndId, "Bottom", "")
Loop, % wndId0 {
If (wndId%A_Index% = aWndId) {
j := A_Index
Break
}
}
Debug_logMessage("DEBUG[2] Current wndId index: " . j, 2, False)
If (d > 0)
direction = 1
Else
direction = -1
i := Manager_loop(j, d, 1, wndId0)
Loop, % wndId0 {
Debug_logMessage("DEBUG[2] Next wndId index: " . i, 2, False)
wndId := wndId%i%
If Not Window_#%wndId%_isMinimized {
Window_set(wndId, "AlwaysOnTop", "On")
Window_set(wndId, "AlwaysOnTop", "Off")
;; If there are hung windows on the screen, we still want to be able to cycle through them.
failure := Manager_winActivate(wndId)
If Not failure
Break
}
i := Manager_loop(i, direction, 1, wndId0)
}
}
}
View_addWindow(m, v, wndId) {
Local i, mSplit, n, replace, search
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, % wndId ";",, All
If Tiler_isActive(m, v) And ((Config_newWndPosition = "masterBottom") Or (Config_newWndPosition = "stackTop")) {
n := View_getTiledWndIds(m, v)
mSplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY
If (mSplit = 1 And Config_newWndPosition = "masterBottom")
View_#%m%_#%v%_wndIds := wndId ";" . View_#%m%_#%v%_wndIds
Else If ((Config_newWndPosition = "masterBottom" And n < mSplit) Or (Config_newWndPosition = "stackTop" And n <= mSplit))
View_#%m%_#%v%_wndIds .= wndId ";"
Else {
If (Config_newWndPosition = "masterBottom")
i := mSplit - 1
Else
i := mSplit
search := View_tiledWndId%i% ";"
replace := search wndId ";"
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
}
}
Else If (Config_newWndPosition = "bottom")
View_#%m%_#%v%_wndIds .= wndId ";"
Else
View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds
}
View_arrange(m, v, setLayout = False) {
Local fn, h, l, w, x, y
Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1)
l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l%
If fn {
x := Monitor_#%m%_x + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin4
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
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.
SetWinDelay, 0
If Config_dynamicTiling Or setLayout {
View_getTiledWndIds(m, v)
If (fn = "monocle") {
;; 'View_getLayoutSymbol_monocle'
View_#%m%_#%v%_layoutSymbol := "[" View_tiledWndId0 "]"
;; 'View_arrange_monocle'
Tiler_stackTiles(0, 0, 1, View_tiledWndId0, +1, 3, x, y, w, h, 0)
} Else ;; (fn = "tile")
Tiler_layoutTiles(m, v, x, y, w, h)
} Else If (fn = "tile") {
Tiler_layoutTiles(m, v, x, y, w, h, "blank")
If Config_continuouslyTraceAreas
View_traceAreas(True)
}
SetWinDelay, 10
}
Else ;; floating layout (no 'View_arrange_', following is 'View_getLayoutSymbol_')'
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#%l%
;Bar_updateLayout(m)
}
View_getActiveWindow(m, v) {
Local listId, listIds, wndId
listIds := "aWndIds;wndIds"
wndId := 0
Loop, Parse, listIds, `;
{
listId := A_LoopField
Loop, Parse, View_#%m%_#%v%_%listId%, `;
{
If Not A_LoopField
Break
Else If Not WinExist("ahk_id" A_LoopField) Or Window_#%A_LoopField%_isMinimized
Continue
Else {
wndId := A_LoopField
Break
}
}
If wndId {
If (listId = "wndIds")
View_setActiveWindow(m, v, wndId)
Break
}
}
Return, wndId
}
View_getTiledWndIds(m, v)
{
Local n, tiledWndIds, wndIds
n := 0
tiledWndIds := ""
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
If A_LoopField And Not Window_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Window_isHung(A_LoopField)
{
n += 1
tiledWndIds .= A_LoopField ";"
}
}
View_tiledWndIds := tiledWndIds
StringTrimRight, tiledWndIds, tiledWndIds, 1
StringSplit, View_tiledWndId, tiledWndIds, `;
Return, n
}
View_ghostWindow(m, v, bodyWndId, ghostWndId)
{
Local search, replace
search := bodyWndId ";"
replace := search ghostWndId ";"
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
}
View_moveToIndex(m, v, n, w) {
Local wndIds
View_#%n%_#%w%_area_#0 := View_#%m%_#%v%_area_#0
View_#%n%_#%w%_aWndIds := View_#%m%_#%v%_aWndIds
View_#%n%_#%w%_layout_#1 := View_#%m%_#%v%_layout_#1
View_#%n%_#%w%_layout_#2 := View_#%m%_#%v%_layout_#2
View_#%n%_#%w%_layoutAxis_#1 := View_#%m%_#%v%_layoutAxis_#1
View_#%n%_#%w%_layoutAxis_#2 := View_#%m%_#%v%_layoutAxis_#2
View_#%n%_#%w%_layoutAxis_#3 := View_#%m%_#%v%_layoutAxis_#3
View_#%n%_#%w%_layoutGapWidth := View_#%m%_#%v%_layoutGapWidth
View_#%n%_#%w%_layoutMFact := View_#%m%_#%v%_layoutMFact
View_#%n%_#%w%_layoutMX := View_#%m%_#%v%_layoutMX
View_#%n%_#%w%_layoutMY := View_#%m%_#%v%_layoutMY
View_#%n%_#%w%_layoutSymbol := View_#%m%_#%v%_layoutSymbol
View_#%n%_#%w%_margins := View_#%m%_#%v%_margins
View_#%n%_#%w%_showStackArea := View_#%m%_#%v%_showStackArea
View_#%n%_#%w%_wndIds := View_#%m%_#%v%_wndIds
StringSplit, View_#%n%_#%w%_margin, View_#%n%_#%w%_margins, `;
StringTrimRight, wndIds, View_#%n%_#%w%_wndIds, 1
Loop, PARSE, wndIds, `;
{
Window_#%A_LoopField%_monitor := n
Window_#%A_LoopField%_tags -= 1 << v - 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.
View_moveWindow(i=0, d=0) {
Local aWndId, m, v
WinGet, aWndId, ID, A
m := Manager_aMonitor
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 (i = 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_#%aWndId%_area := i
Manager_setCursor(aWndId)
}
}
View_resetTileLayout() {
Local m, v
m := Manager_aMonitor
v := Monitor_#%m%_aView_#1
View_#%m%_#%v%_area_#0 := 0
View_#%m%_#%v%_layout_#2 := View_#%m%_#%v%_layout_#1
View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
View_#%m%_#%v%_layoutAxis_#2 := Config_layoutAxis_#2
View_#%m%_#%v%_layoutAxis_#3 := Config_layoutAxis_#3
View_#%m%_#%v%_layoutGapWidth := Config_layoutGapWidth
View_#%m%_#%v%_layoutMFact := Config_layoutMFactor
View_#%m%_#%v%_layoutMX := 1
View_#%m%_#%v%_layoutMY := 1
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1
View_#%m%_#%v%_margins := "0;0;0;0"
View_#%m%_#%v%_showStackArea := True
StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `;
If Tiler_isActive(m, v)
View_arrange(m, v)
}
View_setActiveWindow(m, v, wndId) {
Global
If wndId {
StringReplace, View_#%m%_#%v%_aWndIds, View_#%m%_#%v%_aWndIds, % wndId ";", All
View_#%m%_#%v%_aWndIds := wndId ";" View_#%m%_#%v%_aWndIds
}
}
View_setGapWidth(i, d = 0) {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If (i = 0) And (d != 0)
i := View_#%Manager_aMonitor%_#%v%_layoutGapWidth
i += d
If (i >= 0 And i < Monitor_#%Manager_aMonitor%_height And i < Monitor_#%Manager_aMonitor%_width) {
i := Ceil(i / 2) * 2
View_#%Manager_aMonitor%_#%v%_layoutGapWidth := i
Return, 1
} Else
Return, 0
}
View_setLayout(i, d = 0) {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If (i = -1)
i := View_#%Manager_aMonitor%_#%v%_layout_#2
Else If (i = 0)
i := View_#%Manager_aMonitor%_#%v%_layout_#1
i := Manager_loop(i, d, 1, Config_layoutCount)
If (i > 0) And (i <= Config_layoutCount) {
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_#1 := i
}
View_arrange(Manager_aMonitor, v, True)
}
}
View_setLayoutProperty(name, i, d, opt = 0) {
Local a, l, v
a := False
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Tiler_isActive(Manager_aMonitor, v) {
If (name = "Axis")
a := Tiler_setAxis(Manager_aMonitor, v, opt, d)
Else If (name = "MFactor") {
If (opt = 0)
opt := 1
a := Tiler_setMFactor(Manager_aMonitor, v, i, d, opt)
} Else If (name = "MX")
a := Tiler_setMX(Manager_aMonitor, v, d)
Else If (name = "MY")
a := Tiler_setMY(Manager_aMonitor, v, d)
}
If (name = "GapWidth") And (Tiler_isActive(Manager_aMonitor, v) Or (Config_layoutFunction_#%l% = "monocle"))
a := View_setGapWidth(i, d)
If a
View_arrange(Manager_aMonitor, v)
}
View_shuffleWindow(i, d = 0) {
Local aWndId, j, replace, v
Debug_logMessage("DEBUG[2] View_shuffleWindow(" . i . ", " . d . ")", 2)
v := Monitor_#%Manager_aMonitor%_aView_#1
If Tiler_isActive(Manager_aMonitor, v) {
View_getTiledWndIds(Manager_aMonitor, v)
WinGet, aWndId, ID, A
If InStr(View_tiledWndIds, aWndId ";") And (View_tiledWndId0 > 1) {
Loop, % View_tiledWndId0 {
If (View_tiledWndId%A_Index% = aWndId) {
j := A_Index
Break
}
}
If (i = 0)
i := j
Else If (i = 1 And j = 1)
i := 2
i := Manager_loop(i, d, 1, View_tiledWndId0)
Debug_logMessage("DEBUG[2] View_shuffleWindow: " . j . " -> " . i, 2)
If (i != j) {
If (i < j)
replace := aWndId ";" View_tiledWndId%i% ";"
Else
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, % View_tiledWndId%i% ";", %replace%
View_arrange(Manager_aMonitor, v)
Manager_setCursor(aWndId)
}
}
}
}
View_toggleFloatingWindow(wndId = 0) {
Local l, v
If (wndId = 0)
WinGet, wndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
Debug_logMessage("DEBUG[2] View_toggleFloatingWindow; wndId: " . wndId, 2)
If (Config_layoutFunction_#%l% And InStr(Manager_managedWndIds, wndId ";")) {
Window_#%wndId%_isFloating := Not Window_#%wndId%_isFloating
View_arrange(Manager_aMonitor, v)
Bar_updateTitle()
}
}
View_toggleMargins()
{
Local v
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)
If (View_#%Manager_aMonitor%_#%v%_margins = "0;0;0;0")
View_#%Manager_aMonitor%_#%v%_margins := Config_viewMargins
Else
View_#%Manager_aMonitor%_#%v%_margins := "0;0;0;0"
StringSplit, View_#%Manager_aMonitor%_#%v%_margin, View_#%Manager_aMonitor%_#%v%_margins, `;
View_arrange(Manager_aMonitor, v)
}
}
View_toggleStackArea() {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If Tiler_isActive(Manager_aMonitor, v) And Not Config_dynamicTiling {
Tiler_toggleStackArea(Manager_aMonitor, v)
View_arrange(Manager_aMonitor, v)
}
}
View_traceAreas(continuously = False) {
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
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
* Copyright (c) 2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 0.1.0.01 (02.10.2011)
*/
NAME := "hul!"
VERSION := "0.1.0"
HELP :=
(Join
"USAGE`n
`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 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
`n
The search will be done on typing the search criteria.`n
`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
Select an entry and press Enter again to restore the selected window.`n
`n
Press the Escape (Esc) key to clear all fields and go back to entering the search criteria.`n"
)
/**
* Script settings
*/
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#NoTrayIcon
#SingleInstance force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; DetectHiddenWindows, On
; SetFormat, Integer, h
/**
* Pseudo main function
*/
WinGet, Main_aWndId, ID, A
; BEGIN: Init GUI
IfWinExist, %NAME%
Gui, Destroy
Gui, +LastFound +0xCF0000 -0x80000000
Gui, Add, Text, yp+11, Partial Title:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_title,
Gui, Add, Text, xm, Class Name:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_class,
Gui, Add, Text, xm, Process Name:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_pName,
; Gui, Add, Button, xm w800 vGui_search, Search
Gui, Add, ListBox, +0x100 t36 xm w800 vGui_wnds,
Gui, Add, Button, Default Hidden w800 vGui_restore, Restore
Gui, Show, AutoSize, %NAME%
Gui_wndId := WinExist()
Main_resize()
; END: Init GUI
Return ; end of the auto-execute section
/**
* Hotkeys, function & label definitions
*/
#IfWinActive hul! ahk_class AutoHotkeyGUI
{
^h::MsgBox %HELP%
}
ButtonRestore:
Main_restore()
Return
ButtonSearch:
Main_search()
Return
GuiClose:
ExitApp
Return
GuiEscape:
GuiControl, , Gui_title,
GuiControl, , Gui_class,
GuiControl, , Gui_pName,
GuiControl, , Gui_wnds, |
GuiControl, Focus, Gui_title
Return
GuiSize:
Main_resize(A_GuiWidth, A_GuiHeight)
Return
Main_resize(w = 0, h = 0) {
Global Gui_wndId
If (w = 0 Or h = 0) {
Sleep, 250
WinGetPos, x, y, w, h, ahk_id %Gui_wndId%
h += 1
WinMove, ahk_id %Gui_wndId%, , x, y, w, h
} Else {
w -= 2 * 10
w1 := w - (72 + 10)
h -= 3 * 30
; y := 8 + (3 * 30) + h + 8
GuiControl, Move, Gui_title, w%w1%
GuiControl, Move, Gui_class, w%w1%
GuiControl, Move, Gui_pName, w%w1%
; GuiControl, Move, Gui_search, w%w%
GuiControl, Move, Gui_wnds, w%w% h%h%
; GuiControl, Move, Gui_restore, y%y% w%w%
}
}
Main_restore() {
Global Gui_wnds
GuiControlGet, wnd, , Gui_wnds
If wnd {
wndId := SubStr(wnd, 1, InStr(wnd, ": ") - 1)
WinShow, ahk_id %wndId%
WinRestore, ahk_id %wndId%
WinSet, AlwaysOnTop, On, ahk_id %wndId%
WinSet, AlwaysOnTop, Off, ahk_id %wndId%
WinMove, ahk_id %wndId%, , 0, 0, 800, 600
} Else
GuiControl, Focus, Gui_wnds
}
Main_search() {
Global Gui_class, Gui_pName, Gui_title, Gui_wndId, Gui_wnds
GuiControl, , Gui_wnds, |
GuiControlGet, title, , Gui_title
GuiControlGet, class, , Gui_class
If class
criteria .= " ahk_class " class
GuiControlGet, pName, , Gui_pName
If pName {
Process, Exist, %pName%
If ErrorLevel
criteria .= " ahk_pid " ErrorLevel
}
If Not (criteria Or title)
criteria := "A"
wndListString := ""
DetectHiddenWindows, On
WinGet, wndId, List, % criteria
Loop, % wndId {
WinGetTitle, wndTitle, % "ahk_id " wndId%A_Index%
If Not (wndId%A_Index% = Gui_wndId) And (Not title Or RegExmatch(wndTitle, title)) {
WinGetClass, wndClass, % "ahk_id " wndId%A_Index%
WinGet, wndPName, ProcessName, % "ahk_id " wndId%A_Index%
WinGet, wndStyle, Style, % "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 ")"
}
}
DetectHiddenWindows, Off
GuiControl, , Gui_wnds, % wndListString
}
/**
* hul! - Find and restore (hidden) windows
* Copyright (c) 2011 joten
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @version 0.1.0.01 (02.10.2011)
*/
NAME := "hul!"
VERSION := "0.1.0"
HELP :=
(Join
"USAGE`n
`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 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
`n
The search will be done on typing the search criteria.`n
`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
Select an entry and press Enter again to restore the selected window.`n
`n
Press the Escape (Esc) key to clear all fields and go back to entering the search criteria.`n"
)
/**
* Script settings
*/
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#NoTrayIcon
#SingleInstance force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; DetectHiddenWindows, On
; SetFormat, Integer, h
/**
* Pseudo main function
*/
WinGet, Main_aWndId, ID, A
; BEGIN: Init GUI
IfWinExist, %NAME%
Gui, Destroy
Gui, +LastFound +0xCF0000 -0x80000000
Gui, Add, Text, yp+11, Partial Title:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_title,
Gui, Add, Text, xm, Class Name:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_class,
Gui, Add, Text, xm, Process Name:
Gui, Add, Edit, xp+82 yp-3 w700 gButtonSearch vGui_pName,
; Gui, Add, Button, xm w800 vGui_search, Search
Gui, Add, ListBox, +0x100 t36 xm w800 vGui_wnds,
Gui, Add, Button, Default Hidden w800 vGui_restore, Restore
Gui, Show, AutoSize, %NAME%
Gui_wndId := WinExist()
Main_resize()
; END: Init GUI
Return ; end of the auto-execute section
/**
* Hotkeys, function & label definitions
*/
#IfWinActive hul! ahk_class AutoHotkeyGUI
{
^h::MsgBox %HELP%
}
ButtonRestore:
Main_restore()
Return
ButtonSearch:
Main_search()
Return
GuiClose:
ExitApp
Return
GuiEscape:
GuiControl, , Gui_title,
GuiControl, , Gui_class,
GuiControl, , Gui_pName,
GuiControl, , Gui_wnds, |
GuiControl, Focus, Gui_title
Return
GuiSize:
Main_resize(A_GuiWidth, A_GuiHeight)
Return
Main_resize(w = 0, h = 0) {
Global Gui_wndId
If (w = 0 Or h = 0) {
Sleep, 250
WinGetPos, x, y, w, h, ahk_id %Gui_wndId%
h += 1
WinMove, ahk_id %Gui_wndId%, , x, y, w, h
} Else {
w -= 2 * 10
w1 := w - (72 + 10)
h -= 3 * 30
; y := 8 + (3 * 30) + h + 8
GuiControl, Move, Gui_title, w%w1%
GuiControl, Move, Gui_class, w%w1%
GuiControl, Move, Gui_pName, w%w1%
; GuiControl, Move, Gui_search, w%w%
GuiControl, Move, Gui_wnds, w%w% h%h%
; GuiControl, Move, Gui_restore, y%y% w%w%
}
}
Main_restore() {
Global Gui_wnds
GuiControlGet, wnd, , Gui_wnds
If wnd {
wndId := SubStr(wnd, 1, InStr(wnd, ": ") - 1)
WinShow, ahk_id %wndId%
WinRestore, ahk_id %wndId%
WinSet, AlwaysOnTop, On, ahk_id %wndId%
WinSet, AlwaysOnTop, Off, ahk_id %wndId%
WinMove, ahk_id %wndId%, , 0, 0, 800, 600
} Else
GuiControl, Focus, Gui_wnds
}
Main_search() {
Global Gui_class, Gui_pName, Gui_title, Gui_wndId, Gui_wnds
GuiControl, , Gui_wnds, |
GuiControlGet, title, , Gui_title
GuiControlGet, class, , Gui_class
If class
criteria .= " ahk_class " class
GuiControlGet, pName, , Gui_pName
If pName {
Process, Exist, %pName%
If ErrorLevel
criteria .= " ahk_pid " ErrorLevel
}
If Not (criteria Or title)
criteria := "A"
wndListString := ""
DetectHiddenWindows, On
WinGet, wndId, List, % criteria
Loop, % wndId {
WinGetTitle, wndTitle, % "ahk_id " wndId%A_Index%
If Not (wndId%A_Index% = Gui_wndId) And (Not title Or RegExmatch(wndTitle, title)) {
WinGetClass, wndClass, % "ahk_id " wndId%A_Index%
WinGet, wndPName, ProcessName, % "ahk_id " wndId%A_Index%
WinGet, wndStyle, Style, % "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 ")"
}
}
DetectHiddenWindows, Off
GuiControl, , Gui_wnds, % wndListString
}