Orion9

|
Posted: Sat Oct 04, 2025 00:40 Post subject: |
|
|
A55555 wrote: | Ошибку при запуске поиска выкинуло |
Типичная ошибка ночных версий ) Вместо
Code: | sDbg = Round(j/(nCount-1)*100,0) & '% - ' |
должно быть
Code: | sDbg = Round((j+1)/nCount*100,0) & '% - ' |
Исправил первым делом. Хотя изменений еще много. Судя по скрину, вы подключили модуль - правильно сделали, теперь обновляться будет легче.
A55555 wrote: | спасибо, но стартовать не успевает, поставил буквально в самое начало функции запуск |
А зачем вам запускать и выгружать Everything в каждой операции? Меня не напрягает ручное включение и выключение. Но в обновленном модуле предусмотрел такую опцию.
Code: | Global gEvPath = COMMANDER_PATH & "\Everything.exe", gEvAuto = 0, gEvDelay = 100 |
Если gEvAuto = 1, то будет автозапуск и выгрузка Everything при каждой операции. gEvDelay - задержка в миллисекундах после запуска на случай, если Everything не успевает стартовать.
Также добавил опцию для CapsLock.
Code: | Global gTorrentDbg = 0, gDbgStep, gCapsReverse = 0 |
gCapsReverse = 1 задает обратное поведение. gTorrentDbg и gDbgStep используются для отладочной информации. Alt+0 - включает и выключает режим отладки, а Alt+Win+0 выводит информацию на экран и копирует ее в буфер. Когда в следующий раз зависнет, не помешает посмотреть на каком шаге зависло.
A55555 wrote: | Да, вроде как сразу распределяет, размер показывает полный, но не на 100% совпадающий с тем что на сайте раздачи указан. |
В клиенте есть опция для полного распределения дискового пространства для новой раздачи сразу после ее старта. На бумаге должно работать, но надо проверять. Могут быть нюансы.
A55555 wrote: | Я больше про то, что функция не найдя по размеру, сама не попыталась найти вторым способом по имени. Или тут имеется ввиду, что они друг без друга не могут в по умолчанию режиме? |
Было отдельно, сейчас немного подправил. Теперь предлагается продолжить с другим режимом, если не было ничего найдено в текущем. Автоперехода между режимами не будет - может произойти прыжок не пойми куда, особенно если искать только по размерам. Какой-никакой контроль со стороны пользователя все-таки нужен.
A55555 wrote: | закрыл, снова запустил, на 58% зависло.
Закрыл 58%, снова запустил, нормально нашло. |
Теперь можно будет перед началом операции включить отладку (Alt+0), и когда зависнет Alt+Win+0. На экране и в буфере будет информация, запостите ее на форум. Последняя версия модуля:
 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"
RegisterCommand 70506 "TorrentFindOptions"
RegisterCommand 70507 "TorrentDebugInfo"
SetHotkeyAction /K:A /H:0 /DM /S TorrentDebugInfo
SetHotkeyAction /K:A /K:W /H:0 /DM /S TorrentFindOptions
Global gEvPath = COMMANDER_PATH & "\Everything.exe", gEvAuto = 0, gEvDelay = 100
Global gTorrentDbg = 0, gDbgStep, gCapsReverse = 0
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
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
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
MsgBox("Найдено: " & gTorrentCount & auCRLF & auCRLF & found, "Autorun", 64)
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)
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', '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", 0, "wstr")
OutputDebugString(aFixed[i] & ": " & sRes)
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)
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)
# модификаторы вызова
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
RunThread "WinFindTorrentData"
While g_FindTorrTask = 0
Sleep(50)
Wend
# локальные переменные
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 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
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 >= 5 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 |
 Hidden text Code: | 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
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 |
|
|