-- Inspired from this thread.
I never use the cm_SyncChangeDir command, it's useless in its current state.
Sometimes you want to enter into a directory knowing that there is no equivalent on the other side and you don't want the SyncChangeDir flag to be reset.
This script performs one simple action:
First call. Script runs and works in the background. Script remembers current directories (paths) on the left and right panels. When you return to this directories - synchronization is turned on, when you left directories - synchronization is turned off.
Second call. Disable synchronization and exit script.
Default TC behaviour - GIF1
AHK Script behaviour - GIF2
Code: Select all
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Total Commander DreamLair ;
; Script: Sinchronize dirs changes ;
; Скрипт: Синхронна зміна каталогів ;
; Скрипт: Синхронное изменение каталогов ;
; Script name: SyncChangeDir.ahk ;
; Script author: LonerD ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
#NoEnv
#NoTrayIcon
#Persistent
#SingleInstance Off
SetBatchLines, -1
DetectHiddenWindows, On
if CloseCopy() || RegExMatch(StrGet(DllCall("GetCommandLine", Ptr)), "i)\s/(restart|r|force|f)\s")
{
SendMessage, 1075, 2600, -1,, ahk_class TTOTAL_CMD
ExitApp
}
CloseCopy()
{
WinGet, List, List, % A_ScriptFullPath " ahk_class AutoHotkey"
Loop % List
if WinExist("ahk_id" List%A_Index%) != A_ScriptHwnd && res := true
WinClose
Return res
}
WinGet, hw_TTOTAL_CMD, ID, A
SendMessage, 1075, 2600, 1,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 1074, 9, 0,, % "ahk_id " hw_TTOTAL_CMD
ControlGetText, PathL,, % "ahk_id " ErrorLevel
SendMessage, 1074, 10, 0,, % "ahk_id " hw_TTOTAL_CMD
ControlGetText, PathR,, % "ahk_id " ErrorLevel
SetTimer SyncChange, 50
SyncChange:
if not ( WinExist("ahk_class TTOTAL_CMD") || WinActive("ahk_class TTOTAL_CMD") )
ExitApp
SendMessage, 1074, 9, 0,, % "ahk_id " hw_TTOTAL_CMD
ControlGetText, PathLnew,, % "ahk_id " ErrorLevel
SendMessage, 1074, 10, 0,, % "ahk_id " hw_TTOTAL_CMD
ControlGetText, PathRnew,, % "ahk_id " ErrorLevel
if ( ( PathLnew = PathL ) & ( PathRnew = PathR ) )
; cm_SyncChangeDir , 1 (включение функции)
SendMessage, 1075, 2600, 1,, % "ahk_id " hw_TTOTAL_CMD
Return