Jump to content

Gianni

MVPs
  • Posts

    2,701
  • Joined

  • Last visited

  • Days Won

    40

Gianni last won the day on December 27 2025

Gianni had the most liked content!

About Gianni

  • Birthday 05/02/1962

Profile Information

  • Location
    Italy

Recent Profile Visitors

6,202 profile views

Gianni's Achievements

  1. At the following link the "download" button seems to work: https://web.archive.org/web/20210724011512/http://www.thefoolonthehill.net/drupal/AutoIt Debugger
  2. Okay, thanks for the clarification, @MattyD. I'll keep your suggestion in mind. ... I also read some of your interesting topics while searching for a solution on the site. 👍 Bye and thanks again. 👋
  3. Wow! ... so the additional interfaces after the first aren't independent, but must all be chained together to form a larger interface that inherits all the methods of the previous interfaces... Enlightening! Thanks so much, DanyFirex, as always, you're a great help. You're fantastic! 👍
  4. Hello friends In this topic, @LarsJ explained how to implement COM callback interfaces, pointers, and objects. But I'm facing a problem I can't solve right now. The WebView2 component, used as the base product on which @LarsJ's examples are based, is constantly evolving, with new features added with new versions. These additions are made by adding new interfaces. For example, the ICoreWebView2 base interface, which was present when this post was written, has been joined by the ICoreWebView2_2, ICoreWebView2_3, and so on, currently up to ICoreWebView2_28. Well, the problem I'm having is: how can I use the methods of the new interfaces in addition to those in the base interface? For example, the ICoreWebView2_8 interface contains, among others, the get_IsMuted(), put_IsMuted(), get_IsDocumentPlayingAudio() methods, which I'd like to try using as a generic example. I've prepared and simplified one of the scripts from LarsJ's examples to create a lightweight script that hopefully someone brilliant can implement into a working example. To run the script without complications, you must first download the zip file available in first post and unzip it to a folder of your choice, as long as you have write permissions to that folder. Then save the script from this post to the Examples folder present in the unzipped folder and run it. There are two AutoIt buttons overlaying the WebView2 embedded in the page: the one on the left, as an example, uses the basic version of an ICoreWebView2Environment interface to check the installed WebView2 version, while the one on the right contains a snippet that currently doesn't work (lines 87-105) The basic objects: Environment, Controller, and WebView are already instantiated and implemented in the variables $oCoreWebView2Environment, $oCoreWebView2Controller, and $oCoreWebView2. The ICoreWebView2_8 interface declarations have also been inserted at the beginning of the script. The goal now is to make this interface usable. Searching the forum, I found a post by @Danyfirex (Get CLSID from IID - Developer General Discussion - AutoIt Forums) for a similar problem. It seems that the .QueryInterface method on $oCoreWebView2 needs to be used, but my attempts have been unsuccessful. I think the problem may be both in the way I'm trying to make the ICoreWebView2_8 interface operational, and in the type declarations in $dtag_ICoreWebView2_8 on line 19. Any help is welcome, and I thank in advance anyone who knows how to proceed. #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt("MustDeclareVars", 1) #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPICom.au3> #include <WinAPI.au3> Global $hGui ; Project includes #include "..\Includes\WV2Interfaces.au3" Global $dtag_ICoreWebView2Environment_mod = StringReplace($dtag_ICoreWebView2Environment, "get_BrowserVersionString hresult();", "get_BrowserVersionString hresult(wstr*);") ; == ICoreWebView2_8 Interface ==================================================== Global Const $sIID_ICoreWebView2_8 = "{E9632730-6E1E-43AB-B7B8-7B2C9E62E094}" Global Const $dtag_ICoreWebView2_8 = _ "add_IsMutedChanged hresult(ptr*;struct*);" & _ ; ICoreWebView2IsMutedChangedEventHandler *eventHandler, EventRegistrationToken *token "remove_IsMutedChanged hresult(struct);" & _ ; EventRegistrationToken token "get_IsMuted hresult(BOOL*);" & _ ; BOOL *value "put_IsMuted hresult(BOOL);" & _ ; BOOL value "add_IsDocumentPlayingAudioChanged hresult(ptr*;struct*);" & _ ; ICoreWebView2IsDocumentPlayingAudioChangedEventHandler *eventHandler, EventRegistrationToken *token "remove_IsDocumentPlayingAudioChanged hresult(struct);" & _ ; EventRegistrationToken token "get_IsDocumentPlayingAudio hresult(bool);" ; BOOL *value ?? (BOOL* or BOOL) Global $pICoreWebView2_8, $oCoreWebView2_8, $tICoreWebView2_8 Global $tRIID_ICoreWebView2_8 = _WinAPI_GUIDFromString($sIID_ICoreWebView2_8) #cs Global Const $ICoreWebView2_8_Prefix = "CoreWebView2_8_" $pICoreWebView2_8 = ObjectFromTag($ICoreWebView2_8_Prefix, $dtag_ICoreWebView2_8, $tICoreWebView2_8) #ce ; ================================================================================= WebView2() Func WebView2() ; Create WebView2 GUI $hGui = GUICreate("WebView2 Sample", 950, 600, -1, -1, $WS_OVERLAPPEDWINDOW) ; Create AutoIt controls Local $idButton1 = GUICtrlCreateButton("WebView2 version", 10, 150, 170, 40) Local $idButton2 = GUICtrlCreateButton("Test2", 190, 150, 170, 40) Local $idLabelResult = GUICtrlCreateLabel("", 370, 150, 170, 40) ; --- Initialize and embed WebView2 ---------- _WinAPI_CoInitialize($COINIT_APARTMENTTHREADED) CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate(True) CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate(True) Local $hWebView2Loader = DllOpen(@AutoItX64 ? "WebView2Loader-x64.dll" : "WebView2Loader-x86.dll") Local $aRet = DllCall($hWebView2Loader, "long", "CreateCoreWebView2EnvironmentWithOptions", "wstr", "", "wstr", @ScriptDir, _ "ptr", Null, "ptr", $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler) If @error Or $aRet[0] Then Return ConsoleWrite("CreateCoreWebView2EnvironmentWithOptions ERR" & @CRLF) ; -------------------------------------------- ; after above initialization we have 3 main objects: ; $oCoreWebView2Environment ; $oCoreWebView2Controller ; $oCoreWebView2 ; Show WebView2 GUI GUISetState(@SW_SHOW) Local $vReturnedValue ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESIZED, $GUI_EVENT_RESTORE Local $tRect = _WinAPI_GetClientRect($hGui) $oCoreWebView2Controller.put_Bounds($tRect) Case $idButton1 ; I use a simple method from the basic "Environment" interface. GUICtrlSetData($idLabelResult, "") $oCoreWebView2Environment.get_BrowserVersionString($vReturnedValue) ; get a simple synchronous property MsgBox(0, '', "WebView2 Version is " & $vReturnedValue) GUICtrlSetData($idLabelResult, "current WebView2 Version is" & @CRLF & $vReturnedValue) Case $idButton2 ; attempting to use methods of a later version interface (ICoreWebView2_8) #cs From interface ICoreWebView2_8 I would like to test this 2 synchronous methods get_IsMuted() - audio status put_IsMuted() — toggle audio get_IsDocumentPlayingAudio() - Is Audio Playing? #ce ;#cs --- This attempt to use QueryInterface fails --- Local $peek Local $HRESULT $HRESULT = $oCoreWebView2.QueryInterface($tRIID_ICoreWebView2_8, $pICoreWebView2_8) ConsoleWrite('Debug: line ' & @ScriptLineNumber & ' @error: ' & @error & @TAB & _ '$HRESULT -> ' & VarGetType($HRESULT) & ' ' & $HRESULT & @TAB & _ '$pICoreWebView2_8 -> ' & VarGetType($pICoreWebView2_8) & ' ' & $pICoreWebView2_8 & @CRLF) $oCoreWebView2_8 = ObjCreateInterface($pICoreWebView2_8, $sIID_ICoreWebView2_8, $dtag_ICoreWebView2_8) ConsoleWrite('Debug: line ' & @ScriptLineNumber & ' @error: ' & @error & @TAB & _ '$oCoreWebView2_8 -> ' & VarGetType($oCoreWebView2_8) & ' ' & $oCoreWebView2_8 & @CRLF) $HRESULT = $oCoreWebView2_8.get_IsDocumentPlayingAudio($peek) ConsoleWrite('Debug: line ' & @ScriptLineNumber & ' @error: ' & @error & @TAB & _ '$HRESULT -> ' & VarGetType($HRESULT) & ' ' & $HRESULT & @TAB & _ '$Peek -> ' & VarGetType($peek) & ' ' & $peek & @CRLF) ;#ce MsgBox(32, '', "?? How do I use methods from the ICoreWebView2_8 interface " & _ "in relation to the WebView2 control referenced by the $oCoreWebView2 variable ??" & @CRLF & @CRLF & _ "Thanks") ; $oCoreWebView2.Navigate("https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_8") Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() DllClose($hWebView2Loader) EndFunc ;==>WebView2 ; Copied from WV2Interfaces.au3 ; Executed automatically when the callback interface is created Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke($pSelf, $long, $ptr) ; Ret: long Par: long;ptr* ConsoleWrite("CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke" & @CRLF) ; Create CoreWebView2Environment object $oCoreWebView2Environment = ObjCreateInterface($ptr, $sIID_ICoreWebView2Environment, $dtag_ICoreWebView2Environment_mod) ConsoleWrite("IsObj( $oCoreWebView2Environment ) = " & IsObj($oCoreWebView2Environment) & @CRLF & @CRLF) $oCoreWebView2Environment.AddRef() ; Set $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler callback pointer for the WebView2 GUI $oCoreWebView2Environment.CreateCoreWebView2Controller($hGui, $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler) ; Forces CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke() below to be executed Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ;==>CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke ; Copied from WV2Interfaces.au3 ; Executed as a consequence of $oCoreWebView2Environment.CreateCoreWebView2Controller() above Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke($pSelf, $long, $ptr) ; Ret: long Par: long;ptr* ConsoleWrite("CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke" & @CRLF) ; Create CoreWebView2Controller object $oCoreWebView2Controller = ObjCreateInterface($ptr, $sIID_ICoreWebView2Controller, $dtag_ICoreWebView2Controller) ConsoleWrite("IsObj( $oCoreWebView2Controller ) = " & IsObj($oCoreWebView2Controller) & @CRLF) $oCoreWebView2Controller.AddRef() ; Prevent the object from being deleted when the function ends ; Set bounds for the CoreWebView2 object Local $tRect = _WinAPI_GetClientRect($hGui) $oCoreWebView2Controller.put_Bounds($tRect) ; Create CoreWebView2 object $oCoreWebView2Controller.get_CoreWebView2($pCoreWebView2) $oCoreWebView2 = ObjCreateInterface($pCoreWebView2, $sIID_ICoreWebView2, $dtag_ICoreWebView2) ConsoleWrite("IsObj( $oCoreWebView2 ) = " & IsObj($oCoreWebView2) & @CRLF & @CRLF) ; Navigate to web page $oCoreWebView2.Navigate("https://www.youtube.com/watch?v=oSexfR0Ubzw") Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ;==>CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke ; -- Callback functions ----- Func CoreWebView2_8_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $pRIID, $pObj EndFunc ;==>CoreWebView2_8_QueryInterface Func CoreWebView2_8_AddRef($pSelf) ; Ret: dword Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2_8_AddRef Func CoreWebView2_8_Release($pSelf) ; Ret: dword Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2_8_Release
  5. I recorded for about a minute just by pressing the Start button and without changing any settings, but when I open the file, the media player displays this message: "Cannot open Capture_..._... It's using unsupported encoding settings." (win11 x64) Am I doing something wrong?
  6. Animation file size: 57182968 bytes Dimension: 1920 x 1080 Frame count: 115 Duration: 10000 ms Estimated FPS: 11.5 GPU about 40% Intel(R) HD Graphics 530 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (3.19 GHz)
  7. ... or also with two counters ... one of which is a little more "visual" #include <WindowsStylesConstants.au3> Func ViewCustomCmdsList() Local $hwnd = GUICreate("", 200, 30, -1, -1, $WS_POPUP) Local $hwPrg = GUICtrlCreateProgress(0, 0, 200, 30) GUISetState(@SW_SHOWNOACTIVATE, $hwnd) WinActivate($hSAWSTUDIO_MAIN) ; ----------------------------------------------- ; Select Custom Cmds button Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0) Sleep(1000) ; --------------------- ; Select each Cmd in turn Sleep($iTimeOut) Send("{DOWN +3}") For $i = 2 To 27 Sleep($iTimeOut) ToolTip($i & " of 27", 450, 440) GUICtrlSetData($hwPrg, $i * (100 / 27)) Sleep($iDelayTime) Send("{DOWN}") Next ; --------------------- ToolTip("") GUIDelete($hwnd) Sleep(1000) Send("{ESC}") EndFunc ;==>ViewCustomCmdsList ; -----------------------------------------------
  8. …because even mathematics knows how to send its greetings... MathGreetings.zip
  9. Hi @Danyfirex Thanks so much for the helpful information 👍. I tried COMView and it's a really useful tool. Saludos and thanks for the help. 👋 P.S. COMVew working link: (https://web.archive.org/web/20250719112603/https://www.japheth.de/COMView.html) COMView download: (https://web.archive.org/web/20251029175716/https://www.japheth.de/Download/COMView.zip)
  10. Thanks!, @Danyfirex, you're a champion!. Can I ask how we can get that ID so we can retrieve it for future updates on that OCX (without bothering you )? Bye, thanks again, and happy holidays everyone!
  11. There's a new version of the OCX (Version 2.0.10 (2025-12-15)) on the OrdoWebView2 Control page, but unfortunately it doesn't work here. ...perhaps a new IID (interface identifier) needs to be used, but I don't know where @Danyfirex found the IID for the previous version... Does anyone have any idea where to find it?
  12. Try inserting the following line immediately after the RunAs line, you should get some more information about the nature of the problem... ConsoleWrite(_WinAPI_GetLastError() & @CRLF & _WinAPI_GetLastErrorMessage() & @CRLF)
  13. where is the WinSockUDF.au3 file? Thanks ... found it ... sorry
  14. Hi @genius257 Your input data reader works great! I added several inputs and buttons for a quick, rough test, and the values entered into the "toast" are returned to the callback and parsed correctly by your function. It appears that a notification toast doesn't allow more than 5 inputs; each selector input can't contain more than 5 options, and buttons can't exceed 5. Text inputs allow about 2,000 characters. But these limitations are due to the inherent features of Microsoft notification toasts, not your code. ... these toasts are funny... Bye and thanks again! cheers #include "./src/toast.au3" #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <InetConstants.au3> #include <WinApiReg.au3> #include <WinApiIcons.au3> #include <GDIPlus.au3> #include <WinAPIConv.au3> If Not FileExists(@TempDir & "\e25dbe211ddfb027fcb8271d833159fc.png") Then _GDIPlus_Startup() $thIcons = DllStructCreate("HWND") $x = _WinAPI_ExtractIconEx(@AutoItExe, 0, 0, $thIcons, 1) ConsoleWrite($x & @CRLF) $hBitmap = _GDIPlus_BitmapCreateFromHICON(DllStructGetData($thIcons, 1)) _GDIPlus_ImageSaveToFileEx($hBitmap, @TempDir & "\e25dbe211ddfb027fcb8271d833159fc.png", _GDIPlus_EncodersGetCLSID("PNG")) _GDIPlus_BitmapDispose($hBitmap) ConsoleWrite(@error & @CRLF) _GDIPlus_Shutdown() _WinAPI_DestroyIcon(DllStructGetData($thIcons, 1)) EndIf Global Const $sAppName = @ScriptName Global $tCLSID = _Toast_CoCreateGuid() Global $sGUID = _WinAPI_StringFromGUID($tCLSID) ConsoleWrite("app CLSID: " & $sGUID & @CRLF) _Toast_Initialize($sAppName, $tCLSID, OnToastActivation, "AutoIt Toast Example", @TempDir & "\e25dbe211ddfb027fcb8271d833159fc.png") Opt("GuiOnEventMode", 1) Global $hWnd = GUICreate("Toast example", 700, 320) GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CLOSE") Global $hButton01 = GUICtrlCreateButton("From template", 10, 10, 200, 120) GUICtrlSetOnEvent(-1, "ToastFromTemplateExample") Global $hButton02 = GUICtrlCreateButton("From XML string", 10, 140, 200, 120) GUICtrlSetOnEvent(-1, "ToastFromXmlString") Global $hRich = _GUICtrlRichEdit_Create($hWnd, "", 220, 10, 470, 300) GUISetState() While 1 Sleep(10) WEnd Func ToastFromTemplateExample() Local $oXml = _Toast_CreateToastTemplateXmlDocument() Local $pToast = _Toast_CreateToastNotificationFromXmlObject($oXml) _Toast_Show($pToast) EndFunc ;==>ToastFromTemplateExample Func DownloadImage() If FileExists(@TempDir & "\e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778.jpeg") Then Return _GUICtrlRichEdit_AppendText($hRich, "Trying to download avatar image from gravatar..." & @CRLF) Local $iBytes = InetGet("https://gravatar.com/avatar/e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778", @TempDir & "\e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778.jpeg", $INET_FORCEBYPASS) Local $error = @error If @error <> 0 Then _GUICtrlRichEdit_AppendText($hRich, "Failed to download image" & @CRLF) Return EndIf _GUICtrlRichEdit_AppendText($hRich, "Done! " & $iBytes & " bytes downloaded" & @CRLF) EndFunc ;==>DownloadImage Func ToastFromXmlString() DownloadImage() ; https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=xml Local $sToast = "" $sToast &= "<toast activationType=""foreground"" launch=""action=viewAlarm&amp;alarmId=3"" scenario=""alarm"">" ; action=mainContent;alarmId=3 $sToast &= "" $sToast &= " <visual>" $sToast &= " <binding template=""ToastGeneric"">" $sToast &= " <text>Time to wake up!</text>" $sToast &= " <text>To prove you're awake, select which of the following fruits is yellow...</text>" $sToast &= ' <image placement="appLogoOverride" src="file://' & @TempDir & '\e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778.jpeg" hint-crop="circle"/>' $sToast &= " </binding>" $sToast &= " </visual>" $sToast &= "" $sToast &= " <actions>" $sToast &= "<!-- #1 First input-->" $sToast &= " <input id=""Options"" type=""selection"" defaultInput=""Selection1"">" $sToast &= " <selection id=""Selection1"" content=""Option 1/5""/>" $sToast &= " <selection id=""Selection2"" content=""Option 2/5""/>" $sToast &= " <selection id=""Selection3"" content=""Option 3/5""/>" $sToast &= " <selection id=""Selection4"" content=""Option 4/5""/>" $sToast &= " <selection id=""Selection5"" content=""Option 5/5""/>" ; $sToast &= " <selection id=""Selection6"" content=""Option 6/6""/>" ; No more than 5 options allowed $sToast &= " </input>" $sToast &= "<!-- #2 Second input-->" $sToast &= " <input id=""Poem"" type=""text"" placeHolderContent=""Please write a poem"" />" $sToast &= "<!-- #3 Third input-->" $sToast &= " <input id=""Season"" type=""selection"" defaultInput=""Autumn"">" $sToast &= " <selection id=""Spring"" content=""Spring""/>" $sToast &= " <selection id=""Summer"" content=""Summer""/>" $sToast &= " <selection id=""Autumn"" content=""Autumn""/>" $sToast &= " <selection id=""Winter"" content=""Winter""/>" $sToast &= " </input>" $sToast &= "<!-- #4 Fourth input-->" $sToast &= " <input id=""Mood"" type=""selection"" defaultInput=""Love"">" $sToast &= " <selection id=""Happy"" content=""I'm Happy 😀""/>" $sToast &= " <selection id=""Sad"" content=""I'm Sad 😢""/>" $sToast &= " <selection id=""Love"" content=""I'm in love ❤️""/>" $sToast &= " <selection id=""Angry"" content=""I'm mad at the whole world 🖕""/>" $sToast &= " </input>" $sToast &= "<!-- #5 Fifth input-->" $sToast &= " <input id=""Gender"" type=""selection"" defaultInput=""Female"">" $sToast &= " <selection id=""Male"" content=""I'm a man""/>" $sToast &= " <selection id=""Female"" content=""I'm a woman""/>" $sToast &= " </input>" #cs ; --- No more than 5 inputs allowed and no more than 5 entry --- $sToast &= "<!-- #6 Sixth input-->" $sToast &= " <input id=""WeekDay"" type=""selection"" defaultInput=""Wednesday"">" $sToast &= " <selection id=""Monday"" content=""Monday""/>" $sToast &= " <selection id=""Tuesday"" content=""5 Sincronizza contatti""/>" $sToast &= " <selection id=""Wednesday"" content=""Wednesday""/>" $sToast &= " <selection id=""Thursday"" content=""Thursday""/>" $sToast &= " <selection id=""Friday"" content=""Friday""/>" $sToast &= " <selection id=""Saturday"" content=""Saturday""/>" $sToast &= " <selection id=""Sunday"" content=""Sunday""/>" $sToast &= " </input>" #ce ; --- No more than 5 inputs allowed and no more than 5 entry --- $sToast &= "" $sToast &= " <!-- Button 1 -->" $sToast &= " <action content=""Yes, I agree""" $sToast &= " arguments=""action=Agree""" $sToast &= " activationType=""background""/>" $sToast &= " <!-- Button 2 -->" $sToast &= " <action content=""No, I disagree""" $sToast &= " arguments=""action=Disagree""" $sToast &= " activationType=""background""/>" $sToast &= " <!-- Button 3 -->" $sToast &= " <action content=""Save data""" $sToast &= " arguments=""action=Save""" $sToast &= " activationType=""background""/>" $sToast &= " <!-- Button 4 -->" $sToast &= " <action content=""Open settings""" $sToast &= " arguments=""action=Open""" $sToast &= " activationType=""background""/>" $sToast &= " <!-- Button 5 -->" $sToast &= " <action content=""Dismiss""" $sToast &= " arguments=""action=Dismiss""" $sToast &= " activationType=""background""/>" #cs ; --- No more than 5 buttons allowed --- $sToast &= " <!-- Button 6 -->" $sToast &= " <action content=""Snooze""" $sToast &= " arguments=""action=Snooze""" $sToast &= " activationType=""background""/>" #ce ; --- No more than 5 buttons allowed --- $sToast &= " </actions>" $sToast &= ' <audio src=''ms-winsoundevent:Notification.Looping.Alarm'' loop=''false''/>' $sToast &= "</toast>" ;#ce Local $pToast = _Toast_CreateToastNotificationFromXmlString($sToast) If @error <> 0 Then _GUICtrlRichEdit_AppendText($hRich, _WinAPI_GetErrorMessage(@error)) Return EndIf _Toast_Show($pToast) _GUICtrlRichEdit_AppendText($hRich, $pToast & @TAB & "VarGetType: " & VarGetType($pToast) & @CRLF) EndFunc ;==>ToastFromXmlString ; https://learn.microsoft.com/en-us/windows/win32/api/notificationactivationcallback/nf-notificationactivationcallback-inotificationactivationcallback-activate Func OnToastActivation($pSelf, $appUserModelId, $invokedArgs, $data, $count) _GUICtrlRichEdit_AppendText($hRich, _ "Toast activated!" & @CRLF _ & " " & "appUserModelId: " & $appUserModelId & @TAB & "VarGetType: " & VarGetType($appUserModelId) & @CRLF _ & " " & "invokedArgs: " & $invokedArgs & @TAB & "VarGetType: " & VarGetType($invokedArgs) & @CRLF _ & " " & "$data: " & $data & @TAB & "VarGetType: " & VarGetType($data) & @TAB & DllStructGetData($data, 1) & @CRLF _ ; ??? also _WinAPI_GetString ... no good as well & " " & "$count: " & $count & @TAB & "VarGetType: " & VarGetType($count) & @CRLF _ ) _GUICtrlRichEdit_AppendText($hRich, @CRLF & "-----------------------------" & @CRLF) Local $pData = $data For $i = 1 To $count $tData = DllStructCreate('PTR Key;PTR Value;', $pData) $key = _WinAPI_GetString($tData.Key) $value = _WinAPI_GetString($tData.Value) ; ConsoleWrite(StringFormat('"%s"="%s"\n', $key, $value)) _GUICtrlRichEdit_AppendText($hRich, StringFormat('"%s"="%s"\n', $key, $value)) $pData += DllStructGetSize($tData) Next Return $_Toast_S_OK EndFunc ;==>OnToastActivation Func GUI_CLOSE() Exit EndFunc ;==>GUI_CLOSE
  15. Hi @genius257, and thanks for your progress From some tests I'm running, I'd expect the callback function to return the values of the fields in the "toast" in the $data parameter. Using the following script, I see that the parameter ($data) contains a pointer, but what does it point to, and how can I read the data it points to? bye and thanks #include "./src/toast.au3" #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <InetConstants.au3> #include <WinApiReg.au3> #include <WinApiIcons.au3> #include <GDIPlus.au3> #include <WinAPIConv.au3> If Not FileExists(@TempDir & "\e25dbe211ddfb027fcb8271d833159fc.png") Then _GDIPlus_Startup() $thIcons = DllStructCreate("HWND") $x = _WinAPI_ExtractIconEx(@AutoItExe, 0, 0, $thIcons, 1) ConsoleWrite($x & @CRLF) $hBitmap = _GDIPlus_BitmapCreateFromHICON(DllStructGetData($thIcons, 1)) _GDIPlus_ImageSaveToFileEx($hBitmap, @TempDir & "\e25dbe211ddfb027fcb8271d833159fc.png", _GDIPlus_EncodersGetCLSID("PNG")) _GDIPlus_BitmapDispose($hBitmap) ConsoleWrite(@error & @CRLF) _GDIPlus_Shutdown() _WinAPI_DestroyIcon(DllStructGetData($thIcons, 1)) EndIf Global Const $sAppName = @ScriptName Global $tCLSID = _Toast_CoCreateGuid() Global $sGUID = _WinAPI_StringFromGUID($tCLSID) ConsoleWrite("app CLSID: " & $sGUID & @CRLF) _Toast_Initialize($sAppName, $tCLSID, OnToastActivation, "AutoIt Toast Example", @TempDir & "\e25dbe211ddfb027fcb8271d833159fc.png") Opt("GuiOnEventMode", 1) Global $hWnd = GUICreate("Toast example", 700, 320) GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CLOSE") Global $hButton01 = GUICtrlCreateButton("From template", 10, 10, 200, 120) GUICtrlSetOnEvent(-1, "ToastFromTemplateExample") Global $hButton02 = GUICtrlCreateButton("From XML string", 10, 140, 200, 120) GUICtrlSetOnEvent(-1, "ToastFromXmlString") Global $hRich = _GUICtrlRichEdit_Create($hWnd, "", 220, 10, 470, 300) GUISetState() While 1 Sleep(10) WEnd Func ToastFromTemplateExample() Local $oXml = _Toast_CreateToastTemplateXmlDocument() Local $pToast = _Toast_CreateToastNotificationFromXmlObject($oXml) _Toast_Show($pToast) EndFunc ;==>ToastFromTemplateExample Func DownloadImage() If FileExists(@TempDir & "\e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778.jpeg") Then Return _GUICtrlRichEdit_AppendText($hRich, "Trying to download avatar image from gravatar..." & @CRLF) Local $iBytes = InetGet("https://gravatar.com/avatar/e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778", @TempDir & "\e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778.jpeg", $INET_FORCEBYPASS) Local $error = @error If @error <> 0 Then _GUICtrlRichEdit_AppendText($hRich, "Failed to download image" & @CRLF) Return EndIf _GUICtrlRichEdit_AppendText($hRich, "Done! " & $iBytes & " bytes downloaded" & @CRLF) EndFunc ;==>DownloadImage Func ToastFromXmlString() DownloadImage() ; https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=xml Local $sToast = "" $sToast &= "<toast activationType=""foreground"" launch=""action=viewAlarm&amp;alarmId=3"" scenario=""alarm"">" ; action=mainContent;alarmId=3 $sToast &= "" $sToast &= " <visual>" $sToast &= " <binding template=""ToastGeneric"">" $sToast &= " <text>Time to wake up!</text>" $sToast &= " <text>To prove you're awake, select which of the following fruits is yellow...</text>" $sToast &= ' <image placement="appLogoOverride" src="file://' & @TempDir & '\e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778.jpeg" hint-crop="circle"/>' $sToast &= " </binding>" $sToast &= " </visual>" $sToast &= "" $sToast &= " <actions>" $sToast &= "" $sToast &= " <input id=""answer"" type=""selection"" defaultInput=""wrongDefault"">" $sToast &= " <selection id=""wrong"" content=""Orange""/>" $sToast &= " <selection id=""wrongDefault"" content=""Blueberry""/>" $sToast &= " <selection id=""right"" content=""Banana""/>" $sToast &= " <selection id=""wrong"" content=""Avacado""/>" $sToast &= " <selection id=""wrong"" content=""Cherry""/>" $sToast &= " </input>" $sToast &= "" $sToast &= " <action" $sToast &= " activationType=""background""" $sToast &= " arguments=""snooze""" $sToast &= " content=""snooze""/>" $sToast &= "" $sToast &= " <action" $sToast &= " activationType=""background""" $sToast &= " arguments=""dismiss""" $sToast &= " content=""Dismiss""/>" $sToast &= "" $sToast &= " </actions>" $sToast &= ' <audio src=''ms-winsoundevent:Notification.Looping.Alarm'' loop=''false''/>' $sToast &= "</toast>" ;#ce Local $pToast = _Toast_CreateToastNotificationFromXmlString($sToast) If @error <> 0 Then _GUICtrlRichEdit_AppendText($hRich, _WinAPI_GetErrorMessage(@error)) Return EndIf _Toast_Show($pToast) _GUICtrlRichEdit_AppendText($hRich, $pToast & @TAB & "VarGetType: " & VarGetType($pToast) & @CRLF) EndFunc ;==>ToastFromXmlString ; https://learn.microsoft.com/en-us/windows/win32/api/notificationactivationcallback/nf-notificationactivationcallback-inotificationactivationcallback-activate Func OnToastActivation($pSelf, $appUserModelId, $invokedArgs, $data, $count) _GUICtrlRichEdit_AppendText($hRich, _ "Toast activated!" & @CRLF _ & " " & "appUserModelId: " & $appUserModelId & @TAB & "VarGetType: " & VarGetType($appUserModelId) & @CRLF _ & " " & "invokedArgs: " & $invokedArgs & @TAB & "VarGetType: " & VarGetType($invokedArgs) & @CRLF _ & " " & "$data: " & $data & @TAB & "VarGetType: " & VarGetType($data) & @TAB & DllStructGetData($data, 1) & @CRLF _ ; ??? also _WinAPI_GetString ... no good as well & " " & "$count: " & $count & @TAB & "VarGetType: " & VarGetType($count) & @CRLF _ ) Return $_Toast_S_OK EndFunc ;==>OnToastActivation Func GUI_CLOSE() Exit EndFunc ;==>GUI_CLOSE
×
×
  • Create New...