#NoTrayIcon
#SingleInstance off
SetBatchLines, -1
SetKeyDelay, -1
SetWinDelay, -1
IniRead, RedirectAssociations, % COMMANDER_INI, Associations, RedirectSection, 0
Transform, INI, Deref, % (RedirectAssociations ? RedirectAssociations : COMMANDER_INI)
IniRead, Associations, % INI, Associations
FileRead, INIc, % INI
StringReplace, INIc, INIc, % "[" (StrLen(Associations) ? "" : "-") "Associations]", % "[" (StrLen(Associations) ? "-" : "") "Associations]"
FileDelete, % INI
FileAppend, % INIc, % INI
IniRead, Associations, % INI, Associations
If StrLen(Associations) < 65531
{ PostMessage, 1075, 519, 0,, ahk_class TTOTAL_CMD
WinWait, ahk_class TDlgCustomColors,, 3
If !ErrorLevel
ControlClick, TButton2,,,, 2
} Else
{ MsgBox, 8244, Total Commander, Associations section reached 64Kb limit!`nCannot continue without restarting Total Commander.`n`nRestart now?
IfMsgBox, Yes
TC_Restart()
}
TC_Restart() {
If WinExist("ahk_class TTOTAL_CMD")
{ WinGet, PID, PID
ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where ProcessId=" . PID)._NewEnum()[Process]
PostMessage, 1075, 24340, 0,, % t := "ahk_class TTOTAL_CMD ahk_pid " PID
WinWait, % c := "Total Commander ahk_class #32770 ahk_pid " PID, ?, 1.5
If !ErrorLevel
WinWaitClose, % c
WinWaitClose, % t,, 1.5
If ErrorLevel
MsgBox, 8244, Total Commander, Restart cancelled!
Else
Run, % Process.CommandLine
}
}
|