;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Total Commander DreamLair ;
; Script: Selection the same name files and/or dirs in the panels ;
; Скрипт: Виділення в панелях однойменних файлів та/або каталогів ;
; Скрипт: Выделение в панелях одноимённых файлов и/или каталогов ;
; Version: 2.0 (2018.09.24) ;
; Required: Total Commander 9.0+ ;
; Tested on: Total Commander 9.21a ;
; Author: LonerD DreamLair.net ;
; Made in Donetsk People's Republic ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Parameter: ;
; 1) Selection mode: ;
; 1 - all (default); 2 - only files; 3 - only dirs ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Параметр: ;
; 1) Метод виділення: ;
; 1 - все (за замовч.); 2 - тільки файли; 3 - тільки каталоги ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Параметр: ;
; 1) Метод выделения: ;
; 1 - всё (по умолчанию); 2 - только файлы; 3 - только каталоги ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
#NoEnv
#NoTrayIcon
#MaxMem 1024
#SingleInstance force
SetBatchLines, -1
Mode = %1%
if Mode not in 1,2,3
Mode = 1 ; файли і каталоги
ClipSaved := ClipboardAll
Clipboard := ""
if not ( WinExist("ahk_class TTOTAL_CMD") || WinActive("ahk_class TTOTAL_CMD") )
ExitApp
WinGet, hw_TTOTAL_CMD, ID, A
global hw_TTOTAL_CMD
DllCall("LockWindowUpdate", "uint", hw_TTOTAL_CMD)
TCPanelA := SendMessageTC(1074, 1000, 0, A)
hw_TCPathA := SendMessageTC(1074, 8+TCPanelA, 0, A)
ControlGetText, PathA,, % "ahk_id " hw_TCPathA
PathA := StrReplace(PathA, "\*.*", "\")
hw_TCPathB := SendMessageTC(1074, 11-TCPanelA, 0, A)
ControlGetText, PathB,, % "ahk_id " hw_TCPathB
PathB := StrReplace(PathB, "\*.*", "\")
SendMessage, 1075, 524,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 1075, 330 . Mode,,, % "ahk_id " hw_TTOTAL_CMD
SelItems := SendMessageTC(1074, 1004+TCPanelA, 0, A)
if ( SelItems = 0 )
Goto, Exit
SendMessage, 1075, 2017,,, % "ahk_id " hw_TTOTAL_CMD
FilesA := Clipboard
SendMessage, 1075, 2018,,, % "ahk_id " hw_TTOTAL_CMD
FileListA := Clipboard
SendMessage, 1075, 4006,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 1075, 524,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 1075, 330 . Mode,,, % "ahk_id " hw_TTOTAL_CMD
if ( PathA = PathB )
Goto, Exit
SelItems := SendMessageTC(1074, 1007-TCPanelA, 0, A)
if ( SelItems = 0 )
Goto, NoSelection
SendMessage, 1075, 2017,,, % "ahk_id " hw_TTOTAL_CMD
FilesB := Clipboard
SendMessage, 1075, 2018,,, % "ahk_id " hw_TTOTAL_CMD
FileListB := Clipboard
FileListSel := ""
Loop, Parse, FilesA, `n, `r
{
CurrentFile := A_LoopField
Loop, Parse, FilesB, `n, `r
{
if ( CurrentFile = A_LoopField )
FileListSel := FileListSel A_LoopField "`r`n"
}
}
if ( FileListSel = "" )
Goto, NoSelection
FileListSelA := ""
FileListSelB := ""
FileListSelX := ""
FileListX := FileListB
Gosub, LoopFilelist
FileListSelB := FileListSelX
FileListX := FileListA
Gosub, LoopFilelist
FileListSelA := FileListSelX
StringReplace, FileListSelA, FileListSelA, % PathA, , All
StringReplace, FileListSelB, FileListSelB, % PathB, , All
Clipboard := FileListSelB
SendMessage, 1075, 2033,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 1075, 400 . TCPanelA,,, % "ahk_id " hw_TTOTAL_CMD
Clipboard := FileListSelA
SendMessage, 1075, 2033,,, % "ahk_id " hw_TTOTAL_CMD
Exit:
Clipboard := ClipSaved
ClipSaved := ""
FileListA := ""
FileListB := ""
FileforSel := ""
FileListSelA := ""
FileListSelB := ""
FileListSelX := ""
DllCall("LockWindowUpdate", "uint", 0)
ExitApp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
LoopFilelist:
Loop, Parse, FileListSel, `n, `r
{
FileforSel := A_LoopField
FileLen := StrLen(FileforSel)
if ( FileLen > 0 )
{
Loop, Parse, FileListX, `n, `r
{
StringLen := StrLen(A_LoopField)
SlashSymbol := SubStr(A_LoopField, StringLen - FileLen, 1)
StringRight, CurrentFile, A_LoopField, FileLen
if (( StringLen - FileLen > 1 ) && ( SlashSymbol = "\" ) && ( CurrentFile = FileforSel ))
FileListSelX := FileListSelX A_LoopField "`r`n"
}
}
}
Return
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
NoSelection:
SendMessage, 1075, 524,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 1075, 4006,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 1075, 524,,, % "ahk_id " hw_TTOTAL_CMD
Goto, Exit
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Total Commander Send Message function ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
SendMessageTC(TCMsg, wParam, lParam, aControl)
{
SendMessage, % TCMsg, % wParam, % lParam, % aControl, % "ahk_id " hw_TTOTAL_CMD
return ErrorLevel
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|