Following this topic I also have a custom made WindowManager which probably has bad coding in some points but it worked good in 1.1.28.02.
In 1.1.29 it doesnt work at all and crashes automatically when pressing the Hotkey that triggers the WinMoves
Code: Select all
;https://autohotkey.com/boards/viewtopic.php?f=5&t=49087&p=219059#p219059
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, RegEx
#SingleInstance, Force
;=============================================================================================================================================
;=============================================================================================================================================
WinTitlesArray:= [ "AutoHotkey.Help", "AHK Studio", "ahk_class Chrome_WidgetWin_1", "Window.Spy", "WinSpy", "ahk_class CabinetWClass", "DataSage50", "INFOS.CLIENT", "TempsTravail", ".SAI", "Ventes|Revenus|Produits ahk_class WindowsForms10.Window.8.app.0.(?:.*)_r38_ad1", "Achats|fournisseurs|Charges ahk_class WindowsForms10.Window.8.app.0.(?:.*)_r38_ad1", "Bilan ahk_class WindowsForms10.Window.8.app.0.(?:.*)_r38_ad1", ".tat des r.sultats ahk_class WindowsForms10.Window.8.app.0.(?:.*)_r38_ad1", "Rapport.*Rapprochement ahk_class WindowsForms10.Window.8.app.0.(?:.*)_r38_ad1", "Rapport.*sommaire ahk_class WindowsForms10.Window.8.app.0.(?:.*)_r38_ad1", "Encaissements ahk_class #32770", "Paiements ahk_class #32770", "Virer des Fonds ahk_class #32770", "Rapprochement & d.p.ts ahk_class #32770", "Journal.g.n.ral ahk_class #32770", "REGISTRE_KM", "TauxStatsCan.csv", "Visual Studio Code", "Accessible.Info.Viewer", "D.tails chronologiques des clients" ]
;=============================================================================================================================================
;=============================================================================================================================================
!#1::
SetBatchLines, -1
SetWinDelay, 0
SaveWindows(WinTitlesArray) ; Function call
Return
#1::
SetBatchLines, -1
SetWinDelay, 0
RepositionWindows(WinTitlesArray) ; function call
Return
;=============================================================================================================================================
;=============================================================================================================================================
; Functions
;=============================================================================================================================================
;=============================================================================================================================================
SaveWindows(WinTitlesArray) ; SaveWindows( **WinTitles Array**)
{
MsgBox,262180,Sauvegarder la position des fenêtres?,Voulez-vous sauvegarder la position des fenêtres, ou non?`n`nSi Oui, le fichier WinTitleStats_%A_ComputerName%.ini sera actualisé en conséquence des changements analysés.
ifMsgBox No
return
WinClose, WinTitleStats_%A_ComputerName%
WinGetActiveTitle, LastActiveWindowSaved
For Each, WinTitle in WinTitlesArray
{
This_WinTitle:= WinTitle
if WinExist(This_WinTitle)
{
IniRead, Ini_x, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, x
IniRead, Ini_y, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, y
IniRead, Ini_w, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, w
IniRead, Ini_h, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, h
IniRead, Ini_MinMax, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, MinMax
WinActivate, %This_WinTitle%
WinGetPos,Current_x,Current_y,Current_w,Current_h, %This_WinTitle%
WinGet, Current_MinMax, MinMax, %This_WinTitle%
if (Current_x != Ini_x) or (Current_y != Ini_y) or (Current_w != Ini_w) or (Current_h != Ini_h) ;or (Current_MinMax != Ini_MinMax)
{
IniDelete, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%
IniWrite, %Current_x%, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, x
IniWrite, %Current_y%, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, y
IniWrite, %Current_w%, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, w
IniWrite, %Current_h%, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, h
IniWrite, %Current_MinMax%, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, MinMax
IniWrite, %A_Space%, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, _________________________________________________________________________________________
;IniWrite, Value , Filename , Section , Key
}
}
}
WinActivate, %LastActiveWindowSaved%
}
;=============================================================================================================================================
;=============================================================================================================================================
RepositionWindows(WinTitlesArray) ; RepositionWindows( **WinTitles Array**)
;=============================================================================================================================================
;=============================================================================================================================================
{
WinClose, WinTitleStats_%A_ComputerName%
WinGetActiveTitle, LastActiveWindowSaved
For Each, WinTitle in WinTitlesArray
{
LoopTopLabel:
This_WinTitle:= WinTitle
if WinExist(This_WinTitle)
{
;IniRead, Ini_MinMax, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, MinMax
;if (Ini_MinMax = 1)
;WinMaximize, %This_WinTitle%
;else if (Ini_MinMax = -1) ;and (LastActiveWindow !== %This_WinTitle%)
;WinMinimize, %This_WinTitle%
;else if (Ini_MinMax = 0)
;{
;IniRead, OutputVar, Filename , Section , Key [, Default]
IniRead, Ini_x, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, x
IniRead, Ini_y, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, y
IniRead, Ini_w, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, w
IniRead, Ini_h, WinTitleStats_%A_ComputerName%.ini, %This_WinTitle%, h
WinGetPos,Current_x,Current_y,Current_w,Current_h, %This_WinTitle%
WinGet, Current_MinMax, MinMax, %This_WinTitle%
WinGet, MatchingTitle, List, %This_WinTitle% ; Compare this WinTitle contained in the Array to count how many matches with All existing windows and retrieve IDs of these in pseudo-array
if (MatchingTitle > 1) ; If there is more than 1 existing window matching with This_WinTitle
{
;MsgBox % "Inside Loop Layer1`n`nSearching for This_WinTitle in all existing windows to count matches:`n`n" WinTitle "`n`nNumber of Matches found:`n" MatchingTitle
Loop, %MatchingTitle% ; loop for the amount of matches we found
{
This_WinTitle:= "ahk_id " MatchingTitle%A_Index% ; MatchingTitle contient le no. de MATCH| MatchingTitles1, MatchingTitles2, MatchingTitles3, etc.. = Unique ID of This_WinTitle
;MsgBox % "Inside Loop Layer2`n`nAnalysed Match " A_Index "/" MatchingTitle " for`n" This_WinTitle "`n`nThis Matching Window's unique ID is:`n" This_WinTitle
if (Current_MinMax = 0) and (Current_x != Ini_x) or (Current_y != Ini_y) or (Current_w != Ini_w) or (Current_h != Ini_h)
WinMove, %This_WinTitle%,, %Ini_x%, %Ini_y%, %Ini_w%, %Ini_h%
else if (Current_MinMax != 0) and (Current_x != Ini_x) or (Current_y != Ini_y) or (Current_w != Ini_w) or (Current_h != Ini_h)
{
;WinRestore, %This_WinTitle%
WinMove, %This_WinTitle%,, %Ini_x%, %Ini_y%, %Ini_w%, %Ini_h%
}
}
}
else if (Current_MinMax = 0) ; Normal state (not Minimized or Maximized)
if (Current_x != Ini_x) or (Current_y != Ini_y) or (Current_w != Ini_w) or (Current_h != Ini_h)
{
;WinMove, WinTitle ,WinText,X, Y [, Width , Height, ExcludeTitle, ExcludeText]
WinMove, %This_WinTitle%,, %Ini_x%, %Ini_y%, %Ini_w%, %Ini_h%
;Goto,LoopTopLabel
;MsgBox MinMax = 0 and Ini_positions are not matching Current Positions: Continuing back to LoopTopLabel
}
else if (Current_MinMax = 1) ; Maximized
if (Current_x != Ini_x) or (Current_y != Ini_y) or (Current_w != Ini_w) or (Current_h != Ini_h)
{
WinRestore, %This_WinTitle%
WinMove, %This_WinTitle%,, %Ini_x%, %Ini_y%, %Ini_w%, %Ini_h%
;MsgBox MinMax = 1: do nothing: Going LoopTopLabel
}
else if (Current_MinMax = -1)
{
;WinRestore, %This_WinTitle%
;WinMove, %This_WinTitle%,, %Ini_x%, %Ini_y%, %Ini_w%, %Ini_h%
;MsgBox MinMax = -1: do nothing: Continuing back to LoopTopLabel
}
;}
}
WinActivate, %LastActiveWindowSaved%
}
}
^#!1::ExitApp