Leaderboard
Popular Content
Showing content with the highest reputation on 04/12/2025 in Posts
-
This is a spin off the thread from here. I've moved this out of the collab space so I don't feel guilty about making sweeping changes when the mood hits me. But I'm still more than happy for this to be a community project at heart. Just a quick comment about the code: for this API, it looks like we need to construct some objects internally, which is a bit of a learning curve - but hopefully this example will provide a bit of background as to whats happening there... Original Attempt: Updated example 20/4 - Load media file, progress/seek bar. PlayerDemo 1.1.zip3 points
-
So hopefully there's a better way of doing this, but I was pretty happy when this actually worked! We've been looking at some MediaFoundation stuff recently - and in order to spin up the MFMediaEngine object you must provide an interface to handle callbacks. Basically you are meant to write your own handler with an IMFEventNotify interface, then pass it to the factory. But how do you do this in AutoIt? Well it seems you can dodgy something up! IMFEventNotify object inherits from IUnknown has 1 method of its own - EventNotify . write the 4 methods and throw them into memory with DllCallbackRegister. Grab all the function pointers and pop them into an array. You now have yourself a vtable. The pointer to a vtable is an interface ptr. And that is a COM object! #include <WinAPI.au3> Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}" Global Const $sIID_IMFMediaEngineNotify = "{fee7c112-e776-42b5-9bbf-0048524e2bd5}" Global Const $tag_IMFMediaEngineNotify = "EventNotify hresult(uint; ulong_ptr; uint);" ;The Obj will look like this in memory. ;Only 2 interfaces are supported, IUnknown, and one derived from IUnknown. - They both can coexist in the one place ;for a more complex object we might need to store the locations of multiple vtables, and return the correct one with QueryInterface. ; - pIface -> +- pVtab -> +- pQueryInterface ; | | ; +- iRefCnt +- pAddRef ; | ; +- pRelease ; | ; +- pEventNotify Local $tEventNotify_QI = DllCallbackRegister("IMFEventNotiy_QueryInterface", "long", "ptr;ptr;ptr") Local $tEventNotify_AR = DllCallbackRegister("IMFEventNotiy_AddRef", "long", "ptr") Local $tEventNotify_R = DllCallbackRegister("IMFEventNotiy_Release", "long", "ptr") Local $tEventNotify_EN = DllCallbackRegister("IMFEventNotiy_EventNotify", "long", "ptr;dword;dword_ptr;dword") Local $tIMFMediaEngineNotify_Vtab = DllStructCreate("ptr pQueryInterface;ptr pAddRef;ptr pRelease;ptr pEventNotify") $tIMFMediaEngineNotify_Vtab.pQueryInterface = DllCallbackGetPtr($tEventNotify_QI) $tIMFMediaEngineNotify_Vtab.pAddRef = DllCallbackGetPtr($tEventNotify_AR) $tIMFMediaEngineNotify_Vtab.pRelease = DllCallbackGetPtr($tEventNotify_R) $tIMFMediaEngineNotify_Vtab.pEventNotify = DllCallbackGetPtr($tEventNotify_EN) Local $tIMFMediaEngineNotify = DllStructCreate("ptr pVTab;int iRefCnt") $tIMFMediaEngineNotify.pVtab = DllStructGetPtr($tIMFMediaEngineNotify_Vtab) Func IMFEventNotiy_QueryInterface($pThis, $pIID, $ppObj) ; hResult = oThis.QueryInterface(In pIID, Out pObj*) Local $hResult = $S_OK If Not $ppObj Then Return $E_POINTER Local $tRetObj = DllStructCreate("ptr pObj", $ppObj) ;pObj is ByRef, so ppObj should always be provided. Switch _WinAPI_StringFromGUID($pIID) ;These interfaces are located where we currently are! ;So return ptr to self. Case $sIID_IMFMediaEngineNotify, $sIID_IUnknown $tRetObj.pObj = $pThis IMFEventNotiy_AddRef($pThis) Case Else $tRetObj.pObj = 0 $hResult = $E_NOINTERFACE EndSwitch Return $hResult EndFunc ;==>IMFEventNotiy_QueryInterface Func IMFEventNotiy_AddRef($pThis) ; iRefCnt = oThis.AddRef() Local $tThis = DllStructCreate("ptr VTab;int RefCnt", $pThis) $tThis.RefCnt += 1 Return $tThis.RefCnt EndFunc ;==>IMFEventNotiy_AddRef Func IMFEventNotiy_Release($pThis) ;iRefCnt = oThis.Release() Local $tThis = DllStructCreate("ptr VTab;int RefCnt", $pThis) $tThis.RefCnt -= 1 ;I guess we could probably do some cleanup once RefCnt = 0. ;Not sure how best to do that!. Return $tThis.RefCnt EndFunc ;==>IMFEventNotiy_Release ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Define Event handler. Func IMFEventNotiy_EventNotify($pThis, $iEvent, $iParam1, $iParam2) ConsoleWrite(StringFormat("EventRecieved! Event: %d, Param1: %d, Param2: %d", $iEvent, $iParam1, $iParam2) & @CRLF) EndFunc ;==>IMFEventNotiy_EventNotify ;Ready to go! Local $pIMFMediaEngineNotify = DllStructGetPtr($tIMFMediaEngineNotify) ; Interface ptr (to IMFMediaEngineNotify) IMFEventNotiy_AddRef($pIMFMediaEngineNotify) ;The oject exists in mem, so refCnt should start at 1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Local $oIMFMediaEngineNotify = ObjCreateInterface($pIMFMediaEngineNotify, $sIID_IMFMediaEngineNotify, $tag_IMFMediaEngineNotify) ConsoleWrite("IsObj($oIMFMediaEngineNotify) = " & IsObj($oIMFMediaEngineNotify) & @CRLF & @CRLF) ;Test some methods. - Get IUnknown Iface, then "release" it. ConsoleWrite("QueryInterface Test:" & @CRLF) Local $pIUnknown, $tGUID = _WinAPI_GUIDFromString($sIID_IUnknown) $oIMFMediaEngineNotify.QueryInterface(DllStructGetPtr($tGUID), $pIUnknown) ConsoleWrite(StringFormat("$pIUnknown = %s", Ptr($pIUnknown)) & @CRLF) Local $oIUnknown = ObjCreateInterface($pIUnknown, $sIID_IUnknown, "") ConsoleWrite("RefCnt = " & $oIUnknown.Release() & ", .Release()" & @CRLF & @CRLF) ;Test external Addref call. ConsoleWrite("AddRef Test:" & @CRLF) ConsoleWrite("RefCnt = " & $oIMFMediaEngineNotify.AddRef() & ", .AddRef()" & @CRLF) ConsoleWrite("RefCnt = " & $oIMFMediaEngineNotify.Release() & ", .Release()" & @CRLF & @CRLF) ;Send an event. ConsoleWrite("EventNotify Test:" & @CRLF) $oIMFMediaEngineNotify.EventNotify(1, 2, 3)2 points
-
I think it is best for you to start a new thread. Knowing that it is a legacy engine, not sure I will continue in this path. Unless someone wants to add content to the current state of the code, I would consider the thread closed.2 points
-
A simple help request
argumentum reacted to TheSaint for a topic
That worked too, once I added in the two functions created by ChatGPT.1 point -
It's a watery based version of ChatGPT in bathers or swimsuit.1 point
-
1 point
-
Okay, I've now done away with the previously required Python executable and code. Thanks to my persistence and the heavy lifting of ChatGPT, we finally wrestled a solution using pure AutoIt to get the correct numbered sub-folders for cover images for an ebook. You can read about some of that here. NOTE - This was based on some Python code I found in a file of my calibre install. The original Python script can be found in the Other Dependencies.zip file. See the first post for the updated downloads. The Other Dependencies.zip file is now around 7 MB smaller. P.S. Please note that this has had minimal testing so far.1 point
-
Yep, I get the same with my version of AutoIt, so it looks like ChatGPT once again is talking out of its posterior. THANKS.1 point
-
Ok, that's good to know. I was doing some more reading last night, and it seems this example uses a legacy component for the renderer - the EVR (Enhanced Video Renderer) . Apparently we're now supposed to use IMediaEngine, which exposes a Simple Video Renderer (SVR). So that seems to be a whole different thing. God knows why MS is so intent on reinventing the wheel with these apis! https://learn.microsoft.com/en-us/windows/win32/medfound/enhanced-video-renderer I'll leave it up to @Nine as to the scope of this thread. Considering we sortof have something working here with MediaSession- maybe we should start a new thread for MediaEngine. No doubt Nine will have something to share around media capture at some point too!1 point
-
I was wondering how to create an Application Bar that would be recognized by the system. Searching on the forum here revealed that there was a few attempts of doing so but none was successful. So here a working example of how to perform it. Notice how maximized windows are shrunk by the application bar. 😎 #NoTrayIcon ;#AutoIt3Wrapper_UseX64=y #include <GUIConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <TrayConstants.au3> ; #SHAppBarMessage# ============================================================================================================= ; Name ..........: SHAppBarMessage.AU3 ; Description ...: Create an Application Bar recognized by the system ; Author ........: Nine ; Created .......: 2025-04-04 ; Modified ......: ; Remarks .......: ; Example .......: Yes ; =============================================================================================================================== Opt("MustDeclareVars", True) Opt("GUICloseOnESC", False) Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) Global Enum $ABM_NEW, $ABM_REMOVE, $ABM_QUERYPOS, $ABM_SETPOS, $ABM_GETSTATE, $ABM_GETTASKBARPOS, $ABM_ACTIVATE, $ABM_GETAUTOHIDEBAR, _ $ABM_SETAUTOHIDEBAR, $ABM_WINDOWPOSCHANGED, $ABM_SETSTATE Global Enum $ABS_ONTOP, $ABS_AUTOHIDE, $ABS_ALWAYSONTOP Global Enum $ABE_LEFT, $ABE_TOP, $ABE_RIGHT, $ABE_BOTTOM Global Enum $ABN_STATECHANGE, $ABN_POSCHANGED, $ABN_FULLSCREENAPP, $ABN_WINDOWARRANGE Global Const $CALLBACK = $WM_USER + 0x10 Global Const $tagAPPBARDATA = "dword cbSize;hwnd hWnd;uint uCallbackMessage;uint uEdge;" & $tagRECT & ";lparam lParam" Global $idDummy Example() Func Example() Local $tAppBarData = DllStructCreate($tagAPPBARDATA) $tAppBarData.cbSize = DllStructGetSize($tAppBarData) Local $hGUI = GUICreate("", 80, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0x202020) GUISetFont(11, 0, 0, "Comic Sans MS") Local $idHide = GUICtrlCreateButton(" Hide", 5, 5, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 200, 0) Local $idTask = GUICtrlCreateButton(" Task", 5, 40, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 16739, 0) Local $idDo = GUICtrlCreateButton(" Do", 5, 75, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 16802, 0) Local $idDont = GUICtrlCreateButton(" Don't", 5, 110, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 240, 0) Local $idExit = GUICtrlCreateButton(" Exit", 5, 300, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 290, 0) $tAppBarData.hWnd = $hGUI $tAppBarData.uCallbackMessage = $CALLBACK DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_NEW, "struct*", $tAppBarData) AppBarSetPos($tAppBarData) GUIRegisterMsg($CALLBACK, AppBarProc) GUISetState() $idDummy = GUICtrlCreateDummy() While True Switch GUIGetMsg() Case $idExit ExitLoop Case $idDummy AppBarSetPos($tAppBarData) Case $idHide GUISetState(@SW_HIDE) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_REMOVE, "struct*", $tAppBarData) TraySetIcon("shell32.dll", 255) TraySetState($TRAY_ICONSTATE_SHOW) TraySetToolTip("Left click to restore" & @CRLF & "Right click to Exit") Case $idTask ToggleTaskBar() EndSwitch Switch TrayGetMsg() Case $TRAY_EVENT_PRIMARYDOWN GUISetState(@SW_SHOW) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_NEW, "struct*", $tAppBarData) AppBarSetPos($tAppBarData) TraySetState($TRAY_ICONSTATE_HIDE) Case $TRAY_EVENT_SECONDARYUP Exit EndSwitch WEnd DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_REMOVE, "struct*", $tAppBarData) EndFunc ;==>Example Func AppBarSetPos(ByRef $tAppBar) $tAppBar.uEdge = $ABE_LEFT $tAppBar.left = 0 $tAppBar.top = 0 $tAppBar.Right = 80 $tAppBar.Bottom = @DesktopHeight DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_QUERYPOS, "struct*", $tAppBar) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_SETPOS, "struct*", $tAppBar) WinMove($tAppBar.hWnd, "", $tAppBar.Left, $tAppBar.Top, $tAppBar.Right, $tAppBar.Bottom) EndFunc ;==>AppBarSetPos Func ToggleTaskBar() Local $tAppBar = DllStructCreate($tagAPPBARDATA) $tAppBar.cbSize = DllStructGetSize($tAppBar) Local $iState = DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_GETSTATE, "struct*", $tAppBar)[0] $tAppBar.lParam = $iState = $ABS_AUTOHIDE ? $ABS_ALWAYSONTOP : $ABS_AUTOHIDE DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_SETSTATE, "struct*", $tAppBar) EndFunc ;==>ToggleTaskBar Func AppBarProc($hWnd, $iMsg, $wParam, $lParam) If $wParam = $ABN_POSCHANGED Then GUICtrlSendToDummy($idDummy, $wParam) Return $GUI_RUNDEFMSG EndFunc ;==>AppBarProc1 point
-
NotifyIcon UDF (formerly TrayIconEx) - Create, delete and manage self notify icons
pixelsearch reacted to FireFox for a topic
Hi, Here is an UDF to create, delete, set the icon and state, tooltip and tip for your notify icons. The main advantage is that you can handle mouse events as you want, there is no default events. You can create fully customised notifyicons/tooltips. Thanks to Holger Kotsch for his ModernMenu UDF. Note : Breaking changes ! Please use the 1.2+ version. Functions : Attachments : Example + UDF : AutoIt v3.3.10.0+ NotifyIcon_1.2.zip TrayIconEx_1.1.zip AutoIt v3.3.8.0+ TrayIconEx.zip & Requirements : >WinAPIEx UDF. As usual, enjoy !1 point -
ShellExecute('Your Program.exe', '"Your Parameters with Spaces"') Notice the single quotes outside the double quotes1 point
-
Just use commandline parameter. Quick example If $CmdLine[0] <> 0 Then MsgBox(4000, "Drag n Drop Demo", "Dropped file is " & $CmdLine[1]) The script must be compiled1 point