Orion9

|
Posted: Mon Jun 23, 2025 00:32 Post subject: |
|
|
Loopback wrote: | На полную версию пока изменений не хватает |
Зато хватает, чтобы потестировать объект Callback )
 Hidden text Code: | RegisterCommand 60025 "WindowTest"
Static hWnd = 0
Const PBM_SETPOS = 1026, _
PBM_SETRANGE = 1025, _
PBS_MARQUEE = 0x08, _
PBM_SETMARQUEE = 1034
Const TD_WARNING_ICON = 65535, _
TD_ERROR_ICON = 65534, _
TD_INFORMATION_ICON = 65533, _
TD_SHIELD_ICON = 65532
Const TDCBF_OK_BUTTON = 1, _
TDCBF_YES_BUTTON = 2, _
TDCBF_NO_BUTTON = 4, _
TDCBF_CANCEL_BUTTON = 8, _
TDCBF_RETRY_BUTTON = 0x10, _
TDCBF_CLOSE_BUTTON = 0x20
Global g_WndProc, g_Task = 0
Global oWP = Callback("TestWinProc", "hwnd;uint;wparam;lparam")
Func WindowTest()
RunThread WinTest
EndFunc
Func TestWinProc(hWnd, uMsg, wParam, lParam)
Static WM_CLOSE = 0x0010
#OutputDebugString("Autorun: " & uMsg)
If uMsg = WM_CLOSE Then
If DllCall("DestroyWindow", "handle", hWnd) Then
g_Task = 0
EndIf
Return 0
EndIf
Return DllCall("CallWindowProcW", _
"ptr", g_WndProc, "hwnd", hWnd, "uint", uMsg, "wparam", wParam, "lparam", lParam)
EndFunc
Func WinTest()
If hWnd > 0 Then
If WinGetState(1, hWnd) Then
SendMessage(hWnd, 0x0010, 0, 0)
Return
EndIf
hWnd = 0
Endif
hWnd = DllCall("CreateWindowExW", _
"dword", 0, _
"wstr", "msctls_progress32", _
"wstr", "", _
"dword", 0x10C80000, _
"int", 200, "int", 100, "int", 300, "int", 50, _
"handle", AUTORUN_TCHANDLE, _
"handle", 0, "handle", 0, "ptr", 0, _
"handle")
If hWnd = 0 Then Return
g_WndProc = DllCall("SetWindowLong" & (auX64 ? "PtrW" : "W"), _
"hwnd", hWnd, _
"int", -4, _
"long_ptr", oWP.Ptr)
#DllCall("SetWindowLong" & (auX64 ? "PtrW" : "W"), "hwnd", hWnd, "int", -16, "long_ptr", 0x10C00000)
hIco = SendMessage(AUTORUN_TCHANDLE, 0x7f, 2, 0)
SendMessage(hWnd, 0x80, 0, hIco)
WinSetStyle(PBS_MARQUEE, 2, hWnd)
WinSetText("Estimating...", hWnd)
g_Task = 1
SendMessage(hWnd, PBM_SETMARQUEE, 1, 0)
For i = 1 to 15
Sleep(100)
If g_Task = 0 Then Break
Next
If g_Task > 0 Then
SendMessage(hWnd, PBM_SETMARQUEE, 0, 0)
WinSetStyle(PBS_MARQUEE, 4, hWnd)
SendMessage(hWnd, PBM_SETPOS, 0, 0)
For i = 1 to 10
SendMessage(hWnd, PBM_SETPOS, i*10, 0)
WinSetText("Processed " & i*10 & "%", hWnd)
Sleep(300)
If g_Task = 0 Then Break
Next
EndIf
If g_Task = 0 Then
MsgBox("Операция прервана", "", 48)
Else
If DllCall("DestroyWindow", "handle", hWnd) Then hWnd = 0
MsgBox("Операция успешно завершена", "", 64)
EndIf
EndFunc
|
Сделано, конечно, немножко криво, но это только для теста. Всё работает. Однако TCx64 при вызове WindowTest валится. В чём может быть проблема?
Также сделал функцию на волшебный хинт в целях демонстрации, но TCx64 при его вызове тоже валится, хотя в 32-битной версии всё работает. Валится на третьем шаге, т.е. на вызове функции из DLL по адресу, а не по имени:
 Hidden text Code: | Func MagicHint(FileName, FieldIndex, UnitIndex)
Local bCaps = DllCall("GetKeyState", "int", 0x14, "short")
Local b_CTRL = BitAND(bCaps, 1), b_Shift = IsPressed(0x10)
If Not b_CTRL then b_CTRL = IsPressed (0x11)
If Not b_CTRL Then Return
Static Pipe, Idx = 0, _
sPath = COMMANDER_PATH & "\Ini\Tools\Libs\", _
sLang ="file://" & sPath & "ru.csv", _
sHint ="file://" & sPath & "hint.txt", _
sLib = "MediaInfo" & (auX64 ? "" : "_i386") & ".dll", _
hLib = DllCall("LoadLibrary", "Wstr", sPath & sLib, "Ptr"), _
pNew, pOpen, pDel, pOpt, pInfo
OutputDebugString("Autorun: 1")
If hLib = 0 And FieldIndex > 1 Then Return
If FieldIndex = 1 Then
If hLib = 0 Then Return "Error LoadLibrary " & sLib
Idx = 0
pNew = DllCall("GetProcAddress", "Ptr", hLib, "Str", "MediaInfo_New", "Ptr")
pOpen = DllCall("GetProcAddress", "Ptr", hLib, "Str", "MediaInfo_Open", "Ptr")
pDel = DllCall("GetProcAddress", "Ptr", hLib, "Str", "MediaInfo_Delete", "Ptr")
pOpt = DllCall("GetProcAddress", "Ptr", hLib, "Str", "MediaInfo_Option", "Ptr")
pInfo = DllCall("GetProcAddress", "Ptr", hLib, "Str", "MediaInfo_Inform", "Ptr")
OutputDebugString("Autorun: 2")
Local hMI = DllCall(pNew, "Ptr")
If hMI = 0 Then Return "MediaInfo_New couldn't create new object"
OutputDebugString("Autorun: 3")
If DllCall(pOpen, 'Ptr', hMI, "Wstr", FileName, "Uint") <> 1 Then
DllCall(pDel, "Ptr", hMI)
Return "MediaInfo_Open couldn't open file " & FileName
EndIf
OutputDebugString("Autorun: 4")
Local x, y, w, bHint = 0
Local hWnd = RequestInfo(ItemAtCursor("panel"))
WinGetPos("", "", "w", "", hWnd)
If w > 0 Then
MouseGetPos("x","y")
Static buf = Buffer(8) # POINT
buf.Zero()
buf.SetNum(0, "long", x, "long", y)
DllCall("ScreenToClient", "hwnd", hWnd, "ptr", buf.ptr)
x = buf.GetNum(0)
Switch Round(x/w*100,0)
Case 1 To 10
b_SHIFT = 1
Case 10 To 90
Case 90 To 100
bHint = true
EndSwitch
EndIf
DllCall(pOpt, 'Ptr', hMI, "Wstr", "Language", "Wstr", sLang, "Wstr")
If b_Shift Then
DllCall(pOpt, 'Ptr', hMI, "Wstr", "Complete", "Wstr", "1", "Wstr")
Else
DllCall(pOpt, 'Ptr', hMI, "Wstr", "Complete", "Wstr", "0", "Wstr")
EndIf
If bHint Then
DllCall(pOpt, "Ptr", hMI, "Wstr", "Output", "Wstr", sHint, "Wstr")
Else
DllCall(pOpt, "Ptr", hMI, "Wstr", "Output", "Wstr", "", "Wstr")
EndIf
Pipe = DllCall(pInfo, 'Ptr', hMI, "Uint", 0, "Wstr")
DllCall(pDel, "Ptr", hMI)
If IsPressed(0x5B) Then Idx = 50
Endif
Return TrimSpaces(StrPart(Pipe, auLF, FieldIndex + Idx))
EndFunc |
А так всё работает. Код стал более компактным и чистым. Для работы требуется прописать в autorun.cfg поля:
 Hidden text Code: | Pragma AutorunPluginFields "C1:::MagicHint" "C2:::MagicHint" "C3:::MagicHint" "C4:::MagicHint" "C5:::MagicHint" "C6:::MagicHint" "C7:::MagicHint" "C8:::MagicHint" "C9:::MagicHint" "C10:::MagicHint" "C11:::MagicHint" "C12:::MagicHint" "C13:::MagicHint" "C14:::MagicHint" "C15:::MagicHint" "C16:::MagicHint" "C17:::MagicHint" "C18:::MagicHint" "C19:::MagicHint" "C20:::MagicHint" "C21:::MagicHint" "C22:::MagicHint" "C23:::MagicHint" "C24:::MagicHint" "C25:::MagicHint" "C26:::MagicHint" "C27:::MagicHint" "C28:::MagicHint" "C29:::MagicHint" "C30:::MagicHint" "C31:::MagicHint" "C32:::MagicHint" "C33:::MagicHint" "C34:::MagicHint" "C35:::MagicHint" "C36:::MagicHint" "C37:::MagicHint" "C38:::MagicHint" "C39:::MagicHint" "C40:::MagicHint" "C41:::MagicHint" "C42:::MagicHint" "C43:::MagicHint" "C44:::MagicHint" "C45:::MagicHint" "C46:::MagicHint" "C47:::MagicHint" "C48:::MagicHint" "C49:::MagicHint" "C50:::MagicHint" "C51:::MagicHint" "C52:::MagicHint" "C53:::MagicHint" "C55:::MagicHint" "C55:::MagicHint" "C56:::MagicHint" "C57:::MagicHint" "C58:::MagicHint" "C59:::MagicHint" "C60:::MagicHint" |
И две вспомогательные функции:
 Hidden text Code: | Func TrimSpaces(String)
Local a, b
If Not StrPos(String, ":") Then Return String
a = StrPart(String, ":", 1)
b = StrPart(String, ":", 2) & StrPart(String, ":", 3)
Return StrTrim(a) & ": " & FixCP(StrTrim(b))
EndFunc
Func FixCP(String)
If MediaInfoLock = 0 Then Return String
Local bUsedRepl
Local nSize = StrLen(String)
Local buf = Buffer(nSize)
buf.Zero()
# iso-8859-1 = 28591
DllCall("WideCharToMultiByte", _
"uint", 28591, _
"dword", 0, _
"wstr", String, _
"int", -1, _
"ptr", 0, _
"int", 0, _
"ptr", 0, _
"bool*", @bUsedRepl)
If bUsedRepl Then Return String
DllCall("WideCharToMultiByte", _
"uint", 28591, _
"dword", 0, _
"wstr", String, _
"int", -1, _
"ptr", buf.ptr, _
"int", nSize, _
"ptr", 0, _
"ptr", 0)
Local fixed = buf.GetStr(0, nSize, "ANSI")
Free(buf)
Return fixed
EndFunc
|
А также файл hint.txt положить в папку MediaInfo и путь в скрипте поменять:
 Hidden text Code: | General;Name: %FileName%.%FileExtension%\r\nSize: %FileSize/String4%\r\n[Duration: %Duration%]\r\n[Duration: %Duration/String1%]\r\n[Duration: %Duration/String5%]\r\n[General: %BitRate/String%][(%BitRate_Mode%)][, %Format%][(%Format/Family%)]$if(%Cover%,\, Cover)[, %Width%x%Height%pix][, AR:%AspectRatio%=~%AspectRatio/String%][, %Channel(s)%ch][, %Resolution/String%][, %FrameRate/String%][, %SamplingRate/String%][, %Bits-(Pixel*Frame)%bpf][, %Language%]\r\n
Video;Video #%StreamKindID%: [%Width%x%Height%pix][, AR:%AspectRatio%=~%AspectRatio/String%][, %Resolution/String%][, %FrameRate/String%][, %BitRate/String%][(%BitRate_Mode%)][, %Bits-(Pixel*Frame)%bpf][, %Format%][(%Format/Family%)][, %Language%][, %Channel(s)%ch][, %SamplingRate/String%]\r\n
Audio;Audio #%StreamKindID%: [%Channel(s)%ch][, %Resolution/String%][, %SamplingRate/String%][, %BitRate/String%][(%BitRate_Mode%)][, %Format%][(%Format/Family%)][, %Format_Profile%][, %Language%][, %Width%x%Height%pix][, AR:%AspectRatio%=~%AspectRatio/String%][, %FrameRate/String%][, %Bits-(Pixel*Frame)%bpf]\r\n
;
Text;Text #%StreamKindID%: %Format%[(%Format/Family%)][@%Language%][, %StreamSize/String4%][, %BitRate/String%][(%BitRate_Mode%)][, %Width%x%Height%pix][, AR:%AspectRatio%=~%AspectRatio/String%][, %Channel(s)%ch][, %Resolution/String%][, %FrameRate/String%][, %SamplingRate/String%][, %Bits-(Pixel*Frame)%bpf]\r\n
Chapters;Chapters #%StreamKindID%: %Format%[(%Format/Family%)][@%Language%][, %Total% entries][, %StreamSize/String4%][, %BitRate/String%][(%BitRate_Mode%)][, %Width%x%Height%pix][, AR:%AspectRatio%=~%AspectRatio/String%][, %Channel(s)%ch][, %Resolution/String%][, %FrameRate/String%][, %SamplingRate/String%][, %Bits-(Pixel*Frame)%bpf]\r\n
;
Image;Image #%StreamKindID%: [%Width%x%Height%pix][, AR:%AspectRatio%=~%AspectRatio/String%][, %Resolution/String%][, %FrameRate/String%][, %StreamSize/String4%][, %BitRate/String%][(%BitRate_Mode%)][, %Bits-(Pixel*Frame)%bpf][, %Format%][(%Format/Family%)][, %Language%][, %Channel(s)%ch][, %SamplingRate/String%]\r\n
;
Menu;Menu #%StreamKindID%: [%MenuID/String%][, %Duration% Format:%Format/String%]
; |
Будут вызываться три разные подсказки в зависимости от позиции указателя на панели. Но данные подсказки выбраны только в качестве демонстрации, на самом деле подсказки могут быть совершенно любыми. |
|