;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Total Commander DreamLair
; Script: Archivate selected files and folders using WCX plugins TC
; Script: Архівація виділених файлів і папок за допомогою WCX плагінів TC
; Script: Архивация выделенных файлов и папок с помощью WCX плагинов TC
; Version: 1.0 (2015.05.04)
; Author: LonerD (dreamlair.net)
; Made in Donetsk People's Republic
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Parameters / Параметри / Параметры:
; 1: {archive extension}/{розширення архиву}/{расширение архива}
; 2: {target directory}/{каталог призначення}/{каталог назначения}
; {if \ - then directory in target panel}
; {якщо \ - каталог в протилежній панелі}
; {если \ - каталог в противоположноей панели}
; 3: {archive name}/{ім'я файлу архіву}/{имя файла архива}
; {if \ - then file under cursor name}
; {якщо \ - береться ім'я файлу під курсором}
; {если \ - берётся имя файла под курсором}
; 4: {move to archive: 0 - don't delete files | 1 - delete files}
; {переміщати в архів: 0 - не видаляти файли | 1 - видаляти файли}
; {перемещать в архив: 0 - не удалять файлы | 1 - удалять файлы}
; 5: {archive type: 0 - normal | 1 - SFX}
; {тип архіву: 0 - звичайний | 1 - SFX}
; {тип архива: 0 - обычный | 1 - SFX}
; 6: {1 - separate archives, one per selected file/dir}
; (1 - архівувати кожен файл/каталог у окремий архів)
; (1 - каждый файл/каталог помещается в отдельный архив)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#NoEnv
#NoTrayIcon
#SingleInstance force
SetBatchLines, -1
SetKeyDelay, 20, 20
If not ( WinExist("ahk_class TTOTAL_CMD") || WinActive("ahk_class TTOTAL_CMD") )
ExitApp
WinGet, hw_TTOTAL_CMD, ID, A
SelCount := TC_Command(0x190, hw_TTOTAL_CMD, 0, 0)
CursorName := TC_SendData("SN")
if (( SelCount = 0 ) || (( SelCount = 1 ) && ( CursorName = ".." )))
ExitApp
Arc = %1%
Path = %2%
Name = %3%
ArcMove = %5%
ArcExe = %4%
ArcSepar = %6%
If 0 < 6
ArcSepar = 0
If 0 < 5
ArcExe = 0
If 0 < 4
ArcMove = 0
If 0 < 3
Name := CursorName
If 0 < 2
Path := TC_SendData("TP")
If 0 < 1
Arc := "7z"
if ( Name = "\" )
Name := CursorName
if (( Name = "" ) || ( Name = ".." ))
Name := DreamLair
StringReplace, Name, Name, \, , All
if ( Path = "\" )
Path := TC_SendData("TP")
WinGet, TCPID, PID, A
if ( A_Is64bitOS = 0 )
DreamTCArch := 32
else
DreamTCArch := GetBitness(TCPID)
if ( DreamTCArch = 32 )
{
TAltEdit1 := "TAltEdit1"
TCheckBox5 := "TCheckBox5"
TCheckBox4 := "TCheckBox4"
TCheckBox2 := "TCheckBox2"
TButton5 := "TButton5"
}
else
{
TAltEdit1 := "Edit1"
TCheckBox5 := "Button6"
TCheckBox4 := "Button5"
TCheckBox2 := "Button2"
TButton5 := "Button21"
}
ArcLine := Arc . ":" . Path . Name . "." . Arc
PostMessage, 0x433, 508,,, % "ahk_id " hw_TTOTAL_CMD
WinWaitNotActive, % "ahk_id " hw_TTOTAL_CMD
Sleep, 200
WinGet, Style, Style, % "ahk_id " hw_TTOTAL_CMD
if (Style & 0x8000000)
WinSet, Enable,, % "ahk_id " hw_TTOTAL_CMD
IfWinNotExist, ahk_class TDLGZIP
ExitApp
Sleep, 50
ControlSetText, % TAltEdit1, % ArcLine, ahk_class TDLGZIP
Sleep, 50
if ( ArcExe = 1 )
{
SendMessage, 0x201,,, % TCheckBox5, ahk_class TDLGZIP
SendMessage, 0x202,,, % TCheckBox5, ahk_class TDLGZIP
}
Sleep, 50
if ( ArcMove = 1 )
{
SendMessage, 0x201,,, % TCheckBox4, ahk_class TDLGZIP
SendMessage, 0x202,,, % TCheckBox4, ahk_class TDLGZIP
}
Sleep, 50
if ( ArcSepar = 1 )
{
SendMessage, 0x201,,, % TCheckBox2, ahk_class TDLGZIP
SendMessage, 0x202,,, % TCheckBox2, ahk_class TDLGZIP
}
Sleep, 50
SendMessage, 0x201,,, % TButton5, ahk_class TDLGZIP
SendMessage, 0x202,,, % TButton5, ahk_class TDLGZIP
ExitApp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Total Commander SendMessage (author LonerD)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Author: LonerD
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TC_Command(TCmessage, aControl, Param1, Param2)
{
global hw_TTOTAL_CMD
SendMessage, % TCmessage, % Param1, % Param2, % aControl, % "ahk_id " hw_TTOTAL_CMD
return ErrorLevel
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Total Commander WM_COPYData (author 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
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Total Commander architecture function (author YMP)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; WinGet, hw_TTOTAL_CMD, PID, ahk_class TTOTAL_CMD
; MsgBox, % GetBitness(hw_TTOTAL_CMD)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GetBitness(Process) {
Process, Exist, %Process%
If !(PID := ErrorLevel)
return 0
hProcess := DllCall("OpenProcess", "uint", 0x400
, "uint", 0, "uint", PID, "ptr")
If (hProcess = 0)
return 0
res := DllCall("IsWow64Process", "ptr", hProcess, "int *", Wow64Process)
If (res = 0)
return 0
DllCall("CloseHandle", "ptr", hProcess)
return Wow64Process? 32:64
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |