Orion9

|
Posted: Tue Sep 30, 2025 20:07 Post subject: |
|
|
Ну сказать. Loopback просто вынудил затянуть пояса и сделать хотя бы тестовую версию поиска недокаченных торрентов.
 Hidden text Code: | RegisterCommand 70504 "FindTorrentParts"
Func FindTorrentParts(lParam)
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
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 bSpeed Then
T3 = GetUptime()
If Round(T3 - T2, 0) > 250 Then
WinSetText(sRes, h_WinFindTorr)
T2 = T3
EndIf
Else
WinSetText(sRes, h_WinFindTorr)
EndIf
aQuery.Text = FileFindEv('*\"' & sRes & '"', "", "")
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, "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 & 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
Func ShowRedHint(HintText)
SetHintParam("ShowHint", "Font", 15, "Arial")
SetHintParam("ShowHint", "BackColor", 0xFF0000)
SetHintParam("ShowHint", "Text", 0xFFFFFF)
ShowHint(HintText, "", "", 1000, 1)
WinAlign(LAST_HINT_WINDOW)
Sleep(50)
SetHintParam("ShowHint", "Reload")
EndFunc |
Полный модуль с оригинальным примером от Loopback.
 Torrent.aucfg Code: | #Pragma IncludeOnce
# 70500-70599
RegisterCommand 70500 "TorrentFindData" 0
RegisterCommand 70501 "TorrentFindData" 1
RegisterCommand 70502 "GoToPathFromTextFile"
RegisterCommand 70503 "ToggleEverything"
RegisterCommand 70504 "FindTorrentParts"
RegisterCommand 70505 "TorrentSize"
Global gTorrentSize = 0, gTorrentCount = 0, gDriveInclude = "e:\;f:\;g:\;h:\;i:\;j:\"
Global h_WinFindTorr = 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()
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
While g_FindTorrTask
Sleep(50)
Wend
h_WinFindTorr = 0
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
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"
If Not BitAND(DllCall("GetKeyState", "int", 0x14, "short"), 1) Then
MsgBox("Поиск данных торрента:" & auCRLF & auCRLF & _
"Имя: " & name & auCRLF & _
"Размер: " & size & auCRLF & _
"Файлов: " & files & auCRLF & auCRLF & _
"Диски поиска: " & gDriveInclude & auCRLF & auCRLF & _
"Продолжить?", "Autorun", 3+32+0)
If EXTENDED <> 6 Then Return
Endif
aFound.Count = 0
gTorrentSize = size
h_WinFindTorr = 0
gTorrentCount = 0
RunThread "WinFindTorrentData"
While g_FindTorrTask = 0
Sleep(50)
Wend
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 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
MsgBox("Найдено: " & gTorrentCount & auCRLF & auCRLF & found, "Autorun", 64)
Else
If BitAND(DllCall("GetKeyState", "int", 0x14, "short"), 1) 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)
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
# original function by Loopback
Func TorrentInfo(sFile)
Static aFixed = List('Name', 'TotalSize', 'FileCount', 'BlockSize', 'BlockCount', _
'Created', 'Creator', 'Hash', 'Comment', 'Encoding', _
'Multifile', 'PrivateTorrent', 'Publisher', 'PublisherURL')
Static aMulti = List('Tracker', 'Webseed', 'Error', 'File', '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
Local hHandle = DllCall(sLibName & "\TorrentOpen", "wstr", sFile, "handle")
If hHandle = 0 Then
DllCall("FreeLibrary", "handle", hDll)
Return
EndIf
Local nCount, sRes
For i = 0 to aFixed.Count - 1
sRes = DllCall(sLibName & "\TorrentGet", "handle", hHandle, "wstr", aFixed[i], "int", i, "wstr")
OutputDebugString(aFixed[i] & ": " & sRes)
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)
Next
Next
DllCall(sLibName & "\TorrentClose", "handle", hHandle)
DllCall("FreeLibrary", "handle", hDll)
EndFunc
Func FindTorrentParts(lParam)
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
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 bSpeed Then
T3 = GetUptime()
If Round(T3 - T2, 0) > 250 Then
WinSetText(sRes, h_WinFindTorr)
T2 = T3
EndIf
Else
WinSetText(sRes, h_WinFindTorr)
EndIf
aQuery.Text = FileFindEv('*\"' & sRes & '"', "", "")
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, "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 & 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
Func ShowRedHint(HintText)
SetHintParam("ShowHint", "Font", 15, "Arial")
SetHintParam("ShowHint", "BackColor", 0xFF0000)
SetHintParam("ShowHint", "Text", 0xFFFFFF)
ShowHint(HintText, "", "", 1000, 1)
WinAlign(LAST_HINT_WINDOW)
Sleep(50)
SetHintParam("ShowHint", "Reload")
EndFunc |
 Кнопка TOTALCMD#BAR#DATA
70504
%COMMANDER_EXE%
Поиск торрент-данных по имени
-1
Возможно, не самый лучший и быстрый алгоритм, но зато простой в реализации и рабочий. Пока работает только с Everything и проверяет данные только по именам файлов без учета их размера. Соответственно, найти достоверный Blue-Ray таким образом вряд ли получится из-за слишком большого процента совпадения между именами файлов в разных раздачах. Но какую-то пользу можно попробовать извлечь из журнала операции, где сохраняются Топ-5 вероятных путей и полный список найденных файлов. CapsLock работает как и прежде. При влюченом CapsLock будет автопереход к первому вероятному пути, т.е. пути, где найдено больше всего имен из торрента. Большое количество файлов в торрент-файле может увеличить время поиска. Если запустить поиск на таком файле, результатов можно не дождаться ) В будущих версиях надо над этим подумать.
A55555
Вы пользуетесь готовой сборкой. Возможно, там уже назначена комбинация Alt+F12 или еще какие-то настройки влияют. Сказать трудно. |
|