Orion9

|
Posted: Wed Oct 01, 2025 00:30 Post subject: |
|
|
Вот теперь намного лучше. Скидываю обновленную функцию и кнопку.
 Hidden text Code: | Func FindTorrentParts(lParam)
Local b_CTRL = IsPressed (0x11)
If h_WinFindTorr Then
SendMessage(h_WinFindTorr, 0x0010, 0, 0)
g_FindTorrTask = 0
Return
Endif
Local sPath = RequestCopyDataInfo("SP")
Local sName = RequestCopyDataInfo("SN")
Local sFile = sPath & sName
If Not FileExist(sFile) Then
ShowHint("Not exist " & sFile)
Return
ElseIf StrPos(FileGetAttr(sFile), "D") Then
ShowHint("Directory " & 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
If DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", "FileCount", "int", 0, "wstr") < 1 Then
ShowHint("Not torrent file " & sFile)
DllCall("FreeLibrary", "handle", hDll)
Return
EndIf
h_WinFindTorr = 0
RunThread "WinFindTorrentData"
While g_FindTorrTask = 0
Sleep(50)
Wend
Local T1 = GetUptime(), T2 = T1, T3, bSpeed = false, bSize = Not b_CTRL, sSize
Local j, nCount, sRes, nError, sList, sQuery, sDirs, aQuery = List(), aCount = List()
nCount = DllCall(sLibName & "\TorrentCountGet", "handle", hHandle, "wstr", "File", "uint")
For j = 0 To nCount - 1
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
If bSpeed Then
T3 = GetUptime()
If Round(T3 - T2, 0) > 250 Then
WinSetText(sRes, h_WinFindTorr)
T2 = T3
EndIf
Else
WinSetText(sRes, h_WinFindTorr)
EndIf
If bSize Then
aQuery.Text = FileFindEv('*\"' & sRes & '" size:' & sSize, "", "")
Else
aQuery.Text = FileFindEv('*\"' & sRes & '"', "", "")
EndIf
nError = ERROR
If nError > 0 Then Break
aCount.Add("[" & aQuery.Count & "] " & sRes)
If aQuery.Count > 0 Then
sList &= aQuery.Text & auCRLF
sDirs &= StrReplace(aQuery.Text, sRes, "") & auCRLF
EndIf
If g_FindTorrTask = 0 Then Break
Next
T2 = Round(GetUptime() - T1, 0) / 1000
T3 = "Время поиска: " & StrFormat("%.3f", T2) & " sec"
SetHintParam("ShowHint", "Font", 10, "")
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
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 >= 5 Then Break
Next
EndIf
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 top5.Count = 0 Then
MsgBox("Найдено: " & top5.Count & auCRLF & auCRLF & _
"Торрент: " & nCount & " файлов" & auCRLF & T3 & auCRLF & _
"Режим: " & (bSize ? "Имя+размер" : "Только имя"), "Autorun", 64)
Else
Local top1 = StrTrim(StrPart(top5[0], Chr(160), 2))
If BitAND(DllCall("GetKeyState", "int", 0x14, "short"), 1) Then
ShowRedHint("Автопереход к найденому")
GoToPathFromMsg(top1)
Return
EndIf
MsgBox("Найдено: " & top5.Count & auCRLF & auCRLF & sTop5 & auCRLF & _
"Торрент: " & nCount & " файлов" & auCRLF & T3 & auCRLF & _
"Режим: " & (bSize ? "Имя+размер" : "Только имя") & 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 &= aCount.Text & auCRLF & auCRLF
txt &= "-----------------" & auCRLF
txt &= "Full list:" & auCRLF
txt &= "-----------------" & auCRLF
txt &= sList
SaveDataPathToText(sFile, txt)
EndIf
EndIf
EndIf
Free(aCount, aQuery, top5, m)
DllCall(sLibName & "\TorrentClose", "handle", hHandle)
DllCall("FreeLibrary", "handle", hDll)
EndFunc |
 Hidden text TOTALCMD#BAR#DATA
70504
%COMMANDER_EXE%
Поиск торрент-данных|По имени и размеру файлов|Ctrl - Только по имени файлов
-1
Важно! Для работы нужна последняя версия TCTorrent.
Loopback
В последней версии плагина ProcessExecGetOutput сломался. У меня многие функции перестали работать. Такой код возвращает пустой результат:
Code: | global sout
ProcessExecGetOutput /OEM sout %COMSPEC% "/c SET"
msgbox(sout) |
|
|