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: Выделение файлов через один 
Author Message
LonerD



PostPosted: Thu Aug 04, 2016 01:01    Post subject: Reply with quote

Благодаря новым возможностям ТС9 удалось значительно сократить и оптимизировать скрипт.

Code:
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Total Commander DreamLair
; Script: Zebra file selection
; Скрипт: Выделение файлов зеброй
; Script version: 4.0 (2016.08.04)
; Required: Total Commander 9.0+
; Script author: LonerD
; Made in Donetsk People's Republic
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Parameters:
;    1) Selection mode:
;       1 - all; 2 - only files; 3 - only dirs
;    2) Selection position:
;       1 - begin from first file; 2 - from second etc
;       0 - begin from file under cursor
;    3) Selection range:
;       2 - each second file, 3 - each third file etc
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Параметры:
;    1) Метод выделения:
;       1 - всё; 2 - только файлы; 3 - только каталоги
;    2) Позиция выделения:
;       с какого файла начинать (с первого, второго и т.д...)
;       0 - начинать с файла под курсором
;    3) Порядок выделения:
;       2 - каждый второй файл, 3 - каждый третий и т.д....
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#NoEnv
#NoTrayIcon
#MaxMem 1024
#SingleInstance force
SetBatchLines, -1

Mode = %1%
First = %2%
Range = %3%

If 0 < 3
  Range = 2
If 0 < 2
  First = 1
If Mode not in 1,2,3
  Mode = 1

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

ClipSaved := ClipboardAll
Clipboard := ""

DllCall("LockWindowUpdate", "uint", hw_TTOTAL_CMD)

SendMessage, 1075, 524,,, % "ahk_id " hw_TTOTAL_CMD
SendMessage, 1075, 330 . Mode,,, % "ahk_id " hw_TTOTAL_CMD

TCAPanel := SendMessageTC(1074, 1000, 0, A)
hw_TCAPanel := SendMessageTC(1074, 8+TCAPanel, 0, A)

SelItems := SendMessageTC(1074, 1004+TCAPanel, 0, A)
if ( SelItems = 0 )
  Goto, Exit

SendMessage, 1075, 2018,,, % "ahk_id " hw_TTOTAL_CMD
FileList := Clipboard
Clipboard := ""

ControlGetText, TCAPanelPath,, % "ahk_id " hw_TCAPanel
TCAPanelPath := StrReplace(TCAPanelPath, "\*.*", "\")
FileList := StrReplace(FileList, TCAPanelPath)
IsUpDir := SendMessageTC(1074, 1008+TCAPanel, 0, A)

if ( First = 0 )
{
  FirstFile := SendMessageTC(1074, 1010+TCAPanel, 0, A)
  FirstSelFile := SendMessageTC(1074, 1006+TCAPanel, 0, A)

  if (( Mode = 3 ) & ( FirstSelFile >= FirstFile ))
  {
    SendMessage, 1075, 524,,, % "ahk_id " hw_TTOTAL_CMD
    Goto, Exit
  }
  else if ((( FirstSelFile = 0 ) & ( IsUpDir = 1)) || (( Mode = 2 ) & ( FirstSelFile < FirstFile )))
    FirstSelFile := 1
}
else
  FirstSelFile := First

FileListSel := ""
Loop, Parse, FileList, `n, `r
{
  if ( Mod(A_Index - FirstSelFile + IsUpDir,Range) = 1 )
    FileListSel := FileListSel "`r`n" A_LoopField
}

Clipboard := FileListSel
SendMessage, 1075, 2033,,, % "ahk_id " hw_TTOTAL_CMD

Exit:
Clipboard := ClipSaved
ClipSaved := ""
FileList := ""
FileListSel := ""
DllCall("LockWindowUpdate", "uint", 0)
ExitApp

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SendMessageTC(TCMsg, wParam, lParam, aControl)
{
  SendMessage, % TCMsg, % wParam, % lParam, % aControl, % "ahk_id " hw_TTOTAL_CMD
  return ErrorLevel
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


_________________
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