Страница 1 из 1

Автоматизация при работе с торрент файлами

Добавлено: Чт май 14, 2026 12:17
Orion9
Скрипты для поиска локальных торрент-данных и быстрого перехода к найденному. Торрент-данными считаются любые закачанные или частично закачанные данные (раздачи) с торрент-трекеров. Возможен обратный поиск, когда по закачанным данным ищется локальный .torrent файл.

Скрипты написаны на языке плагина Autorun. Присутствует отдельный скрипт для подсчёта размера выделенных .torrent файлов.
Установка Autorun
Для работы рекомендуется установить последнюю версию плагина. На данный момент это 2.2.21.3 (15.10.2025)

Инструкция по установке плагина
https://total.darkhost.ru/wiki/doku.php?id=ru:autorun

Особенности последней версии. Для версии 2.2.21.3 нет полного архива с дополнительными модулями (субплагинами) и файлами справки, установку придется проводить в два этапа. Сначала нужно установить версию 2.2.21 от 28.09.2025
https://total.darkhost.ru/files/autorun ... 1_beta.zip
Поверх неё накатить последний модуль от 15.10.2025
https://total.darkhost.ru/files/temp/au ... 251015.zip
Установка TCTorrent
Для работы требуется последняя версия TCTorrent.wdx с поддержкой интерфейса для получения данных из торрент файла:
viewpost.php?p=140436
Установка Everything
Скрипты взаимодействуют с утилитой Everything (версии 1.4.1 или выше). В настройках Everything необходимо включить индексацию размеров файлов и папок: Сервис -> Настройки -> Индексирование.
https://www.voidtools.com/ru-ru/downloads/
Torrent.aucfg

Код: Выделить всё

Pragma IncludeOnce

# 70500-70599

RegisterCommand 70500 "TorrentFindData" 0
RegisterCommand 70501 "TorrentFindData" 1
RegisterCommand 70502 "GoToPathFromTextFile"
RegisterCommand 70503 "ToggleEverything"
RegisterCommand 70504 "FindTorrentParts"
RegisterCommand 70505 "TorrentSize"
RegisterCommand 70506 "TorrentFindOptions"
RegisterCommand 70507 "TorrentDebugInfo"

RegisterCommand 70508 "TorrentBugTest"
RegisterCommand 70509 "SearchForTorrents"

SetHotkeyAction /K:A /H:0 /DM /S TorrentDebugInfo
SetHotkeyAction /K:A /K:W /H:0 /DM /S TorrentFindOptions
SetHotkeyAction /K:A /K:W /H:T /DM /S TorrentFixedInfo

Global gEvPath = COMMANDER_PATH & "\Everything.exe", gEvAuto = 0, gEvDelay = 100

Global gTorrentDbg = 0, gDbgStep, gCapsReverse = 0
Global gTorrentLog, gTorrentUrl, gTorrentUrlClip = 1
Global gTorrentSize = 0, gTorrentCount = 0, gDriveInclude = "e:\;f:\;g:\;h:\;i:\;j:\"

Global h_WinFindTorr = 0, g_WinThread = 0
Global g_WinFindTorr = 0, g_FindTorrTask = 0
Global o_WinFindTorr = Callback("WinFindTorrProc", "hwnd;uint;wparam;lparam")

Func WinFindTorrProc(hWnd, uMsg, wParam, lParam)
    Static WM_CLOSE = 0x0010
    If uMsg = WM_CLOSE Then
       If DllCall("DestroyWindow", "handle", hWnd) Then
          h_WinFindTorr = 0        
          g_FindTorrTask = 0
       EndIf   
       Return 0
    EndIf
    Return DllCall("CallWindowProcW", "ptr", g_WinFindTorr, _
                                      "hwnd", hWnd, "uint", uMsg, "wparam", wParam, "lparam", lParam)
EndFunc

Func WinFindTorrentData(bWhile = 1)
    Local hIco    
    h_WinFindTorr = DllCall("CreateWindowExW", _
                            "dword", 0, _
                            "wstr", "msctls_progress32", _
                            "wstr", "", _
                            "dword", 0x00C80000, _
                            "int", 200, "int", 100, "int", Scale(400), "int", Scale(50), _
                            "handle", AUTORUN_TCHANDLE, _
                            "handle", 0, "handle", 0, "ptr", 0, "handle")
    If h_WinFindTorr = 0 Then Return 0
    
    WinAlign(h_WinFindTorr, 0, DllCall("GetDesktopWindow"))
    WinSetPos("", -Scale(50), "", "", 1, h_WinFindTorr)
    WinSetState(5, h_WinFindTorr)
    
    g_WinFindTorr = DllCall("SetWindowLong" & (auX64 ? "PtrW" : "W"), _
                            "hwnd", h_WinFindTorr, _
                            "int", -4, _
                            "long_ptr", o_WinFindTorr.Ptr, "ptr")
                            
    Static PBS_MARQUEE     =  0x08, _
           PBM_SETMARQUEE  =  1034, _
           WM_GETICON      =  0x7f, _
           WM_SETICON      =  0x80
           
    hIco = SendMessage(AUTORUN_TCHANDLE, WM_GETICON, 2, 0)                     
    SendMessage(h_WinFindTorr, WM_SETICON, 0, hIco)
    
    WinSetStyle(PBS_MARQUEE, 2, h_WinFindTorr)    
    SendMessage(h_WinFindTorr, PBM_SETMARQUEE, 1, 0)
    
    WinSetText("Searching...", h_WinFindTorr)
    
    g_FindTorrTask = 1
    If bWhile Then
       While g_FindTorrTask
           Sleep(50)
       Wend
       h_WinFindTorr = 0
    EndIf   
EndFunc

Func TorrentFindData(lParam, nMode)
    If IsPressed(0x10) And Not nMode Then
       SetTorrentDrives()
       Return
    EndIf
    Local bEverything = nMode
    If h_WinFindTorr Then
       SendMessage(h_WinFindTorr, 0x0010, 0, 0)
       g_FindTorrTask = 0  
       Return
    Endif
    Static buf = Buffer(256)
    buf.Zero()
    Local nSymb = DllCall("GetLogicalDriveStringsW", "dword", buf.size, "ptr", buf.ptr)    
    If Not nSymb Then
       MsgBox("Не удалось получить список логических дисков" & auCRLF "SYSERROR: " & SYSERROR, "Autorun")
       Return
    EndIf
    Static aDrive = List(), aFound = List()
    Local i = 0, sz, sDrives
    aDrive.Count = 0
    While 1
       sDrive = buf.GetStr(i)
       sz = StrLen(sDrive)
       If sz = 0 Then break
       aDrive.add(sDrive)
       i = i + sz*2 + 2
    Wend
    sDrives = aDrive.text
    #MsgBox(sDrives)    
    Local obj = Plugin("TCTorrent")
    If ERROR <> 0 Then
       ShowHint("TCTorrent.wdx plugin error " & ERROR)
       Return
    Endif
    Local lRet = false 
    Local sPath = RequestCopyDataInfo("SP")    
    Local sName = RequestCopyDataInfo("SN")        
    Local sFile = sPath & sName
    If Not FileExist(sFile) Then 
       ShowHint("Файл не существует " & sFile)
       lRet = true
    ElseIf StrPos(FileGetAttr(sFile), "D") Then
       ShowHint("Каталог " & sFile)
       lRet = true
    ElseIf FileGetSize(sFile) > 1024*1024*5 Then
       ShowHint("Размер файла больше 5 Мб " & sFile)
       lRet = true
    Else
       obj.FileName = sFile
       Local name =  obj.GetValue(0)
       Local size = obj.GetValue(2,0)	# size -> bytes       
       Local files = obj.GetValue(1)
       If files < 1 Then
          ShowHint("Файл не является торрент-файлом " & sFile)
          lRet = true        
       EndIf
    Endif
    Free(obj)
    If lRet Then Return
    IniRead gDriveInclude %COMMANDER_INI% "Autorun" "TorrentDrives" %"gDriveInclude"
    Local bCaps = BitAND(DllCall("GetKeyState", "int", 0x14, "short"), 1)
    If gCapsReverse Then bCaps = Not bCaps
    If Not bCaps Then
       MsgBox("Поиск данных торрента:" & auCRLF & auCRLF & _
              "Имя: "    & name & auCRLF & _
              "Размер: " & size & auCRLF & _
              "Файлов: " & files & auCRLF & auCRLF & _ 
              "Диски поиска: " & gDriveInclude & auCRLF & auCRLF & _       
              "Продолжить?", "Autorun", 3+32+0)
       If EXTENDED <> 6 Then Return
    Endif
    If bEverything Then 
       If gEvAuto And Not ProcessExist("Everything.exe") Then 
          ShellExec(gEvPath, "-startup")
          Sleep(gEvDelay)
       EndIf   
    EndIf      
    aFound.Count = 0    
    gTorrentSize = size
    h_WinFindTorr = 0
    gTorrentCount = 0
    RunThread "WinFindTorrentData"
    While g_FindTorrTask = 0
        Sleep(50)
    Wend
    TorrentGetFixed(0, 0, sFile)
    Local found
    If bEverything Then      
       found = FileFindEv("size:" & gTorrentSize, "", "sort:3")
       Local nError = ERROR
       If nError = 1 Then MsgBox("Не найдено окно Everything.")
       If nError = 2 Then MsgBox("Ошибка выполнения запроса к IPC Everything.")  
       If nError > 0 Then 
          g_FindTorrTask = 0
          Return
        EndIf  
    Else   
       For i = 0 to aDrive.Count -1
           If StrPos(gDriveInclude, aDrive[i]) Then
            If files > 1 Then
               found &= FileFind(aDrive[i], "*.*", 1, 2, "PathList", "Func:FindTorrentDir") & auCRLF
            Else
               found &= FileFind(aDrive[i], "*.*", 1, 1, "PathList", "Func:FindTorrentFile") & auCRLF
            EndIf   
           Endif   
       Next
    EndIf   
    found = StrTrim(found)
    aFound.Text = found
    If bEverything Then gTorrentCount = aFound.Count
    If bEverything And gEvAuto Then ShellExec(gEvPath, "-exit")     
    If g_FindTorrTask = 0 Then
       If gTorrentCount = 0 Then
          MsgBox("Поиск отменен" & auCRLF & auCRLF & _
                 "Найдено: " & gTorrentCount & auCRLF & auCRLF & found, "Autorun", 48)
       
       Else
          MsgBox("Поиск отменен" & auCRLF & auCRLF & _
                 "Найдено: " & gTorrentCount & auCRLF & auCRLF & found & auCRLF & auCRLF & _       
                 "Сохранить в текстовый файл?", "Autorun", 3+48+0)
          If EXTENDED = 2 Then Return
          If EXTENDED = 7 Then GoToPathFromMsg(aFound[0])
          If EXTENDED = 6 Then SaveDataPathToText(sFile, found)
       EndIf
    Else 
       g_FindTorrTask = 0
       SendMessage(h_WinFindTorr, 0x0010, 0, 0)
       If DllCall("DestroyWindow", "handle", h_WinFindTorr) Then h_WinFindTorr = 0
       If gTorrentCount = 0 Then
          Local mode = files > 1 ? 0 : 1
          Local sMode = (mode = 0 ? "«Имя и размер»" : "«Только имя»")
          MsgBox("Найдено: " & gTorrentCount & auCRLF & auCRLF & _
                 "Файлов в торренте: " & files & " " & auCRLF & auCRLF & _         
                 "Продолжить в режиме " & sMode & "?", "Autorun", 3+64+0)
             If EXTENDED = 6 Then Return FindTorrentParts(mode)               
       Else
          bCaps = BitAND(DllCall("GetKeyState", "int", 0x14, "short"), 1)
          If gCapsReverse Then bCaps = Not bCaps
          If bCaps Then      
             SetHintParam("ShowHint", "Font", 15, "Arial")
             SetHintParam("ShowHint", "BackColor", 0xFF0000)
             SetHintParam("ShowHint", "Text", 0xFFFFFF)     
             ShowHint("Автопереход к найденному", 0, 0, 1000, 1)
             WinAlign(LAST_HINT_WINDOW)
             Sleep(100)         
             SetHintParam("ShowHint", "Reload")             
             GoToPathFromMsg(aFound[0])
             Return
          EndIf
          MsgBox("Найдено: " & gTorrentCount & auCRLF & auCRLF & found & auCRLF & auCRLF & _       
                 "Сохранить в текстовый файл?", "Autorun", 3+64+0)
          If EXTENDED = 2 Then Return
          If EXTENDED = 7 Then GoToPathFromMsg(aFound[0])
          If EXTENDED = 6 Then SaveDataPathToText(sFile, found)
       EndIf
    EndIf
EndFunc

Func SaveDataPathToText(Filename, DataPath)
     Local file = FileChangeExt(Filename, "txt"), bGoto = false
     If FileExist(file) Then
        MsgBox("Файл существует" & auCRLF & auCRLF & _
                file & auCRLF & auCRLF & "Перезаписать?", "Autorun", 3+32+0)
        If EXTENDED <> 6 Then Return
     EndIf
     FileWrite(file, DataPath)
     #MsgBox("Файл сохранен " & auCRLF & auCRLF & file, "Autorun", 64)
     SetHintParam("ShowHint", "Font", 15, "Arial")
     SetHintParam("ShowHint", "BackColor", 0xFF0000)
     SetHintParam("ShowHint", "Text", 0xFFFFFF)     
     ShowHint("Файл сохранен", 0, 0, 1000, 1)
     WinAlign(LAST_HINT_WINDOW)
     Sleep(100)         
     SetHintParam("ShowHint", "Reload")
     If bGoto Then
        If RequestInfo(1000) = 1 Then
           CommandExec /CD %'file'
        Else
           CommandExec /CD '' %'file'
        Endif
     Endif   
EndFunc

Func GoToPathFromTextFile()
    Local sPath = RequestCopyDataInfo("SP")    
    Local sName = RequestCopyDataInfo("SN")        
    Local sFile = sPath & sName
    If Not FileExist(sFile) Then 
       ShowHint("Файл не существует " & sFile)
       Return
    ElseIf StrPos(FileGetAttr(sFile), "D") Then
       ShowHint("Файл является каталогом " & sFile)
       Return
    ElseIf FileGetExt(sFile) <> "TXT" Then
       ShowHint("Расширение файла не .txt " & sFile)
       Return
    ElseIf FileGetSize(sFile) > 1024*2 Then
       ShowHint("Размер файла больше 2 Кб " & sFile)
       Return       
    EndIf
    Local txt = FileRead(sFile)
    Local target = StrPart(txt, auCRLF, 1)
    If target <> "" Then
       GoToPathFromMsg(target)
    Else   
       ShowHint("Пустой путь" & target)  
    EndIf    
EndFunc

Func GoToPathFromMsg(Target)
    If FileExist(Target) Then
       If RequestInfo(1000) = 2 Then
          CommandExec /CD %'Target'
       Else
          CommandExec /CD '' %'Target'
       Endif
       SendCommand(4006)
       If StrPos(FileGetAttr(Target), "D") Then SendCommand(2002)
       Local ForceRedraw = 0
       If ForceRedraw Then
          WinRedraw(1)
          SendCommand(540)     # cm_RereadSource
       EndIf
    Else
       ShowHint("Путь не существует " & Target)
    EndIf    
EndFunc

Func FindTorrentFile(file)
    Static T1 = GetUptime()
    If Not g_FindTorrTask Then Return 0
    If Round(GetUptime() - T1, 0) > 200 Then 
       WinSetText(" [" & gTorrentCount & "] " & file.FullPath, h_WinFindTorr)
       T1 = GetUptime()
       Sleep(5)
    EndIf         
    If file.size = gTorrentSize Then 
       gTorrentCount += 1
       Return 1
    EndIf
    Return 2
EndFunc

Func FindTorrentDir(file)
    Static T2 = GetUptime()
    If Not g_FindTorrTask Then Return 0
    If Round(GetUptime() - T2, 0) > 200 Then 
       WinSetText(" [" & gTorrentCount & "] " & file.FullPath, h_WinFindTorr)
       T2 = GetUptime()
       Sleep(5)
    EndIf   
    Local sz = FileFind(file.FullPath, "*.*", 1, 0, "TotalSize")  
    If sz = gTorrentSize Then 
       gTorrentCount += 1
       Return 1
    EndIf    
    Return 2
EndFunc

Global gVbsInputBox

Func SetTorrentDrives()
    Local out, drives, vbs
    
    IniRead drives %COMMANDER_INI% "Autorun" "TorrentDrives" %"gDriveInclude"    
    vbs = '/c ECHO Wscript.Echo Inputbox("Search on these disks:","Autorun","' & drives & '")>%TEMP%\~auto_0001.vbs'
    
    ProcessExecGetOutput out %COMSPEC% %vbs%
    
    gVbsInputBox = 1
    RunThread("WinVbsInputBoxActivate")
    ProcessExecGetOutput /OEM out "cscript.exe" "/nologo ~auto_0001.vbs" %TEMP%
    gVbsInputBox = 0
    
    out = StrTrim(out)
    If out = "" Then Return
    
    IniWrite %COMMANDER_INI% "Autorun" "TorrentDrives" %out%
    Sleep(50)
    MsgBox("Ключ сохранен.", "Autorun", 64)           
EndFunc

Func WinVbsInputBoxActivate()
    Local hVbs
    While gVbsInputBox
        hVbs = WinFind(0, "#32770", "Autorun")
        If hVbs > 0 Then
           WinSetState(23, hVbs)
           Break
        EndIf
        Sleep(50)
    Wend
EndFunc

Func TorrentSize(lParam)
    Local T1 = GetUptime()
    Local obj = Plugin("TCTorrent")
    If ERROR <> 0 Then
       ShowHint("TCTorrent.wdx plugin error " & ERROR)
       Return
    Endif
    Local size = 0, files = 0
    Local aSel = List()
          aSel.Text = GetSelectedItems(3, 0)       
    Local sPath = RequestCopyDataInfo("SP")    
    Local sName = RequestCopyDataInfo("SN")        
    Local sFile = sPath & sName
    Local lRet = false
    If aSel.Count = 0 Then
       If Not FileExist(sFile) Then 
          ShowHint("Файл не существует " & sFile)
          lRet = true
       ElseIf StrPos(FileGetAttr(sFile), "D") Then
          ShowHint("Каталог " & sFile)
          lRet = true       
       Else
          obj.FileName = sFile
          files = obj.GetValue(1)
          size = obj.GetValue(2,0)	# size -> bytes
          Free(obj)
       Endif
    EndIf
    If lRet Then
       Free(obj, aSel)
       Return
    EndIf
    If aSel.Count > 10 Then
       ShowHint("Выделено: " & aSel.Count & auCRLF & "Подсчёт времени...")
    EndIf    
    Local j, k = 0, dirs = 0, torrs = 0
    If aSel.Count > 0 Then
       For j = 0 To aSel.Count - 1
          sFile = sPath & aSel[j]
          If FileExist(sFile) Then 
             k += 1
             If Not StrPos(FileGetAttr(sFile), "D") Then
               obj.FileName = sFile
               s = obj.GetValue(2,0)
               If s > 0 Then 
                  size += s
                  files += obj.GetValue(1)
                  torrs += 1 
               Endif  
             Else   
               dirs += 1
             Endif   
          EndIf
       Next
       sName = "S/A: " & aSel.Count & "/" & k	# Selected / Available
    Else
       SetHintParam("ShowHint", "Font", 10, "")
       ShowHint("" & sName & auCRLF & _
                "Размер: " & SizeFormat(size, 1, 'G', 2, 1) & auCRLF & _
                "Файлов: " & files)
       Sleep(100)
       SetHintParam("ShowHint", "Reload")
       Free(aSel)
       Return
    EndIf
    Local tl = Round(GetUptime() - T1, 0) / 1000
    SetHintParam("ShowHint", "Font", 10, "")
    ShowHint((k = aSel.Count ? "" : "Файл " & sName & auCRLF) & _
             "Элементов: " & aSel.Count & auCRLF & _
             "Обработано: " & torrs & auCRLF & _
             "Каталогов: " & dirs & auCRLF & _              
             "Размер: " & SizeFormat(size, 0, 'M', 2) & auCRLF & _
             "Размер: " & SizeFormat(size, 0, 'G', 2) & auCRLF & _
             "Размер: " & SizeFormat(size, 0, 'T', 4) & auCRLF & _
             "Файлов: " & files & auCRLF & _                       
             "Powered by TCTorrent.wdx" & auCRLF & _
             "Время операции: " &  StrFormat("%.3f", tl) & " sec")
    Sleep(100)
    SetHintParam("ShowHint", "Reload")          
    Free(obj, aSel)
EndFunc

Func ToggleEverything()    
    If Not ProcessExist("Everything.exe") Then
       CommandExec em_everything
    Else
       CommandExec em_everything_exit
    Endif    
EndFunc 

Func TerminateEverything()
    CommandExec em_everything_exit
EndFunc

Func TorrentBugTest(lParam)
    RunThread("TorrentThreadTest")
EndFunc

Func TorrentThreadTest()
    Local out, tor, vbs
    tor = "d:\Temp\Jinn'sLiveUSB 11.2.2.torrent"
    vbs = '/c ECHO Wscript.Echo Inputbox("Torrent file for testing:","Autorun","' & tor & '")>%TEMP%\~auto_0002.vbs'    
    ProcessExecGetOutput out %COMSPEC% %vbs%
    
    gVbsInputBox = 1
    RunThread("WinVbsInputBoxActivate")
    ProcessExecGetOutput /OEM out "cscript.exe" "/nologo ~auto_0002.vbs" %TEMP%
    gVbsInputBox = 0
    
    out = StrTrim(out)
    If out = "" Then Return
    If Not FileExist(out) Then 
       MsgBox("File doesn't exist " & out)
       Return
    EndIf
    
    Local hIco = 0   
    Local hWnd = DllCall("CreateWindowExW", _
                         "dword", 0, _
                         "wstr", "msctls_progress32", _
                         "wstr", "", _
                         "dword", 0x00C80000, _
                         "int", 200, "int", 100, "int", Scale(400), "int", Scale(50), _
                         "handle", AUTORUN_TCHANDLE, _
                         "handle", 0, "handle", 0, "ptr", 0, "handle")
    If hWnd = 0 Then Return 0
    
    WinAlign(hWnd, 0, DllCall("GetDesktopWindow"))
    WinSetPos("", -Scale(50), "", "", 1, hWnd)
    WinSetState(5, hWnd)
                                
    Static PBS_MARQUEE     =  0x08, _
           PBM_SETMARQUEE  =  1034, _
           WM_GETICON      =  0x7f, _
           WM_SETICON      =  0x80
           
    hIco = SendMessage(AUTORUN_TCHANDLE, WM_GETICON, 2, 0)                     
    SendMessage(hWnd, WM_SETICON, 0, hIco)
    
    WinSetStyle(PBS_MARQUEE, 2, hWnd)    
    SendMessage(hWnd, PBM_SETMARQUEE, 1, 0)
    For i = 1 To 500
        TorrentInfo(hWnd, i, out)
        If WinGetState(1, hWnd) = 0 Then
           MsgBox("Тестирование прервано", "Autorun", 48)
           Return
        EndIf
    Next    
    MsgBox("Тестирование успешно завершено", "Autorun", 64)
    DllCall("DestroyWindow", "handle", hWnd)
EndFunc

# original function by Loopback
Func TorrentInfo(hWnd, nPass, sFile)
    Static aFixed = List('Name', 'TotalSize', 'FileCount', 'BlockSize', 'BlockCount', _
                         'Created', 'Creator', 'Hash', 'Comment', 'Encoding', _
                         'Multifile', 'PrivateTorrent', 'Publisher', 'PublisherURL')
    Static aMulti = List('Tracker', 'Webseed', 'Error', 'CustomField')

    Static sLibName = "TCTorrent.wlx" & (auX64 ? "64" : "")
    Static sLibPath = COMMANDER_PATH & "\Plugins\wlx\TCTorrent\" & sLibName

    Local hDll = DllCall("LoadLibrary", "wstr", sLibPath, "handle")
    If hDll = 0 Then Return MsgBox("Can't load " & sLibPath)

    Local hHandle = DllCall(sLibName & "\TorrentOpen", "wstr", sFile, "handle")
    If hHandle = 0 Then
        DllCall("FreeLibrary", "handle", hDll)
        Return MsgBox("Can't open " & sFile)
    EndIf

    Local nCount, sRes

    For i = 0 to aFixed.Count - 1
        sRes = DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", aFixed[i], "int", 0, "wstr")
        OutputDebugString(aFixed[i] & ": " & sRes)
        WinSetText(nPass & ": " & sRes, hWnd)
    Next

    OutputDebugString(auCRLF & 'Files:')
    nCount = DllCall(sLibName & "\TorrentCountGet", "handle", hHandle, "wstr", "File", "uint")
    For j = 0 To nCount - 1
        sRes = StrFormat("[%12s] %s", _
                 DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", "FileSize", "int", j, "wstr"), _
                 DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", "File", "int", j, "wstr"))
        OutputDebugString(sRes)
        WinSetText(nPass & ": " & sRes, hWnd)
    Next

    For i = 0 to aMulti.Count - 1
        OutputDebugString(auCRLF & aMulti[i] & 's:')
        nCount = DllCall(sLibName & "\TorrentCountGet", "handle", hHandle, "wstr", aMulti[i], "uint")
        For j = 0 To nCount - 1
            sRes = DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", aMulti[i], "int", j, "wstr")
            OutputDebugString(sRes)
            WinSetText(nPass & ": " & sRes, hWnd)
        Next
    Next

    DllCall(sLibName & "\TorrentClose", "handle", hHandle)
    DllCall("FreeLibrary", "handle", hDll)
EndFunc 

#Func FindTorrentParts(lParam)
#    RunThread "ThreadTorrentParts" lParam
#EndFunc

Func FindTorrentParts(lParam)
    # модификаторы вызова
    Local b_CTRL = IsPressed (0x11), b_Shift = IsPressed (0x10)
    If lParam = 1 Then b_CTRL = true
    If lParam = 2 Then b_Shift = true    
    
    # повторный вызов при запущенной задаче
    If h_WinFindTorr Then
       SendMessage(h_WinFindTorr, 0x0010, 0, 0)
       g_FindTorrTask = 0  
       Return
    Endif
    
    If gEvAuto And Not ProcessExist("Everything.exe") Then 
       ShellExec(gEvPath, "-startup")
       Sleep(gEvDelay)       
    Endif
    
    # имя файла под курсором
    Local sPath = RequestCopyDataInfo("SP")    
    Local sName = RequestCopyDataInfo("SN")        
    Local sFile = sPath & sName
    
    # файл не существует или является каталогом
    If Not FileExist(sFile) Then 
       ShowHint("File doesn't exist " & sFile)
       Return
    ElseIf StrPos(FileGetAttr(sFile), "D") Then
       ShowHint("Not a torrent file " & sFile)
       Return
    ElseIf FileGetSize(sFile) > 1024*1024*5 Then
       ShowHint("File size > 5 Mb " & sFile)
       Return
    EndIf    
    
    # путь к библиотеке плагина
    Static sLibName = "TCTorrent.wlx" & (auX64 ? "64" : "")
    Static sLibPath = COMMANDER_PATH & "\Plugins\wlx\TCTorrent\" & sLibName

    # не удалось загрузить библиотеку
    Local hDll = DllCall("LoadLibrary", "wstr", sLibPath, "handle")
    If hDll = 0 Then 
       ShowHint("TCTorrent.wlx can't load library " & sLibPath)
       Return
    EndIf    

    # библиотеке не удалось открыть файл
    Local hHandle = DllCall(sLibName & "\TorrentOpen", "wstr", sFile, "handle")
    If hHandle = 0 Then
        ShowHint("TCTorrent.wlx can't open file " & sFile)    
        DllCall("FreeLibrary", "handle", hDll)
        Return
    EndIf
    
    # файл не является торрент-файлом
    Local nFiles
    nFiles = DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", "FileCount", "int", 0, "wstr")
    If nFiles < 1 Then
       ShowHint("Corrupt torrent file " & sFile)
       DllCall(sLibName & "\TorrentClose", "handle", hHandle)       
       DllCall("FreeLibrary", "handle", hDll)       
       Return             
    EndIf  
    
    # окно прогресса операции
    h_WinFindTorr = 0
    If g_WinThread Then 
       RunThread "WinFindTorrentData"
       While g_FindTorrTask = 0
           Sleep(50)
       Wend
    Else
        WinFindTorrentData(0)
    EndIf
    
    TorrentGetFixed(sLibName, hHandle, sFile)
    
    # локальные переменные
    Local T1 = GetUptime(), T2 = T1, T3, bSpeed = 0, nRes = 0
    Local bName = Not b_Shift, bSize = Not b_CTRL, sSize, sMode, sMem, sDbg
    Local j, nCount, sRes, nError, sList, sDirs, aQuery = List(), aCount = List()
    
    Static aMode = List("«Имя и размер»", "«Только имя»", "«Только размер»")
    If bName And bSize Then
       nMode = 0
    ElseIf bName Then
       nMode = 1    
    Else
       nMode = 2
    EndIf
    sMode = aMode[nMode]
    
    # количество файлов в торренте
    nCount = DllCall(sLibName & "\TorrentCountGet", "handle", hHandle, "wstr", "File", "uint")

    # перечисление файлов в торренте
    For j = 0 To nCount - 1
        
        If gTorrentDbg Then gDbgStep = "Step 1. TorrentGet j=" & j & auCRLF
        
        # имя файла
        sRes = DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", "File", "int", j, "wstr")
        
        # размер файла
        If bSize Then
           sSize = DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", "FileSize", "int", j, "wstr")
        EndIf
        
        sDbg = Round((j+1)/nCount*100,0) & '% - '
        If gTorrentDbg Then
           nRes += StrLen(sRes) + 8
           sMem = StrLen(sList) + StrLen(sDirs) + nRes
           sDbg &= SizeFormat(sMem*2, 1, 'G', 2) &  ' - '        
        EndIf

        If gTorrentDbg Then gDbgStep &= "Step 2. WinSetText " & sRes & auCRLF
        
        # меньше сообщений окну прогресса
        If bSpeed Then
           T3 = GetUptime()
           If Round(T3 - T2, 0) > 250 Then 
              WinSetText(sDbg & sRes, h_WinFindTorr)
              T2 = T3
           EndIf
        Else
           WinSetText(sDbg & sRes, h_WinFindTorr)
        EndIf

        If gTorrentDbg Then gDbgStep &= "Step 3. FileFindEv " & sRes & auCRLF
        
        # запрос к Everything
        If bName And bSize Then
           aQuery.Text = FileFindEv('*\"' & sRes & '" size:' & sSize, "", "")
        ElseIf bName Then
           aQuery.Text = FileFindEv('*\"' & sRes & '"', "", "")        
        Else
           aQuery.Text = FileFindEv('size:' & sSize, "", "")
        EndIf
                
        # ошибка запроса
        nError = ERROR
        If nError > 0 Then Break

        If gTorrentDbg Then gDbgStep &= "Step 4. aCount.Add" & auCRLF
        
        # обработка запроса
        aCount.Add("[" & aQuery.Count & "] " & sRes)        
        If aQuery.Count > 0 Then 
           If gTorrentDbg Then gDbgStep &= "Step 5. sList" & auCRLF
           sList &= aQuery.Text & auCRLF
           If gTorrentDbg Then gDbgStep &= "Step 6. sDirs" & auCRLF
           If nFiles > 1 Then 
              If gTorrentDbg Then gDbgStep &= "Step 7. StrReplace" & auCRLF
              sDirs &= StrReplace(aQuery.Text, sRes, "") & auCRLF
           Else
              sDirs &= aQuery.Text & auCRLF
           EndIf
        Else
           If gTorrentDbg Then 
              gDbgStep &= "Step 5. Skip" & auCRLF
              gDbgStep &= "Step 6. Skip" & auCRLF
              gDbgStep &= "Step 7. Skip" & auCRLF              
           EndIf             
        EndIf  

        If gTorrentDbg Then gDbgStep &= "Step 8. Next"
        #Sleep(3000)
        
        # опрерация прервана закрытием окна прогресса
        If g_FindTorrTask = 0 Then Break
    Next
    
    If gTorrentDbg Then gDbgStep &= "Step 9. Out"
       
    If nError = 1 Then MsgBox("Everything window not found.")
    If nError = 2 Then MsgBox("IPC Everything query execution error.")  
    If nError > 0 Then 
       g_FindTorrTask = 0
       SendMessage(h_WinFindTorr, 0x0010, 0, 0)       
       Free(aCount, aQuery)
       DllCall(sLibName & "\TorrentClose", "handle", hHandle)
       DllCall("FreeLibrary", "handle", hDll)           
       Return
    EndIf

    Local c = 0, m = Map(), top5 = List(), sTop5, bDirs = StrLen(StrTrim(sDirs))
    
    # суммирование путей при непустом результате
    If g_FindTorrTask And bDirs Then 
       aQuery.Text = sDirs
       For value In aQuery
           c = 1
           If m.Has(value) Then c += m.Get(value)
           m.Set(value, c)
       Next
    EndIf
    
    # сортировка путей по убыванию
    If g_FindTorrTask And bDirs Then
       top5.SortMethod = 1 
       For key, value In m          
           top5.Add("[" & value & "]" & Chr(160) & key)
       Next
       top5.Sort(1)
       
       # выбор верхних пяти путей
       For j = 0 To top5.Count - 1
          sTop5 &= top5[j] & auCRLF
          If j >= 4 Then Break
       Next   
    EndIf
    
    c = top5.Count
    Local top1, files = aCount.Text
    If c > 0 Then top1 = StrTrim(StrPart(top5[0], Chr(160), 2))

    # освобождение объектов и библиотеки    
    Free(aCount, aQuery, top5, m)    
    DllCall(sLibName & "\TorrentClose", "handle", hHandle)
    DllCall("FreeLibrary", "handle", hDll)
    
    # время операции    
    T2 = Round(GetUptime() - T1, 0) / 1000
    T3 = "Время поиска: " &  StrFormat("%.3f", T2) & " sec"
    
    If gEvAuto Then ShellExec(gEvPath, "-exit")    
    
    If g_FindTorrTask = 0 Then
       MsgBox("Поиск отменен", "Autorun", 48)
    Else        
       # закрытие окна прогресса
       g_FindTorrTask = 0
       SendMessage(h_WinFindTorr, 0x0010, 0, 0)
       If DllCall("DestroyWindow", "handle", h_WinFindTorr) Then h_WinFindTorr = 0
       
       # ничего не найдено
       If c = 0 Then
          If nMode < 2 Then
             MsgBox("Найдено: " & c & auCRLF & auCRLF & _
                    "Торрент: " & nCount & " файлов" & auCRLF & T3 & auCRLF & _
                    "Режим: " & sMode & auCRLF & auCRLF & _                
                    "Продолжить в режиме " & aMode[nMode+1] & "?", "Autorun", 3+64+0)
             If EXTENDED = 6 Then Return FindTorrentParts(nMode+1)                
          Else
             MsgBox("Найдено: " & c & auCRLF & auCRLF & _
                    "Торрент: " & nCount & " файлов" & auCRLF & T3 & auCRLF & _
                    "Режим: " & sMode, "Autorun", 64)
          EndIf           
       Else          
          # проверка CapsLock
          Local bCaps = BitAND(DllCall("GetKeyState", "int", 0x14, "short"), 1)
          If gCapsReverse Then bCaps = Not bCaps
          If bCaps Then
             ShowRedHint("Автопереход к найденному")
             GoToPathFromMsg(top1)
             Return
          EndIf          
          MsgBox("Найдено: " & c & auCRLF & auCRLF & sTop5 & auCRLF & _
                 "Торрент: " & nCount & " файлов" & auCRLF & T3 & auCRLF & _
                 "Режим: " & sMode & auCRLF & auCRLF & _                
                 "Сохранить в текстовый файл?", "Autorun", 3+64+0)
          If EXTENDED = 2 Then Return
          If EXTENDED = 7 Then GoToPathFromMsg(top1)
          If EXTENDED = 6 Then
             Local txt
             txt &= top1 & auCRLF & auCRLF
             txt &= "-----------------" & auCRLF             
             txt &= "Top 5 locations:" & auCRLF 
             txt &= "-----------------" & auCRLF             
             txt &= sTop5 & auCRLF
             txt &= "-----------------" & auCRLF             
             txt &= "Torrent files:" & auCRLF     
             txt &= "-----------------" & auCRLF             
             txt &= files & auCRLF & auCRLF
             txt &= "-----------------" & auCRLF                          
             txt &= "Full list:" & auCRLF
             txt &= "-----------------" & auCRLF                
             txt &= sList             
             SaveDataPathToText(sFile, txt)
          EndIf   
       EndIf
    EndIf
EndFunc

Func TorrentFindOptions()
     gTorrentDbg = Not gTorrentDbg
     ShowRedHint("Торрент Debug " & (gTorrentDbg ? "включен" : "выключен"))
EndFunc

Func TorrentDebugInfo()
    If Not gTorrentDbg Then gDbgStep = "Торрент Debug выключен"
    If gDbgStep = "" Then gDbgStep = "Empty"
    SetHintParam("ShowHint", "Font", 13, "Arial")
    SetHintParam("ShowHint", "BackColor", 0x000000)
    SetHintParam("ShowHint", "Text", 0xFFFFFF)
    ShowHint(gDbgStep)
    WinAlign(LAST_HINT_WINDOW)    
    ClipPut(gDbgStep)  
    SetHintParam("ShowHint", "Reload") 
EndFunc

Func TorrentGetFixed(TorrLib, TorrHandle, TorrFile)
    Local sRes, sComm, i = 0, bLib = false, hDll
    
    Static aFixed = List('Name', 'TotalSize', 'FileCount', 'BlockSize', 'BlockCount', _
                         'Created', 'Creator', 'Hash', 'Comment', 'Encoding', _
                         'Multifile', 'PrivateTorrent', 'Publisher', 'PublisherURL')
                         
    Static sLibName = "TCTorrent.wlx" & (auX64 ? "64" : "")
    Static sLibPath = COMMANDER_PATH & "\Plugins\wlx\TCTorrent\" & sLibName
                         
    If TorrLib = 0 Then 
       TorrLib = sLibName 
       hDll = DllCall("LoadLibrary", "wstr", sLibPath, "handle")
       If hDll = 0 Then 
          gTorrentLog = "Can't load " & sLibPath
          Return 
       EndIf
       TorrHandle = DllCall(sLibName & "\TorrentOpen", "wstr", TorrFile, "handle")
       If TorrHandle = 0 Then
           DllCall("FreeLibrary", "handle", hDll)
           gTorrentLog = "Can't open " & TorrFile
           Return
       EndIf
       bLib = true
    EndIf   
                             
    gTorrentUrl = DllCall(TorrLib & "\TorrentGet", _
                   "handle", TorrHandle, "wstr", "PublisherURL", "int", 0, "wstr")
    gTorrentLog = "File: "   & TorrFile & auCRLF
    
    For i = 0 to aFixed.Count - 1
        sRes = DllCall(TorrLib & "\TorrentGet", _
               "handle", TorrHandle, "wstr", aFixed[i], "int", 0, "wstr")
        If i = 8 Then sComm = sRes
        gTorrentLog &= aFixed[i] & ": " & sRes & auCRLF
    Next
    
    gTorrentLog = StrTrim(gTorrentLog)
    If StrPos(sComm, "http") Then 
       gTorrentUrl = sComm
    Else
       If Not StrPos(gTorrentUrl, "http") Then gTorrentUrl = "[No valid URL] " & FileGetName(TorrFile)    
    EndIf
    If gTorrentUrlClip Then ClipPut(gTorrentUrl)
    
    If bLib Then
       DllCall(sLibName & "\TorrentClose", "handle", TorrHandle)
       DllCall("FreeLibrary", "handle", hDll)
    EndIf   
EndFunc

Func TorrentFixedInfo()
    If gTorrentLog = "" Then gTorrentLog = "No torrent information"
    SetHintParam("ShowHint", "Font", 13, "Arial")
    SetHintParam("ShowHint", "BackColor", 0x000000)
    SetHintParam("ShowHint", "Text", 0xFFFFFF)
    ShowHint(gTorrentLog)
    WinAlign(LAST_HINT_WINDOW)
    ClipPut(gTorrentUrl)  
    SetHintParam("ShowHint", "Reload") 
EndFunc

SetHotkeyAction /K:A /H:9 SearchForTorrents

Func SearchForTorrents()
    Local sTorDirs = COMMANDER_PATH & "\Ini\Torrent.txt"
    Local sPath = RequestCopyDataInfo("SP")    
    Local sName = RequestCopyDataInfo("SN")        
    Local sFile = sPath & sName
    If Not FileExist(sFile) Then 
       ShowHint("Файл не существует " & sFile)
       Return
    EndIf
    If Not FileExist(sTorDirs) Then 
       ShowHint("Файл не существует " & sTorDirs)
       Return
    EndIf    
    Static aTorDirs = List()
    aTorDirs.Count = 0
    aTorDirs.LoadFromFile(sTorDirs)
    If aTorDirs.Count = 0 Then
       MsgBox("Файл не содержит данных." & auCRLF & auCRLF & sTorDirs, "Autorun", 48)
       Return
    EndIf
    Local sLegit, sIgnore
    For i = 0 To aTorDirs.Count - 1
       sDir = aTorDirs[i]
       If FileExist(sDir) And StrPos(FileGetAttr(sDir), "D") Then
          sLegit &= sDir & auCRLF
       Else
          sIgnore &= sDir & auCRLF           
       EndIf
    Next
    sLegit = StrTrim(sLegit)
    sIgnore = StrTrim(sIgnore)
    If sLegit = "" Then
       MsgBox("Нет существующих путей." & auCRLF & auCRLF & sTorDirs, "Autorun", 48)
       Return
    EndIf
    Local sTorrs
    aTorDirs.Count = 0    
    aTorDirs.Text = sLegit
    For i = 0 To aTorDirs.Count - 1
       sTorrs &= StrTrim(FileFind(aTorDirs[i], "*.torrent", 0)) & auCRLF  
    Next
    sTorrs = StrTrim(sTorrs)    
    If sTorrs = "" Then
       sTorrs = "Каталоги поиска: " & auCRLF & sLegit & auCRLF & auCRLF & _
              (sIgnore = "" ? "" : "Не существуют: " & auCRLF & sIgnore)
       MsgBox("Не найдены .torrent файлы." & auCRLF & auCRLF & sTorrs, "Autorun", 48)
       Return
    EndIf
    Local obj = Plugin("TCTorrent")
    If ERROR <> 0 Then
       MsgBox("TCTorrent.wdx plugin error " & ERROR, "Autorun", 48)
       Return
    Endif    
    Local lst = List(), sFound = ""
    lst.Text = sTorrs
    WinFindTorrentData(0)
    Local size
    If StrPos(FileGetAttr(sFile), "D") Then
       Sleep(10)
       WinSetText("Подсчёт размера...", h_WinFindTorr)
       size = FileFind(sFile, "*.*", 1, 0, "TotalSize")
    Else   
       size = FileGetSize(sFile) 
    EndIf
    For i = 0 To lst.Count - 1
       WinSetText(lst[i], h_WinFindTorr)
       obj.FileName = lst[i]
       If size = obj.GetValue(2,0) Then
          sFound = lst[i]
          Break
       EndIf
       If g_FindTorrTask = 0 Then Break
    Next
    Free(lst, obj)
    If g_FindTorrTask = 0 Then 
       MsgBox("Операция прервана", "Autorun", 48)
       Return
    EndIf   
    g_FindTorrTask = 0
    SendMessage(h_WinFindTorr, 0x0010, 0, 0)     
    If sFound = "" Then
       MsgBox("Не найдено." & auCRLF & auCRLF & _
              "Каталоги поиска: " & auCRLF & sLegit & auCRLF & auCRLF & _
              (sIgnore = "" ? "" : "Не существуют: " & auCRLF & sIgnore & auCRLF & auCRLF) & _              
              "Файлов .torrent: " & i & auCRLF & auCRLF & _
              "Искомый объект: " & auCRLF & sFile & auCRLF & _
              "Размер: " & size & " байт" & auCRLF & auCRLF & _
              "Искать по имени и размеру?", "Autorun", 3+0+48)
       If EXTENDED <> 6 Then Return
       If StrPos(FileGetAttr(sFile), "D") Then
          MsgBox("Объект является каталогом. Поиск по имени и размеру доступен только для файлов.", "Autorun", 48)
          Return
       EndIf
       sFound = DeepSearchForTorrents(sFile, sTorrs)
       If sFound = "" Then Return
    EndIf
    Local bUseEm = 1   
    ShowRedHint("Автопереход к найденному")
    If bUseEm Then
       SetEnv("COMMANDER_GOTO", sFound)
       CommandExec("em_torrents_goto")
       #CommandExec("em_torrents_goto", sFound)
    Else
       GoToPathFromMsg(sFound)
       If FileExist(sFound) Then SendCommand(2002)    
    EndIf
EndFunc

Func DeepSearchForTorrents(sFile, sTorrs)
    Static sLibName = "TCTorrent.wlx" & (auX64 ? "64" : "")
    Static sLibPath = COMMANDER_PATH & "\Plugins\wlx\TCTorrent\" & sLibName
    Local hDll = DllCall("LoadLibrary", "wstr", sLibPath, "handle")
    If hDll = 0 Then 
       MsgBox("Can't load " & sLibPath, "Autorun", 48)
       Return 
    EndIf
    WinFindTorrentData(0)
    Local nSkip = 0, nError = 0, sName, sSize, sLog
    Local i, j, ht, sTorr, sFound, lst = List(), nCount = 0
    Local name =  FileGetName(sFile), size = FileGetSize(sFile)
    Static sz = List()
    sz.Count = 0
    lst.Text = sTorrs    
    For i = 0 To lst.Count - 1
       sTorr = lst[i]
       WinSetText(sTorr, h_WinFindTorr)
       ht = DllCall(sLibName & "\TorrentOpen", "wstr", sTorr, "handle")
       If ht = 0 Then
          nSkip += 1
          nError += 1
          sLog &= "Can't open " & sTorr & auCRLF
          Continue
       EndIf    
       nCount = DllCall(sLibName & "\TorrentCountGet", "handle", ht, "wstr", "File", "uint")
       If nCount < 2 Then
          nSkip += 1       
          If nCount < 1 Then
             nError += 1
             sLog &= "Corrupt " & sTorr & auCRLF
          Else           
             sLog &= "Single " & sTorr & auCRLF
          EndIf   
          DllCall(sLibName & "\TorrentClose", "handle", ht)
          Continue
       EndIf  
       For j = 0 To nCount - 1
          sName = DllCall(sLibName & "\TorrentGet", "handle", ht, "wstr", "File", "int", j, "wstr")
          sSize = DllCall(sLibName & "\TorrentGet", "handle", ht, "wstr", "FileSize", "int", j, "wstr") 
          If size = sSize Then             
             If name = FileGetName(sName) Then
                sFound = sTorr
                Break
             EndIf
             If sz.IndexOf(sTorr) = -1 Then sz.Add(sTorr)
          EndIf   
          If g_FindTorrTask = 0 Then Break          
       Next
       DllCall(sLibName & "\TorrentClose", "handle", ht)       
       If sFound <> "" Then Break
       If g_FindTorrTask = 0 Then Break
    Next
    Free(lst)
    If g_FindTorrTask = 0 Then
       DllCall("FreeLibrary", "handle", hDll)    
       MsgBox("Операция прервана", "Autorun", 48)
       Return
    EndIf   
    g_FindTorrTask = 0
    SendMessage(h_WinFindTorr, 0x0010, 0, 0)
    DllCall("FreeLibrary", "handle", hDll)
    If sFound = "" Then
       If sz.Count > 0 Then
          MsgBox("Имя+размер: 0" & auCRLF & _
                 "Только размер: " & sz.Count & auCRLF & auCRLF & _
                 "Файлов: " & i & auCRLF & _
                 "Пропущено: " & nSkip & auCRLF & _
                 "Ошибок: " & nError & auCRLF & auCRLF & _
                 "Искомый файл: " & auCRLF & sFile & auCRLF & _
                 "Размер: " & size & " байт" & auCRLF & auCRLF & _
                 "Перейти к первому «Только размер»?", "Autorun", 3+0+48)
          If EXTENDED <> 6 Then Return
          Return sz[0]
       EndIf
       MsgBox("Не найдено." & auCRLF & auCRLF & _                         
              "Файлов: " & i & auCRLF & _
              "Пропущено: " & nSkip & auCRLF & _
              "Ошибок: " & nError & auCRLF & auCRLF & _                            
              "Искомый файл: " & auCRLF & sFile & auCRLF & _
              "Размер: " & size & " байт" & auCRLF & auCRLF & _
              "Показать пропущенные?", "Autorun", 3+0+48)
       If EXTENDED <> 6 Then Return
       If sLog = "" Then
          MsgBox("Нет пропущенных", "Autorun", 64)       
       Else
          MsgBox(sLog, "Autorun", 64)
       EndIf                
       Return
    EndIf
    Return sFound
EndFunc
Functions.aucfg
Модуль использует две дополнительные функции, которые можно подключить отдельно, либо добавить в сам модуль

Код: Выделить всё

Func GetDPI()
    Local DC = DllCall("GetDC", "int", 0)
    Local lpy = DllCall("GetDeviceCaps", "handle", DC, "int", 88) # LOGPIXELSX
    DllCall("ReleaseDC", "int", 0, "handle", DC)
    Return lpy
EndFunc

Func Scale(nValue)
    Static dpi = GetDPI()
    Return DllCall("MulDiv", "int", nValue, "int", dpi, "int", 96)
EndFunc 
Подключение к autorun.cfg

Код: Выделить всё

Pragma AutorunBlockUnload

LoadLibrary Plugins\Autorun_Tweaks.dll
LoadLibrary Plugins\Autorun_Sysinfo.dll
LoadLibrary Plugins\Autorun_Runtime.dll
LoadLibrary Plugins\Autorun_Process.dll

Pragma Include %COMMANDER_PATH%\wdx\Autorun\Torrent.aucfg

Pragma AutorunFinalizeSection
Описание модуля
Основная задача модуля — поиск данных. Поиск работает в обе стороны: 1) поиск торрент-данных по торрент-файлу; 2) поиск торрент-файла по торрент-данным. Можно искать как файлы, так и папки.

При поиске торрент-данных возможно сохранить найденные пути в текстовый файл или сразу перейти к первому найденному варианту при нажатии кнопки "Нет". Текстовый файл сохраняется с тем же именем, что и торрент-файл. Находясь на этом файле, можно выполнить команду с кодом 70502 — первый путь в файле откроется на противоположной панели. Код команды можно использовать в кнопке на панели инструментов или в специальной em_команде для более удобного и быстрого вызова.

Все команды модуля:

70500 - Поиск торрент-данных по размеру
70501 - Поиск торрент-данных по размеру с использованием Everything

Код 70500 с модификатором Shift вызывает окно с полем редактирования, где указывается на каких дисках будет производится поиск. Строка сохраняется в wincmd.ini в секцию Autorun:

[Autorun]
TorrentDrives=e:\;f:\;g:\;i:\;j:\

Для обеих команд 70500 и 70501 действует модификатор CapsLock. При включеном CapsLock начало операции поиска и переход к найденнным данным происходит автоматически без отображения диалоговых окон. Такое поведение можно зафиксировать в глобальной переменной gCapsReverse: gCapsReverse = 1 включает обратное поведение CapsLock.

70503 - Запускает или закрывает приложение Everything

Путь к приложению указывается в заголовке модуля в переменной gEvPath. Переменные gEvAuto и gEvDelay отвечают за автозапуск приложения и задержку перед его запуском во время операций поиска.

70504 - Поиск частично закаченных данных (раздач).

При поиске частично закаченных данных действуют модификаторы Ctrl и Shift. Вызов команды без модификаторов запускает поиск по именам и размерам файлов в раздаче (перебирается содержимое .torrent файла). Ctrl - Только по именам файлов. Shift - Только по размерам.

70505 - Подсчёт размера .torrent файлов. Работает с выделенными на панели файлами.

Команды 70506 и 70507 используются для отладки. Alt+Win+0 включает режим отладки, Alt+0 выводит информацию на экран и копирует ее в буфер. Отладка доступна только для кода 70504, указанные комбинации прописаны в модуль через SetHotkeyAction.

70508 - Тест для проверки устойчивости
70509 - Поиск торрент-файлов по торрент-данным

Для поиска торрент-файлов (*.torrent) необходимо создать текстовый файл %COMMANDER_PATH%\Ini\Torrent.txt, где будут перечислены пути поиска (торрент-файлы не ищутся по всем дискам и каталогам, как это происходит при поиске торрент-данных). Например:

d:\Portable\uTorrent\torrents
d:\Temp\Test
d:\Temp
d:\Temp\Software
d:\Test\TorrentData

Глубина каталогов при этом не учитывается, пути к файлам .torrent должны быть перечислены в этом файле отдельно для каждой папки.

В модуле действует комбинация Alt+Win+T. Эта комбинация показывает подсказку о последнем запущенном .torrent файле и копирует в буфер ссылку из полей "PublisherURL" или "Comment".
usercmd.ini
Все коды команд можно использовать в кнопках, но для ускорения работы можно создать специальные em_команды и назначить им горячие клавиши. Пример использования:

[em_torrent_data_search]
cmd=70500

[em_torrent_data_everything]
cmd=70501

[em_torrent_data_goto_txt]
cmd=70502

[em_torrent_data_name_size]
cmd=70504

[em_torrent_data_options]
cmd=70506

[em_torrent_data_dbginfo]
cmd=70507

[em_torrents_search]
cmd=70509

[em_torrents_goto]
cmd=cm_FocusTrg,em_commander_cd

[em_commander_cd_param]
cmd=CD
param=?%A0

[em_commander_cd]
cmd=CD %COMMANDER_GOTO%

[em_everything]
cmd=%COMMANDER_PATH%\Utilites\Everything\Everything.exe
param=-startup

[em_everything_exit]
cmd=%COMMANDER_PATH%\Utilites\Everything\Everything.exe
param=-exit

[em_everything_toggle]
cmd=70503
Wincmd.ini

Код: Выделить всё

[Shortcuts]
A+T=em_torrent_data_search
A+E=em_torrent_data_everything
A+N=em_torrent_data_name_size
CA+N=em_torrent_data_name_size
SA+N=em_torrent_data_name_size
A+P=em_torrent_data_goto_txt
A+M=em_torrents_search
CA+M=em_torrents_search
CA+E=em_everything_toggle
Для поиска торрент-данных необходимо выполнить код нужной команды (70500, 70501 или 70504), находясь на .torrent файле. Для поиска торрент-файла необходимо выполнить команду 70509, находясь на искомом файле или папке. Для подсчета размера используется команда 70505.
70500
TOTALCMD#BAR#DATA
70500

%COMMANDER_EXE%
Поиск данных торрент-файла|Shift - Выбор дисков для поиска|CapsLock - Автопереход к найденому

0
-1
70501
TOTALCMD#BAR#DATA
70501

%COMMANDER_EXE%
Поиск торрент-данных c Everything|CapsLock - Автопереход к найденому

0
-1
70502
TOTALCMD#BAR#DATA
70502

%COMMANDER_EXE%
Переход к данным из текстового файла

0
-1
70503
TOTALCMD#BAR#DATA
70503

%COMMANDER_EXE%
Everything

0
-1
70504
TOTALCMD#BAR#DATA
70504

%COMMANDER_EXE%
Поиск торрент-данных|По именам и размерам файлов|Ctrl - Только по именам файлов|Shift - Только по размерам

0
-1
70505
TOTALCMD#BAR#DATA
70505

%COMMANDER_EXE%
Подсчёт размера .torrent файлов


-1
70509
TOTALCMD#BAR#DATA
70509

%COMMANDER_EXE%
Поиск торрент-файлов по торрент-данным


-1