Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Создание архивов с использованием wcx-плагинов 
Author Message
LonerD



PostPosted: Tue Sep 18, 2018 17:38    Post subject: Reply with quote

Обновлённый вариант.
Упрощён и значительно оптимизирован с учётом нововведений в TC 9.
Исправлены найденные ошибки и добавлены новые.
Параметры изменились по сравнению с первой версией.
Добавлена тихая архивация без отображения диалога.

Ссылка на полную версию скрипта.

Code:
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Total Commander DreamLair                        ;
; Script: Archive files with using WCX plugins     ;
; Script: Архівація за допомогою WCX плагінів      ;
; Script: Архивация с помощью WCX плагинов         ;
; Script version: 2.0 (2018.09.18)                 ;
; Required: Total Commander 9.0+                   ;
; Tested on: Total Commander 9.21a                 ;
; Script author: LonerD                            ;
; Site: https://dreamlair.net                      ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Parameters / Параметры:
; 1: {archive extension}/{расширение архива}
; 2: {archive name}/{имя файла архива}
;    {if %P%N - then file under cursor name}
;    {если %P%N - берётся имя файла под курсором}
; 3: {target directory}/{каталог назначения}
;    {if %T - then directory in target panel}
;    {если %T - каталог в противоположноей панели}
; 4: {move to archive: 0 - don't delete files | 1 - delete files}
;    {перемещать в архив: 0 - не удалять файлы | 1 - удалять файлы}
; 5: {archive type: 0 - normal | 1 - SFX}
;    {тип архива: 0 - обычный | 1 - SFX}
; 6: {1 - separate archives, one per selected file/dir}
;    (1 - каждый файл/каталог помещать в отдельный архив)
; 7: {1 - archive silent, without confirmation dialog}
;    (1 - тихий процесс, скрыть диалог архивации)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;

#NoEnv
#NoTrayIcon
#SingleInstance force
SetBatchLines, -1
SetKeyDelay, 20, 20
DetectHiddenWindows, on

if not ( WinExist("ahk_class TTOTAL_CMD") || WinActive("ahk_class TTOTAL_CMD") )
  ExitApp
WinGet, hw_TTOTAL_CMD, ID, ahk_class TTOTAL_CMD
  global hw_TTOTAL_CMD

TCAPanel := SendMessageTC(1074, 1000, 0, A)
SelItems := SendMessageTC(1074, 1004+TCAPanel, 0, A)
CaretPos := SendMessageTC(1074, 1006+TCAPanel, 0, A)
IsUpDir := SendMessageTC(1074, 1008+TCAPanel, 0, A)

if (( IsUpDir = 1 ) && ( CaretPos = 0 ) && ( SelItems = 0 ))
  ExitApp

hw_TCTPath := SendMessageTC(1074, 11-TCAPanel, 0, A)
ControlGetText, TCTPath,, % "ahk_id " hw_TCTPath
TCTPath := StrReplace(TCTPath, "\*.*", "\")

Arc = %1%
ArcName = %2%
ArcPath = %3%
ArcMove = %4%
ArcExe = %5%
ArcSepar = %6%
ArcSilent = %7%

if 0 < 7
  ArcSilent = 0
if 0 < 6
  ArcSepar = 0
if 0 < 5
  ArcExe = 0
if 0 < 4
  ArcMove = 0
if 0 < 3
  ArcPath := TCTPath
if 0 < 2
  ArcName := ""
if 0 < 1
  Arc := "7z"

if ArcMove not in 0,1
  ArcMove = 0
if ArcExe not in 0,1
  ArcExe = 0
if ArcSepar not in 0,1
  ArcSepar = 0
if ArcSilent not in 0,1
  ArcSilent = 0

if not InStr(FileExist(ArcPath), "D")
  ArcPath := TCTPath

if FileExist(ArcName)
{
  SplitPath, ArcName, FileName, FileDir, FileExt, FileNameNoExt
  if not InStr(FileExist(ArcName), "D")
   ArcName := FileNameNoExt
     else
       ArcName := FileName
}

if ( ArcName = "" )
{
  FormatTime, CurrentDate, , [yyyy.MM.dd-HH.mm.ss]
  ArcName := "DreamLair " CurrentDate
}

Gosub, SetTC3264

TAltEdit := TC3264 = 32 ? "TAltEdit1" : "Edit1"
TCheckBoxMove := TC3264 = 32 ? "TCheckBox5" : "Button6"
TCheckBoxExe := TC3264 = 32 ? "TCheckBox4" : "Button5"
TCheckBoxSep := TC3264 = 32 ? "TCheckBox2" : "Button2"
TButtonOK := TC3264 = 32 ? "TButton5" : "Button21"

ArcLine := Arc . ":" . ArcPath . ArcName . "." . Arc

PostMessage, 0x433, 508,,, % "ahk_id " hw_TTOTAL_CMD
if ( ArcSilent = 0 )
{
  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
}
else
{
  WinWait, ahk_class TDLGZIP
  WinSet, Transparent, 0, ahk_class TDLGZIP
}

IfWinNotExist, ahk_class TDLGZIP
  ExitApp

Sleep, 50
ControlSetText, % TAltEdit, % ArcLine, ahk_class TDLGZIP

Sleep, 50
if ( ArcMove = 1 )
{
 SendMessage, 0x201,,, % TCheckBoxMove, ahk_class TDLGZIP
 SendMessage, 0x202,,, % TCheckBoxMove, ahk_class TDLGZIP
}

Sleep, 50
if ( ArcExe = 1 )
{
 SendMessage, 0x201,,, % TCheckBoxExe, ahk_class TDLGZIP
 SendMessage, 0x202,,, % TCheckBoxExe, ahk_class TDLGZIP
}

Sleep, 50
if ( ArcSepar = 1 )
{
 SendMessage, 0x201,,, % TCheckBoxSep, ahk_class TDLGZIP
 SendMessage, 0x202,,, % TCheckBoxSep, ahk_class TDLGZIP
}

if ( ArcSilent = 1 )
{
 Sleep, 50
 SendMessage, 0x201,,, % TButtonOK, ahk_class TDLGZIP
 SendMessage, 0x202,,, % TButtonOK, ahk_class TDLGZIP
}

Sleep, 50
ExitApp

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Total Commander Send Message function            ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
SendMessageTC(TCMsg, wParam, lParam, aControl)
{
  SendMessage, % TCMsg, % wParam, % lParam, % aControl, % "ahk_id " hw_TTOTAL_CMD
  return ErrorLevel
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; Total Commander Architecture (32 or 64 bit)      ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
SetTC3264:
if ( A_Is64bitOS = 0 )
  TC3264 := 32
else
{
  WinGet, TCControls, ControlList, % "ahk_id " hw_TTOTAL_CMD
  Loop, Parse, TCControls, `n, `r
  {
    if ( A_LoopField ~= "ListBox(1|2|3)" )
    {
      TC3264 := A_LoopField ~= "TMyListBox(1|2|3)" ? 32 : 64
      break
    }
  }
}
Return
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;

_________________
Win11 x64 Eng | TC DreamLair eternal pre-α
View user's profile Send private message Visit poster's website ICQ Number


Powered by phpBB © 2001, 2005 phpBB Group