;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Total Commander DreamLair
; Script: Selection the same name files and/or dirs in the panels
; Скрипт: Виділення в панелях однойменних файлів та/або каталогів
; Скрипт: Выделение в панелях одноимённых файлов и/или каталогов
; Version: 1.0 (2015.05.02)
; 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
If not ( WinExist("ahk_class TTOTAL_CMD") || WinActive("ahk_class TTOTAL_CMD") )
ExitApp
ClipSaved := ClipboardAll
Clipboard := ""
WinGet, hw_TTOTAL_CMD, ID, A
DllCall("LockWindowUpdate", "uint", hw_TTOTAL_CMD)
ControlGetFocus, aControl, % "ahk_id " hw_TTOTAL_CMD
PathA := TC_SendData("SP")
SendMessage, 0x433, 524,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 0x433, 330 . Mode,,, % "ahk_id " hw_TTOTAL_CMD
SelItems := TC_Command("0x190", aControl, 0, 0)
if ( SelItems = 0 )
Goto, Exit
SendMessage, 0x433, 2017,,, % "ahk_id " hw_TTOTAL_CMD
FilesA := Clipboard
SendMessage, 0x433, 2018,,, % "ahk_id " hw_TTOTAL_CMD
FileListA := Clipboard
SendMessage, 0x433, 4001,,, % "ahk_id " hw_TTOTAL_CMD
ControlGetFocus, xControl, % "ahk_id " hw_TTOTAL_CMD
B_Panel := xControl = aControl ? 2 : 1
A_Panel := B_Panel = 1 ? 2 : 1
SendMessage, 0x433, 400 . B_Panel,,, % "ahk_id " hw_TTOTAL_CMD
ControlGetFocus, bControl, % "ahk_id " hw_TTOTAL_CMD
PathB := TC_SendData("SP")
SendMessage, 0x433, 524,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 0x433, 330 . Mode,,, % "ahk_id " hw_TTOTAL_CMD
if ( PathA = PathB )
Goto, Exit
SelItems := TC_Command("0x190", bControl, 0, 0)
if ( SelItems = 0 )
Goto, NoSelection
SendMessage, 0x433, 2017,,, % "ahk_id " hw_TTOTAL_CMD
FilesB := Clipboard
SendMessage, 0x433, 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, 0x433, 2033,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 0x433, 400 . A_Panel,,, % "ahk_id " hw_TTOTAL_CMD
Clipboard := FileListSelA
SendMessage, 0x433, 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, 0x433, 524,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 0x433, 400 . A_Panel,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 0x433, 524,,, % "ahk_id " hw_TTOTAL_CMD
Goto, Exit
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Доп. функция (автор я)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TC_Command(TCmessage, aControl, Param1, Param2)
{
global hw_TTOTAL_CMD
SendMessage, % TCmessage, % Param1, % Param2, % aControl, % "ahk_id " hw_TTOTAL_CMD
return ErrorLevel
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Доп. функция (автор artt)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TC_SendData(Cmd, CmdType="", msg="", hwnd="")
{
Critical
global hw_TTOTAL_CMD
Static om := OnMessage(0x4a, "TC_SendData"), TC_ReceiveDataValue := "", TC_DataReceived := ""
If ( (msg=0x4A) and (hwnd=A_ScriptHwnd) )
Exit ( TC_ReceiveDataValue := StrGet(NumGet(CmdType + A_PtrSize * 2)), TC_DataReceived := "1" )
VarSetCapacity(CopyDataStruct, A_PtrSize * 3), TC_ReceiveDataValue := 1, TC_DataReceived := ""
If CmdType in LR,ST
DirType := CmdType, CmdType := "CD"
else if ( CmdType = "" )
CmdType := ( A_IsUnicode ? "GW" : "GA" ), TC_ReceiveDataValue := ""
If( A_IsUnicode )
{
VarSetCapacity(cmdA, StrPut(cmd, "cp0"), 0)
Loop, % StrLen(cmd)
NumPut( Asc(SubStr(cmd, A_Index, 1)), cmdA, A_Index - 1, "Char" )
}
NumPut( Asc(SubStr(CmdType, 1, 1)) + 256 * Asc(SubStr(CmdType, 2, 1)), CopyDataStruct, 0 )
NumPut( StrLen(cmd) + (CmdType = "CD" ? 5 : 0), CopyDataStruct, A_PtrSize )
NumPut( (A_IsUnicode ? &cmdA : &cmd), CopyDataStruct, A_PtrSize * 2 )
Loop, % ( CmdType=="CD" ? 2 : 0 )
NumPut( Asc(SubStr(DirType, A_Index, 1)), (A_IsUnicode ? cmdA : cmd), (StrLen(cmd) + A_Index), "Char" )
SendMessage, 0x4A, %A_ScriptHwnd%, &CopyDataStruct,, % "ahk_id " hw_TTOTAL_CMD
; SendMessage, 0x4A, %A_ScriptHwnd%, &CopyDataStruct,, ahk_class TTOTAL_CMD
While ( TC_ReceiveDataValue = "" )
{
IfEqual, TC_DataReceived, 1, Break
IfGreaterOrEqual, A_Index, 500, Break
Sleep, 10
}
Return TC_ReceiveDataValue
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |