Leaderboard
Popular Content
Showing content with the highest reputation on 08/27/2024 in all areas
-
We have changed the login to require your Email address and disabled the option to use your member name to make the hacking of accounts harder, as that was happening regularly lately. We can assist in case you don't remember the Email address used at signup. Just use the "Contact us" link at the bottom of the page.7 points
-
2 points
-
i found solution here (Thanks to LarsJ ) https://www.autoitscript.com/forum/topic/205154-using-objcreateinterface-and-objectfromtag-functions/ Methods/properties of the description tag string must be in correct Vtable order. (I learned what Vtable is) ; https://www.autoitscript.com/forum/topic/212211-solved-setthumbnailtooltip #include <GUIConstantsEx.au3> $hGUI = GUICreate("AutoIt v3", 400, 100) GUISetState() _SetThumbnailTooltip($hGUI, "AutoIt v3" & @CRLF & "including a line breaker" & @CRLF & "in gui ThumbnailTooltip") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) Func _SetThumbnailTooltip($hWnd, $sText) ; Declare the CLSID, IID, and interface description for ITaskbarList3. Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" Local Const $sIID_ITaskbarList3 = "{ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf}" Local Const $sTagITaskbarList3 = "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" & _ "MarkFullscreenWindow hresult(hwnd;boolean);" & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" ; Create the object. Local $oTB = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $sTagITaskbarList3) ; Initialize the iTaskbarList3 object. $oTB.HrInit() ; Attempt to set the tooltip for the taskbar thumbnail $oTB.SetThumbnailTooltip($hWnd, $sText) EndFunc ;==>_SetThumbnailTooltip1 point
-
The Trailing Backslash
mr-es335 reacted to pixelsearch for a topic
@mr-es335 Hello Concerning FileCopy, maybe 2 posts I wrote a few years ago (after detecting a potential issue) could help you, here and there Good luck and have a great day too1 point -
Hi @UEZ, The link you posted refers to the WebView2's .NET environment. the "environment" created by larsj here is instead based on a WIN32 WebView COM environment, and the link for that method in our case would look like this: https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.1901.177#capturepreview. Following the information posted by @LarsJ in this topic, and imitating by analogy the settings related to the .ExecuteScript method which is working, I attempted to implement that CapturePreview method (lines 440 - 477 in WV2Interfaces_mod.au3), but surely I'm doing something wrong as the script terminates with this error: AutoIt3.exe ended.rc:-1073741819 Maybe I'm not adapting the parameters correctly from these two code snippets in the WebView2.h file to line 86 and line 443 in WV2Interfaces_mod.au3 virtual HRESULT STDMETHODCALLTYPE CapturePreview( /* [in] */ COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT imageFormat, /* [in] */ IStream *imageStream, /* [in] */ ICoreWebView2CapturePreviewCompletedHandler *handler) = 0; and this: { public: virtual HRESULT STDMETHODCALLTYPE Invoke( /* [in] */ HRESULT errorCode) = 0; } i also think that the parameter of type "stream" the way i tried to implement it could cause problems...(?) i implemented the callback functions too, but the whole thing doesn't work for testing you can simply download this compressed file created by Larsj which contains the basic environment needed to run WebView2. It consists of 2 folders to be extracted in a path of your choice where you have write rights: Examples Includes so to do some testing you can use the following two draft listings, which I also used for testing: put the below WebView2Draft.au3 script inside the Examples folder put the below WV2Interfaces_mod.au3 script inside the Includes folder when running the WebView2Draft.au3 listing an AutoIt GUI is generated with an embedded WebView2 control where a simple HTML page is displayed. clicking the ExecuteScript button, the system works and sends the two addends present in the input boxes of AutoIt to javascript. The result of the calculation performed by javascript is then returned to AutoIt using the CallBack function. While the CapturePreview button (lines from 78 to 95) doesn't work and sends the script into error. I hope someone understands where the problem is and manages to make it work sorry if this is a bit in draft form, but it's just experimenting material. Thanks WebView2Draft.au3 put this in the Examples folder #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> #include <WinAPIFiles.au3> Global Const $STGM_READWRITE = 2, $STGM_CREATE = 0x00001000 Global $hGui Global $idParam1, $vParam1, $idParam2, $vParam2, $idLabelResult Global $hStream ; handle to a file to write screenshot to Global $COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_PNG = 0 ; format of file PNG Global $sScrrenShot_Path = 'c:\temp\WebView2_Screenshot.png' ; Project includes #include "..\Includes\WV2Interfaces_mod.au3" WebView2() Func WebView2() ; Create WebView2 GUI $hGui = GUICreate("WebView2 Sample", 650, 350, -1, -1, $WS_OVERLAPPEDWINDOW) ; Create AutoIt controls Local $idButton = GUICtrlCreateButton("ExecuteScript", 10, 250, 170, 40) $idParam1 = GUICtrlCreateInput(5, 200, 250, 50, 40) GUICtrlCreateLabel('+', 252, 260, 10) $idParam2 = GUICtrlCreateInput(2, 260, 250, 50, 40) GUICtrlCreateLabel('=', 312, 260, 10) $idLabelResult = GUICtrlCreateLabel("", 320, 250, 170, 40) Local $idWebScreenShot = GUICtrlCreateButton("CapturePreview", 10, 300, 170, 40) ; Initialize COM _WinAPI_CoInitialize($COINIT_APARTMENTTHREADED) ; Create callback interface and functions CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate(False) ; Forces CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke() below to be executed ; Create callback interface and functions CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate(False) ; Create callback interface and functions CoreWebView2ExecuteScriptCompletedHandlerCreate(False) ; Create callback interface and functions CoreWebView2CapturePreviewCompletedHandlerCreate(False) ; ; DllCall CreateCoreWebView2EnvironmentWithOptions 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) ConsoleWrite("CreateCoreWebView2EnvironmentWithOptions OK" & @CRLF & @CRLF) ; Show WebView2 GUI GUISetState(@SW_SHOW) ; 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 $idButton ; ExecuteScript $vParam1 = GUICtrlRead($idParam1) $vParam2 = GUICtrlRead($idParam2) $oCoreWebView2.ExecuteScript("calc(" & $vParam1 & "," & $vParam2 & ");", $pCoreWebView2ExecuteScriptCompletedHandler) ; ConsoleWrite(" ==> " & $oCoreWebView2.get_BrowserProcessId & " <==" & @CRLF) ; Forces CoreWebView2ExecuteScriptCompletedHandler_Invoke() below to be executed Case $idWebScreenShot ; CapturePreview ; create a stream on a file [By the great UEZ! :) ] FileDelete($sScrrenShot_Path) $hStream = _WinAPI_SHCreateStreamOnFileEx($sScrrenShot_Path, BitOR($STGM_READWRITE, $STGM_CREATE), $FILE_ATTRIBUTE_NORMAL, True) ConsoleWrite("-Debug stream --: " & @error & @TAB & VarGetType($hStream) & @TAB & $hStream & @TAB & VarGetType($oCoreWebView2) & @CRLF) ; load a web page ; $oCoreWebView2.Navigate("https://www.autoitscript.com") ; MsgBox(0, '', 'Pause to give time to load page') ConsoleWrite("------------------" & @CRLF) $oCoreWebView2.CapturePreview($COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_PNG, $hStream, $pICoreWebView2CapturePreviewCompletedHandler) ; above call Forces in turn CoreWebView2CapturePreviewCompletedHandler_Invoke() callback function below to be executed after screenshot is taken ; MsgBox(0, '', 'Pause post screenshot') Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() CoreWebView2ExecuteScriptCompletedHandlerDelete() CoreWebView2CapturePreviewCompletedHandlerDelete() 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) ConsoleWrite("IsObj( $oCoreWebView2Environment ) = " & IsObj($oCoreWebView2Environment) & @CRLF & @CRLF) ; 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.NavigateToString(_GetPage()) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ;==>CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke ; Copied from WV2Interfaces.au3 ; Executed as a consequence of $oCoreWebView2.ExecuteScript() above Func CoreWebView2ExecuteScriptCompletedHandler_Invoke($pSelf, $long, $wstr) ; Ret: long Par: long;wstr ConsoleWrite("CoreWebView2ExecuteScriptCompletedHandler_Invoke()" & @CRLF) ConsoleWrite("$long = " & $long & @TAB & "$wstr = " & $wstr & @CRLF & @CRLF) ControlSetText('', '', $idLabelResult, $wstr) Return 0 ; S_OK = 0x00000000 #forceref $pSelf EndFunc ;==>CoreWebView2ExecuteScriptCompletedHandler_Invoke Func CoreWebView2CapturePreviewCompletedHandler_Invoke($pSelf, $iErrorCode) ; Ret: dword ConsoleWrite("CoreWebView2CapturePreviewCompletedHandler_Invoke()" & @CRLF) ConsoleWrite("CapturePreview returned Error code: " & $iErrorCode & @CRLF) Return 0 ; For AddRef/Release #forceref $pSelf, $iErrorCode EndFunc ;==>CoreWebView2CapturePreviewCompletedHandler_Invoke Func _GetPage() Local $sSource = "" $sSource &= "<!DOCTYPE html>" & @CRLF $sSource &= "<html>" & @CRLF $sSource &= "" & @CRLF $sSource &= "<head>" & @CRLF $sSource &= " <title>Our Company</title>" & @CRLF $sSource &= "<SCRIPT>" & @CRLF $sSource &= "function calc(x,y){" & @CRLF $sSource &= "return x + y;" & @CRLF $sSource &= "}" & @CRLF $sSource &= "</SCRIPT>" & @CRLF $sSource &= "</head>" & @CRLF $sSource &= "" & @CRLF $sSource &= "<body>" & @CRLF $sSource &= "" & @CRLF $sSource &= " <h1>Welcome to WebView2 embedded in AutoIt</h1> " & @CRLF $sSource &= " <h2>Web Site Main Ingredients:</h2>" & @CRLF $sSource &= "" & @CRLF $sSource &= " <p>A web Page (HTML) embedded in an AutoIt GUI</p>" & @CRLF $sSource &= " <p>Computer Code (JavaScript) embedded in the web page</p>" & @CRLF $sSource &= " <p>Execute javascript from AutoIt (AutoIt - Javascript interaction)</p>" & @CRLF $sSource &= "" & @CRLF $sSource &= "</body>" & @CRLF $sSource &= "" & @CRLF $sSource &= "</html> " & @CRLF Return $sSource EndFunc ;==>_GetPage ; https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-shcreatestreamonfileex Func _WinAPI_SHCreateStreamOnFileEx($sFile, $grfMode, $dwAttributes, $fCreate) ; By UEZ ; https://www.autoitscript.com/forum/topic/204362-microsoft-edge-webview2-embed-web-code-in-your-native-application/?do=findComment&comment=1523541 Local $iLen = StringLen($sFile), $tFile = DllStructCreate("wchar szFile[" & $iLen & "]") $tFile.szFile = $sFile Local $aResult = DllCall("Shlwapi.dll", "long", "SHCreateStreamOnFileEx", "struct*", $tFile, "dword", $grfMode, "dword", $dwAttributes, "bool", $fCreate, "ptr", Null, "ptr*", 0) If $aResult[0] Or @error Then Return SetError(1, 0, 0) Return $aResult[6] EndFunc ;==>_WinAPI_SHCreateStreamOnFileEx WV2Interfaces_mod.au3 put this in the Includes folder #include-once #include "ObjectFromTag.au3" ; Globals for callback interfaces ; for Environment creation ; ------------------------ Global _ $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler, _ ; ..... result returned by ObjectFromTag $tCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler ; ........ Interface struct (DllStruct) ; for controller creation ; ----------------------- Global _ $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler, _ ; ..... <-- result returned by ObjectFromTag (an object or a pointer to the object) $tCoreWebView2CreateCoreWebView2ControllerCompletedHandler ; ........ <-- Interface struct (DllStruct) ; for ExecuteScript creation ; -------------------------- Global _ $pCoreWebView2ExecuteScriptCompletedHandler, _ ; ..... <-- result returned by ObjectFromTag (an object or a pointer to the object) $tCoreWebView2ExecuteScriptCompletedHandler ; ........ <-- Interface struct (DllStruct) ; for CapturePreview creation ; --------------------------- Global _ $pICoreWebView2CapturePreviewCompletedHandler, _ $tICoreWebView2CapturePreviewCompletedHandler ; NavigationStarting ; ------------------ Global _ $pCoreWebView2NavigationStartingEventHandler, _ $tCoreWebView2NavigationStartingEventHandler ; WebMessageReceived ; ------------------ Global _ $pCoreWebView2WebMessageReceivedEventHandler, _ $tCoreWebView2WebMessageReceivedEventHandler ; --- ICoreWebView2 interface --- Global $oCoreWebView2, $pCoreWebView2 Global Const $sIID_ICoreWebView2 = "{76ECEACB-0462-4D94-AC83-423A6793775E}" ; https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2 ; https://mam-mam.net/delphi/tedgebrowser_webview2.html ; https://docs.rs/webview2-sys/latest/src/webview2_sys/lib.rs.html ; https://stackoverflow.com/questions/2230758/what-does-lpcwstr-stand-for-and-how-should-it-be-handled ; https://docs.rs/webview2-sys/latest/webview2_sys/index.html Global Const $dtag_ICoreWebView2 = _ "get_Settings hresult(ptr*);" & _ "get_Source hresult(wstr*);" & _ ; ok "Navigate hresult(wstr);" & _ "NavigateToString hresult(wstr);" & _ "add_NavigationStarting hresult(ptr;struct*);" & _ "remove_NavigationStarting hresult();" & _ "add_ContentLoading hresult();" & _ "remove_ContentLoading hresult();" & _ "add_SourceChanged hresult();" & _ "remove_SourceChanged hresult();" & _ "add_HistoryChanged hresult();" & _ "remove_HistoryChanged hresult();" & _ "add_NavigationCompleted hresult();" & _ "remove_NavigationCompleted hresult();" & _ "add_FrameNavigationStarting hresult();" & _ "remove_FrameNavigationStarting hresult();" & _ "add_FrameNavigationCompleted hresult();" & _ "remove_FrameNavigationCompleted hresult();" & _ "add_ScriptDialogOpening hresult();" & _ "remove_ScriptDialogOpening hresult();" & _ "add_PermissionRequested hresult();" & _ "remove_PermissionRequested hresult();" & _ "add_ProcessFailed hresult();" & _ "remove_ProcessFailed hresult();" & _ "AddScriptToExecuteOnDocumentCreated hresult(wstr;ptr);" & _ "RemoveScriptToExecuteOnDocumentCreated hresult();" & _ "ExecuteScript hresult(wstr;ptr);" & _ ; ok ; LPCWSTR javaScript, ICoreWebView2ExecuteScriptCompletedHandler *handler "CapturePreview hresult(int32;ptr;ptr);" & _ ; COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT imageFormat, IStream *imageStream, ICoreWebView2CapturePreviewCompletedHandler *handler "Reload hresult(none);" & _ ; ok ; * !!! you have to pass an argument anyway in the function call, or error occurs (?strange but true) "PostWebMessageAsJson hresult();" & _ "PostWebMessageAsString hresult();" & _ "add_WebMessageReceived hresult(ptr;struct*);" & _ "remove_WebMessageReceived hresult();" & _ "CallDevToolsProtocolMethod hresult();" & _ "get_BrowserProcessId hresult(UINT*);" & _ ; ok "get_CanGoBack hresult(BOOL*);" & _ ; ok "get_CanGoForward hresult(BOOL*);" & _ ; ok "GoBack hresult(none);" & _ ; ok ; * !!! you have to pass an argument anyway in the function call, or error occurs (?strange but true) "GoForward hresult(none);" & _ ; ok ; !!! you have to pass an argument anyway in the function call, or error occurs (?strange but true) "GetDevToolsProtocolEventReceiver hresult();" & _ "Stop hresult();" & _ "add_NewWindowRequested hresult();" & _ "remove_NewWindowRequested hresult();" & _ "add_DocumentTitleChanged hresult();" & _ "remove_DocumentTitleChanged hresult();" & _ "get_DocumentTitle hresult(wstr*);" & _ ; ok "AddHostObjectToScript hresult();" & _ "RemoveHostObjectFromScript hresult();" & _ "OpenDevToolsWindow hresult();" & _ "add_ContainsFullScreenElementChanged hresult();" & _ "remove_ContainsFullScreenElementChanged hresult();" & _ "get_ContainsFullScreenElement hresult(BOOL*);" & _ ; ok "add_WebResourceRequested hresult();" & _ "remove_WebResourceRequested hresult();" & _ "AddWebResourceRequestedFilter hresult();" & _ "RemoveWebResourceRequestedFilter hresult();" & _ "add_WindowCloseRequested hresult();" & _ "remove_WindowCloseRequested hresult();" ; --- ICoreWebView2Settings interface --- Global $oCoreWebView2Settings, $pCoreWebView2Settings Global Const $sIID_ICoreWebView2Settings = "{E562E4F0-D7FA-43AC-8D71-C05150499F00}" Global Const $dtag_ICoreWebView2Settings = _ "get_IsScriptEnabled hresult();" & _ "put_IsScriptEnabled hresult();" & _ "get_IsWebMessageEnabled hresult(bool*);" & _ "put_IsWebMessageEnabled hresult();" & _ "get_AreDefaultScriptDialogsEnabled hresult();" & _ "put_AreDefaultScriptDialogsEnabled hresult();" & _ "get_IsStatusBarEnabled hresult();" & _ "put_IsStatusBarEnabled hresult();" & _ "get_AreDevToolsEnabled hresult();" & _ "put_AreDevToolsEnabled hresult();" & _ "get_AreDefaultContextMenusEnabled hresult();" & _ "put_AreDefaultContextMenusEnabled hresult();" & _ "get_AreHostObjectsAllowed hresult();" & _ "put_AreHostObjectsAllowed hresult();" & _ "get_IsZoomControlEnabled hresult();" & _ "put_IsZoomControlEnabled hresult();" & _ "get_IsBuiltInErrorPageEnabled hresult();" & _ "put_IsBuiltInErrorPageEnabled hresult();" ; --- ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler and related interfaces and functions --- ; ICoreWebView2Environment interface Global $oCoreWebView2Environment Global Const $sIID_ICoreWebView2Environment = "{B96D755E-0319-4E92-A296-23436F46A1FC}" Global Const $dtag_ICoreWebView2Environment = _ "CreateCoreWebView2Controller hresult(hwnd;ptr);" & _ "CreateWebResourceResponse hresult();" & _ "get_BrowserVersionString hresult();" & _ "add_NewBrowserVersionAvailable hresult();" & _ "remove_NewBrowserVersionAvailable hresult();" #cs // *********************************************************************// // interface: ICoreWebView2Environment // flag: (0) // GUID: {B96D755E-0319-4E92-A296-23436F46A1FC} // *********************************************************************// ICoreWebView2Environment = interface(IUnknown) ['{B96D755E-0319-4E92-A296-23436F46A1FC}'] function CreateCoreWebView2Controller(var ParentWindow: _RemotableHandle; const handler: ICoreWebView2CreateCoreWebView2ControllerCompletedHandler): HResult; stdcall; function CreateWebResourceResponse(const Content: IStream; StatusCode: SYSINT; ReasonPhrase: PWideChar; Headers: PWideChar; out Response: ICoreWebView2WebResourceResponse): HResult; stdcall; function Get_BrowserVersionString(out versionInfo: PWideChar): HResult; stdcall; function add_NewBrowserVersionAvailable(const eventHandler: ICoreWebView2NewBrowserVersionAvailableEventHandler; out token: EventRegistrationToken): HResult; stdcall; function remove_NewBrowserVersionAvailable(token: EventRegistrationToken): HResult; stdcall; end; #ce ; ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler callback interface ; ---------------------------------------------------------------------------------------------------------------- Global Const $sIID_ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler = "{4E8A3389-C9D8-4BD2-B6B5-124FEE6CC14D}" ; <-- ??? not used #cs ; from ; https://pkg.go.dev/github.com/zzl/go-webview2/wv2 var IID_ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler = syscall.GUID{0x4E8A3389, 0xC9D8, 0x4BD2, [8]byte{0xB6, 0xB5, 0x12, 0x4F, 0xEE, 0x6C, 0xC1, 0x4D}} // 4E8A3389-C9D8-4BD2-B6B5-124FEE6CC14D var IID_ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler = syscall.GUID{0x4E8A3389, 0xC9D8, 0x4BD2, [8]byte{0xB6, 0xB5, 0x12, 0x4F, 0xEE, 0x6C, 0xC1, 0x4D}} #ce ; from ; https://pkg.go.dev/github.com/zzl/go-webview2/wv2 ; ---------------------------------------------------------------------------------------------------------------- Global Const $dtag_ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler = _ "Invoke hresult(hresult;ptr*);" ; Functions to create and delete the callback interface ; ; first call ; crea l'environment e ne restituisce il "pointer" nella variabile Global $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler ; =========== ; Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate($bPrint = False) $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler = ObjectFromTag( _ "CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_", _ ; ...... Presents methods/properties with the same prefix name $dtag_ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler, _ ; .. Interface description tag string $tCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler, _ ; ....... Interface struct (DllStruct) False, _ ; ............................................................. Return object if True or object pointer if False $bPrint _ ; ............................................................ Print information in SciTE console ) ; Last 2 parameters uses default values ; $bIsUnknown = True, _ ; ................................................ Inherits from the IUnknown interface ; $sIID = "{00000000-0000-0000-C000-000000000046}") ; .................... Last param is IID_IUnknown by default If $bPrint Then ConsoleWrite("$pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler = " & $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler & @CRLF & @CRLF) EndFunc ;==>CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler = 0 DeleteObjectFromTag($tCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler) EndFunc ;==>CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete ; Callback functions Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* ConsoleWrite("# invoked -> EnvironmentCompletedHandler_QueryInterface() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) ; & "CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_QueryInterface()" & @CRLF & @CRLF) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $pRIID, $pObj EndFunc ;==>CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_QueryInterface Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_AddRef($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_AddRef() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) ; & "CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_AddRef()" & @CRLF & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_AddRef Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Release($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Release() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) ; &("CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Release()" & @CRLF & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Release #cs Function copied to example code Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke( $pSelf, $long, $ptr ) ; Ret: long Par: long;ptr* ConsoleWrite( "CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke()" & @CRLF & @CRLF ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long, $ptr EndFunc #ce ; --- ICoreWebView2CreateCoreWebView2ControllerCompletedHandler and related interfaces and functions --- ; ICoreWebView2Controller interface Global $oCoreWebView2Controller Global Const $sIID_ICoreWebView2Controller = "{4D00C0D1-9434-4EB6-8078-8697A560334F}" Global Const $dtag_ICoreWebView2Controller = _ "get_IsVisible hresult();" & _ "put_IsVisible hresult();" & _ "get_Bounds hresult();" & _ (@AutoItX64 ? "put_Bounds hresult(struct*);" : "put_Bounds hresult(struct);") & _ "get_ZoomFactor hresult();" & _ "put_ZoomFactor hresult();" & _ "add_ZoomFactorChanged hresult();" & _ "remove_ZoomFactorChanged hresult();" & _ "SetBoundsAndZoomFactor hresult();" & _ "MoveFocus hresult();" & _ "add_MoveFocusRequested hresult();" & _ "remove_MoveFocusRequested hresult();" & _ "add_GotFocus hresult();" & _ "remove_GotFocus hresult();" & _ "add_LostFocus hresult();" & _ "remove_LostFocus hresult();" & _ "add_AcceleratorKeyPressed hresult();" & _ "remove_AcceleratorKeyPressed hresult();" & _ "get_ParentWindow hresult();" & _ "put_ParentWindow hresult();" & _ "NotifyParentWindowPositionChanged hresult();" & _ "Close hresult();" & _ "get_CoreWebView2 hresult(ptr*);" ; ICoreWebView2CreateCoreWebView2ControllerCompletedHandler callback interface Global Const $sIID_ICoreWebView2CreateCoreWebView2ControllerCompletedHandler = "{6C4819F3-C9B7-4260-8127-C9F5BDE7F68C}" Global Const $dtag_ICoreWebView2CreateCoreWebView2ControllerCompletedHandler = _ "Invoke hresult(hresult;ptr*);" ; Functions to create and delete the callback interface ; second call ; create 'controller' in Global $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler ; Func CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate($bPrint = False) $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler = ObjectFromTag( _ "CoreWebView2CreateCoreWebView2ControllerCompletedHandler_", _ ; ...... Presents methods/properties with the same prefix name $dtag_ICoreWebView2CreateCoreWebView2ControllerCompletedHandler, _ ; .. Interface description tag string $tCoreWebView2CreateCoreWebView2ControllerCompletedHandler, _ ; ....... Interface struct (DllStruct) False, _ ; ............................................................ Return object if True or object pointer if False $bPrint _ ; ........................................................... Print information in SciTE console ) ; Last 2 parameters uses default values ; $bIsUnknown = True, _ ; ............................................... Inherits from the IUnknown interface ; $sIID = "{00000000-0000-0000-C000-000000000046}") ; ................... Last param is IID_IUnknown by default If $bPrint Then ConsoleWrite("$pCoreWebView2CreateCoreWebView2ControllerCompletedHandler = " & $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler & @CRLF & @CRLF) EndFunc ;==>CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate Func CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler = 0 DeleteObjectFromTag($tCoreWebView2CreateCoreWebView2ControllerCompletedHandler) EndFunc ;==>CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete ; Callback functions Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* ConsoleWrite("# invoked -> CoreWebView2CreateCoreWebView2ControllerCompletedHandler_QueryInterface() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $pRIID, $pObj EndFunc ;==>CoreWebView2CreateCoreWebView2ControllerCompletedHandler_QueryInterface Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_AddRef($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2CreateCoreWebView2ControllerCompletedHandler_AddRef() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2CreateCoreWebView2ControllerCompletedHandler_AddRef Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Release($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Release() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Release #cs Function copied to example code Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke( $pSelf, $long, $ptr ) ; Ret: long Par: long;ptr* ConsoleWrite( "CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke()" & @CRLF & @CRLF ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long, $ptr EndFunc #ce ; --- ICoreWebView2NavigationStartingEventHandler and related interfaces and functions --- ; ICoreWebView2NavigationStartingEventArgs interface Global $oCoreWebView2NavigationStartingEventArgs Global Const $sIID_ICoreWebView2NavigationStartingEventArgs = "{5B495469-E119-438A-9B18-7604F25F2E49}" Global Const $dtag_ICoreWebView2NavigationStartingEventArgs = _ "get_Uri hresult(wstr*);" & _ "get_IsUserInitiated hresult(bool*);" & _ "get_IsRedirected hresult(bool*);" & _ "get_RequestHeaders hresult(ptr*);" & _ "get_Cancel hresult(bool*);" & _ "put_Cancel hresult(bool);" & _ "get_NavigationId hresult(struct*);" ; ICoreWebView2NavigationStartingEventHandler callback interface Global Const $sIID_ICoreWebView2NavigationStartingEventHandler = "{9ADBE429-F36D-432B-9DDC-F8881FBD76E3}" Global Const $dtag_ICoreWebView2NavigationStartingEventHandler = _ "Invoke hresult(ptr*;ptr*);" ; Functions to create and delete the callback interface Func CoreWebView2NavigationStartingEventHandlerCreate($bPrint = False) $pCoreWebView2NavigationStartingEventHandler = ObjectFromTag("CoreWebView2NavigationStartingEventHandler_", $dtag_ICoreWebView2NavigationStartingEventHandler, $tCoreWebView2NavigationStartingEventHandler, False, $bPrint) If $bPrint Then ConsoleWrite("$pCoreWebView2NavigationStartingEventHandler = " & $pCoreWebView2NavigationStartingEventHandler & @CRLF & @CRLF) EndFunc ;==>CoreWebView2NavigationStartingEventHandlerCreate Func CoreWebView2NavigationStartingEventHandlerDelete() $pCoreWebView2NavigationStartingEventHandler = 0 DeleteObjectFromTag($tCoreWebView2NavigationStartingEventHandler) EndFunc ;==>CoreWebView2NavigationStartingEventHandlerDelete ; Callback functions Func CoreWebView2NavigationStartingEventHandler_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* ConsoleWrite("# invoked -> CoreWebView2NavigationStartingEventHandler_QueryInterface() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $pRIID, $pObj EndFunc ;==>CoreWebView2NavigationStartingEventHandler_QueryInterface Func CoreWebView2NavigationStartingEventHandler_AddRef($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2NavigationStartingEventHandler_AddRef() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2NavigationStartingEventHandler_AddRef Func CoreWebView2NavigationStartingEventHandler_Release($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2NavigationStartingEventHandler_Release() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2NavigationStartingEventHandler_Release #cs Function copied to example code Func CoreWebView2NavigationStartingEventHandler_Invoke( $pSelf, $ptr1, $ptr2 ) ; Ret: long Par: ptr*;ptr* ConsoleWrite( "CoreWebView2NavigationStartingEventHandler_Invoke()" & @CRLF & @CRLF ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $ptr1, $ptr2 EndFunc #ce ; --- ICoreWebView2ExecuteScriptCompletedHandler and related interfaces and functions --- ; ICoreWebView2ExecuteScriptCompletedHandler callback interface Global Const $sIID_ICoreWebView2ExecuteScriptCompletedHandler = "{49511172-CC67-4BCA-9923-137112F4C4CC}" Global Const $dtag_ICoreWebView2ExecuteScriptCompletedHandler = _ "Invoke hresult(hresult;wstr);" ; Functions to create and delete the callback interface Func CoreWebView2ExecuteScriptCompletedHandlerCreate($bPrint = False) $pCoreWebView2ExecuteScriptCompletedHandler = ObjectFromTag("CoreWebView2ExecuteScriptCompletedHandler_", _ $dtag_ICoreWebView2ExecuteScriptCompletedHandler, _ $tCoreWebView2ExecuteScriptCompletedHandler, _ False, _ $bPrint) If $bPrint Then ConsoleWrite("$pCoreWebView2ExecuteScriptCompletedHandler = " & $pCoreWebView2ExecuteScriptCompletedHandler & @CRLF & @CRLF) EndFunc ;==>CoreWebView2ExecuteScriptCompletedHandlerCreate Func CoreWebView2ExecuteScriptCompletedHandlerDelete() $pCoreWebView2ExecuteScriptCompletedHandler = 0 DeleteObjectFromTag($tCoreWebView2ExecuteScriptCompletedHandler) EndFunc ;==>CoreWebView2ExecuteScriptCompletedHandlerDelete ; ------------------------------------------------------------------------------------------------------------------------- ; Callback functions Func CoreWebView2ExecuteScriptCompletedHandler_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* ConsoleWrite("# invoked -> CoreWebView2ExecuteScriptCompletedHandler_QueryInterface() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $pRIID, $pObj EndFunc ;==>CoreWebView2ExecuteScriptCompletedHandler_QueryInterface Func CoreWebView2ExecuteScriptCompletedHandler_AddRef($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2ExecuteScriptCompletedHandler_AddRef() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2ExecuteScriptCompletedHandler_AddRef Func CoreWebView2ExecuteScriptCompletedHandler_Release($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2ExecuteScriptCompletedHandler_Release() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2ExecuteScriptCompletedHandler_Release ; ------------------------------------------------------------------------------------------------------------------------- ; == CapturePreview ======================================================================================================= Global $sIID_ICoreWebView2CapturePreviewCompletedHandler = "{697e05e9-3d8f-45fa-96f4-8ffe1ededaf5}" Global $dtag_ICoreWebView2CapturePreviewCompletedHandler = _ "Invoke hresult(LONG);" ; HRESULT error Func CoreWebView2CapturePreviewCompletedHandlerCreate($bPrint = False) $pICoreWebView2CapturePreviewCompletedHandler = ObjectFromTag( _ 'CoreWebView2CapturePreviewCompletedHandler_', _ $dtag_ICoreWebView2CapturePreviewCompletedHandler, _ $tICoreWebView2CapturePreviewCompletedHandler, _ False, _ $bPrint) If $bPrint Then ConsoleWrite("$pICoreWebView2CapturePreviewCompletedHandler = " & $pICoreWebView2CapturePreviewCompletedHandler & @CRLF & @CRLF) EndFunc ;==>CoreWebView2CapturePreviewCompletedHandlerCreate Func CoreWebView2CapturePreviewCompletedHandlerDelete() $pICoreWebView2CapturePreviewCompletedHandler = 0 DeleteObjectFromTag($tICoreWebView2CapturePreviewCompletedHandler) EndFunc ;==>CoreWebView2CapturePreviewCompletedHandlerDelete ; -- Callback functions ----- Func CoreWebView2CapturePreviewCompletedHandler_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* ConsoleWrite('***> CoreWebView2CapturePreviewCompletedHandler_QueryInterface' & @CRLF) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $pRIID, $pObj EndFunc ;==>CoreWebView2CapturePreviewCompletedHandler_QueryInterface Func CoreWebView2CapturePreviewCompletedHandler_AddRef($pSelf) ; Ret: dword ConsoleWrite('***> CoreWebView2CapturePreviewCompletedHandler_AddRef' & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2CapturePreviewCompletedHandler_AddRef Func CoreWebView2CapturePreviewCompletedHandler_Release($pSelf) ; Ret: dword ConsoleWrite('***> CoreWebView2CapturePreviewCompletedHandler_Release' & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2CapturePreviewCompletedHandler_Release ; ====================================================================== ; --- ICoreWebView2WebMessageReceivedEventHandler and related interfaces and functions --- ; ICoreWebView2WebMessageReceivedEventArgs interface Global $oCoreWebView2WebMessageReceivedEventArgs Global Const $sIID_ICoreWebView2WebMessageReceivedEventArgs = "{0F99A40C-E962-4207-9E92-E3D542EFF849}" Global Const $dtag_ICoreWebView2WebMessageReceivedEventArgs = _ "get_Source hresult(wstr*);" & _ "get_WebMessageAsJson hresult(wstr*);" & _ "TryGetWebMessageAsString hresult(wstr*);" ; ICoreWebView2WebMessageReceivedEventHandler callback interface Global Const $sIID_ICoreWebView2WebMessageReceivedEventHandler = "{57213F19-00E6-49FA-8E07-898EA01ECBD2}" Global Const $dtag_ICoreWebView2WebMessageReceivedEventHandler = _ "Invoke hresult(ptr*;ptr*);" ; Functions to create and delete the callback interface ; Functions to create and delete the callback interface #cs Func CoreWebView2ExecuteScriptCompletedHandlerCreate($bPrint = False) $pCoreWebView2ExecuteScriptCompletedHandler = ObjectFromTag("CoreWebView2ExecuteScriptCompletedHandler_", _ $dtag_ICoreWebView2ExecuteScriptCompletedHandler, _ $tCoreWebView2ExecuteScriptCompletedHandler, _ False, _ $bPrint) If $bPrint Then ConsoleWrite("$pCoreWebView2ExecuteScriptCompletedHandler = " & $pCoreWebView2ExecuteScriptCompletedHandler & @CRLF & @CRLF) EndFunc ;==>CoreWebView2ExecuteScriptCompletedHandlerCreate #ce Func CoreWebView2WebMessageReceivedEventHandlerCreate($bPrint = False) $pCoreWebView2WebMessageReceivedEventHandler = ObjectFromTag("CoreWebView2WebMessageReceivedEventHandler_", _ $dtag_ICoreWebView2WebMessageReceivedEventHandler, _ $tCoreWebView2WebMessageReceivedEventHandler, _ False, _ $bPrint) If $bPrint Then ConsoleWrite("$pCoreWebView2WebMessageReceivedEventHandler = " & $pCoreWebView2WebMessageReceivedEventHandler & @CRLF & @CRLF) EndFunc ;==>CoreWebView2WebMessageReceivedEventHandlerCreate Func CoreWebView2WebMessageReceivedEventHandlerDelete() $pCoreWebView2WebMessageReceivedEventHandler = 0 DeleteObjectFromTag($tCoreWebView2WebMessageReceivedEventHandler) EndFunc ;==>CoreWebView2WebMessageReceivedEventHandlerDelete ; Callback functions Func CoreWebView2WebMessageReceivedEventHandler_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* ConsoleWrite("# invoked -> CoreWebView2WebMessageReceivedEventHandler_QueryInterface() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $pRIID, $pObj EndFunc ;==>CoreWebView2WebMessageReceivedEventHandler_QueryInterface Func CoreWebView2WebMessageReceivedEventHandler_AddRef($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2WebMessageReceivedEventHandler_AddRef() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2WebMessageReceivedEventHandler_AddRef Func CoreWebView2WebMessageReceivedEventHandler_Release($pSelf) ; Ret: dword ConsoleWrite("# invoked -> CoreWebView2WebMessageReceivedEventHandler_Release() (Script: WV2Interfaces.au3 Line: " & @ScriptLineNumber & @CRLF) Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2WebMessageReceivedEventHandler_Release #cs Function copied to example code Func CoreWebView2WebMessageReceivedEventHandler_Invoke( $pSelf, $ptr1, $ptr2 ) ; Ret: long Par: ptr*;ptr* ConsoleWrite( "CoreWebView2WebMessageReceivedEventHandler_Invoke()" & @CRLF & @CRLF ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $ptr1, $ptr2 EndFunc #ce1 point
-
Scripting example based on code by ChimpWebView2-4.au3: #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" WebView2() Func WebView2() ; Create WebView2 GUI $hGui = GUICreate( "WebView2 Sample", 600, 300, -1, -1, $WS_OVERLAPPEDWINDOW ) ; Create Button Local $idButton = GUICtrlCreateButton( "ExecuteScript", 10, 250, 170, 40 ) ; Initialize COM _WinAPI_CoInitialize( $COINIT_APARTMENTTHREADED ) ; Create callback interface and functions CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate( True ) ; Forces CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke() below to be executed ; Create callback interface and functions CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate( True ) ; Create callback interface and functions CoreWebView2ExecuteScriptCompletedHandlerCreate( True ) ; DllCall CreateCoreWebView2EnvironmentWithOptions Local $hWebView2Loader = DllOpen( @AutoItX64 ? "WebView2Loader-x64.dll" : "WebView2Loader-x86.dll" ) Local $aRet = DllCall( $hWebView2Loader, "long", "CreateCoreWebView2EnvironmentWithOptions", "wstr", "", "wstr", "", _ "ptr", Null, "ptr", $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler ) If @error Or $aRet[0] Then Return ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions ERR" & @CRLF ) ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions OK" & @CRLF & @CRLF ) ; Show WebView2 GUI GUISetState( @SW_SHOW ) ; 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 $idButton $oCoreWebView2.ExecuteScript( "alert( 'Hello' );", $pCoreWebView2ExecuteScriptCompletedHandler ) ; Forces CoreWebView2ExecuteScriptCompletedHandler_Invoke() below to be executed Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() CoreWebView2ExecuteScriptCompletedHandlerDelete() DllClose( $hWebView2Loader ) EndFunc ; 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 ) ConsoleWrite( "IsObj( $oCoreWebView2Environment ) = " & IsObj( $oCoreWebView2Environment ) & @CRLF & @CRLF ) ; 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 ; 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.NavigateToString( _GetPage() ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ; Copied from WV2Interfaces.au3 ; Executed as a consequence of $oCoreWebView2.ExecuteScript() above Func CoreWebView2ExecuteScriptCompletedHandler_Invoke( $pSelf, $long, $wstr ) ; Ret: long Par: long;wstr ConsoleWrite( "CoreWebView2ExecuteScriptCompletedHandler_Invoke()" & @CRLF ) ConsoleWrite( "$long = " & $long & @TAB & "$wstr = " & $wstr & @CRLF & @CRLF ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf EndFunc Func _GetPage() Local $sPageSource = "" $sPageSource &= "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & @CRLF $sPageSource &= "<HTML><HEAD><TITLE>L E D Panel Script</TITLE>" & @CRLF $sPageSource &= "<META http-equiv=Content-Type content=""text/html; charset=windows-1252"">" & @CRLF $sPageSource &= "<STYLE type=text/css>" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "body{" & @CRLF $sPageSource &= "background-color:black;" & @CRLF $sPageSource &= "}" & @CRLF $sPageSource &= "</STYLE>" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "</HEAD>" & @CRLF $sPageSource &= "<BODY onload=""LEDinit()"">" & @CRLF $sPageSource &= "<img src=""https://www.autoitscript.com/forum/cdn/images/logo_autoit_210x72.svg"" width=""100"" height=""35"" style=""position: absolute; top: 5px; left: 200px;"">" & @CRLF $sPageSource &= "<SCRIPT language=JavaScript>" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "//""L.E.D. Panel"" Script by Richard Maloney © 2002" & @CRLF $sPageSource &= "//For Custom effects, email Richard ( ottawo@rogers.com )" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "//____________________CONFIGURATION AREA_____________________" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "// THIS LED SCRIPT TAKES UP 200 pixels HORIZONTAL and 28 pixels VERTICAL -Have Fun :- )" & @CRLF $sPageSource &= "// YOUR MESSAGE GOES ON NEXT 4 LINES DOWN." & @CRLF $sPageSource &= "// ALLOWABLE CHARACTERS ARE: A-Z, Period, space, comma, numerals, question mark and 'message codes'." & @CRLF $sPageSource &= "// THE 4 MESSAGE CODES:" & @CRLF $sPageSource &= "// @=PAUSE FOR 3 SECONDS, #=FLASH FOR 3 SECONDS, ^=SCROLL UP EFFECT, _=SUN EFFECT, $=SPLIT EFFECT" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "//EXAMPLE: var message=""_ Dynamic^^ Drive! # For the best dhtml scripts... www.dynamic.drive.com "";" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "var message=""HI EVERYONE@ LARSJ HAS DONE A VERY GOOD JOB# WEBVIEW2^^ A POWERFUL TOOL !!!@$@ A NEW SUN HAS RISEN@_ "";" & @CRLF $sPageSource &= "var LEDonColor='Red'; //color of the LEDs when they are on" & @CRLF $sPageSource &= "var LEDoffColor='#7D0605'; //color of the LEDs when they are off" & @CRLF $sPageSource &= "startXPos=10; //start of horizontal position eg. startXPos=20; places the leds 20 pixels from left" & @CRLF $sPageSource &= "startYPos=10; //start of vertical position" & @CRLF $sPageSource &= "//____________________END CONFIGURATION AREA__________________" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "var IE=( document.all ) ? true:false; var NS=( document.layers ) ? true:false; var W3C=( ( document.getElementById ) && ( !IE ) ) ? true:false;" & @CRLF $sPageSource &= "var d=document; if ( window.offscreenBuffering ) window.offscreenBuffering = true;" & @CRLF $sPageSource &= "function getCSS( id ) {" & @CRLF $sPageSource &= " if ( IE ) return d.all[id] //IE" & @CRLF $sPageSource &= " else if ( NS ) return d.layers[id] //NS4" & @CRLF $sPageSource &= " else return d.getElementById( id )//W3C" & @CRLF $sPageSource &= "}" & @CRLF $sPageSource &= "var alphabet=new Array( 44 );" & @CRLF $sPageSource &= "alphabet[0]=new Array( ""0111111"",""1001000"",""1001000"",""1001000"",""0111111"" ); alphabet[1]=new Array( ""1111111"",""1001001"",""1001001"",""1001001"",""0110110"" );//B" & @CRLF $sPageSource &= "alphabet[2]=new Array( ""0111110"",""1000001"",""1000001"",""1000001"",""0100010"" ); alphabet[3]=new Array( ""1111111"",""1000001"",""1000001"",""1000001"",""0111110"" );//D" & @CRLF $sPageSource &= "alphabet[4]=new Array( ""1111111"",""1001001"",""1001001"",""1001001"" ); alphabet[5]=new Array( ""1111111"",""1001000"",""1001000"",""1001000"" );//F" & @CRLF $sPageSource &= "alphabet[6]=new Array( ""0111110"",""1000001"",""1000001"",""1001001"",""0101110"" ); alphabet[7]=new Array( ""1111111"",""0001000"",""0001000"",""0001000"",""1111111"" );//H" & @CRLF $sPageSource &= "alphabet[8]=new Array( ""1000001"",""1111111"",""1000001"" ); alphabet[9]=new Array( ""0000110"",""0000001"",""0000001"",""0000001"",""1111110"" );//J" & @CRLF $sPageSource &= "alphabet[10]=new Array( ""1111111"",""0001000"",""0010100"",""0100010"",""1000001"" ); alphabet[11]=new Array( ""1111111"",""0000001"",""0000001"",""0000001"" );//L" & @CRLF $sPageSource &= "alphabet[12]=new Array( ""1111111"",""0010000"",""0001000"",""0010000"",""1111111"" ); alphabet[13]=new Array( ""1111111"",""0010000"",""0001000"",""0000100"",""1111111"" );//N" & @CRLF $sPageSource &= "alphabet[14]=new Array( ""0111110"",""1000001"",""1000001"",""1000001"",""0111110"" ); alphabet[15]=new Array( ""1111111"",""1001000"",""1001000"",""1001000"",""0110000"" );//P" & @CRLF $sPageSource &= "alphabet[16]=new Array( ""0111110"",""1000001"",""1000001"",""1000011"",""0111111"" ); alphabet[17]=new Array( ""1111111"",""1001000"",""1001100"",""1001010"",""0110001"" );//R" & @CRLF $sPageSource &= "alphabet[18]=new Array( ""0110010"",""1001001"",""1001001"",""1001001"",""0100110"" ); alphabet[19]=new Array( ""1000000"",""1000000"",""1111111"",""1000000"",""1000000"" );//T" & @CRLF $sPageSource &= "alphabet[20]=new Array( ""1111110"",""0000001"",""0000001"",""0000001"",""1111110"" ); alphabet[21]=new Array( ""1110000"",""0001100"",""0000011"",""0001100"",""1110000"" );//V" & @CRLF $sPageSource &= "alphabet[22]=new Array( ""1111110"",""0000001"",""0000010"",""0001100"",""0000010"",""0000001"",""1111110"" ); alphabet[23]=new Array( ""1100011"",""0010100"",""0001000"",""0010100"",""1100011"" );//X" & @CRLF $sPageSource &= "alphabet[24]=new Array( ""1100000"",""0010000"",""0001111"",""0010000"",""1100000"" ); alphabet[25]=new Array( ""1000011"",""1000101"",""1001001"",""1010001"",""1100001"" );//Z" & @CRLF $sPageSource &= "alphabet[26]=new Array( ""0000000"",""0000000"",""0000000"",""0000000"" ); alphabet[27]=new Array( ""0000000"",""0000001"",""0000000"",""0000000"",""0000000"" );//PERIOD" & @CRLF $sPageSource &= "alphabet[28]=new Array( ""0000000"",""0000000"",""1111101"",""0000000"",""0000000"" );//!" & @CRLF $sPageSource &= "alphabet[29]=new Array( ""0100001"",""1111111"",""0000001"" ); alphabet[30]=new Array( ""0100011"",""1000101"",""1001001"",""1001001"",""0110001"" );//2" & @CRLF $sPageSource &= "alphabet[31]=new Array( ""0100010"",""1001001"",""1001001"",""1001001"",""0110110"" ); alphabet[32]=new Array( ""0001000"",""0011000"",""0101000"",""1111111"",""0001000"" );//4" & @CRLF $sPageSource &= "alphabet[33]=new Array( ""1111001"",""1001001"",""1001001"",""1001001"",""1000110"" ); alphabet[34]=new Array( ""0111110"",""1001001"",""1001001"",""1001001"",""0100110"" );//6" & @CRLF $sPageSource &= "alphabet[35]=new Array( ""1000011"",""1000100"",""1001000"",""1110000"" ); alphabet[36]=new Array( ""0110110"",""1001001"",""1001001"",""1001001"",""0110110"" );//8" & @CRLF $sPageSource &= "alphabet[37]=new Array( ""0110010"",""1001001"",""1001001"",""1001001"",""0111110"" ); alphabet[38]=new Array( ""0000001"",""0000010"",""0000000"" );//COMMA" & @CRLF $sPageSource &= "alphabet[39]=new Array( ""XXXXXXX"" );//PAUSE ( @ )" & @CRLF $sPageSource &= "alphabet[40]=new Array( ""YYYYYYY"" );//FLASH ( # )" & @CRLF $sPageSource &= "alphabet[41]=new Array( ""DDDDDDD"" );//SCROLL UP EFFECT ( ^ )" & @CRLF $sPageSource &= "alphabet[42]=new Array( ""SSSSSSS"" );//SUN EFFECT ( _ )" & @CRLF $sPageSource &= "alphabet[43]=new Array( ""0100000"",""1000000"",""1001101"",""1001000"",""0110000"" );//?" & @CRLF $sPageSource &= "alphabet[44]=new Array( ""QQQQQQQ"" );//SPLIT EFFECT ( $ )" & @CRLF $sPageSource &= "" & @CRLF $sPageSource &= "message=message.toUpperCase(); //make message uppercase" & @CRLF $sPageSource &= "var messageArray=new Array(); //make messageArray-an array of the letters in the message" & @CRLF $sPageSource &= "var columnCount=0; //variable to count columns in messageArray.length" & @CRLF $sPageSource &= "for ( i=0; i<message.length; i++ ){ //iterate through the characters in the message" & @CRLF $sPageSource &= " letterNum=message.charCodeAt( i ); //assign proper letter code ( alphabet array )" & @CRLF $sPageSource &= " if ( ( letterNum>=65 ) && ( letterNum<=90 ) ) temp=letterNum-65; //letters" & @CRLF $sPageSource &= " else if ( letterNum==46 ) temp=27; //." & @CRLF $sPageSource &= " else if ( letterNum==32 ) temp=26; //space" & @CRLF $sPageSource &= " else if ( letterNum==33 ) temp=28; //!" & @CRLF $sPageSource &= " else if ( ( letterNum>=49 ) && ( letterNum<=57 ) ) temp=letterNum-20; //[1-9]" & @CRLF $sPageSource &= " else if ( letterNum==48 ) temp=14; //zero" & @CRLF $sPageSource &= " else if ( letterNum==63 ) temp=43; //?" & @CRLF $sPageSource &= " else if ( letterNum==44 ) temp=38; //," & @CRLF $sPageSource &= " else if ( letterNum==64 ) temp=39; //pause" & @CRLF $sPageSource &= " else if ( letterNum==35 ) temp=40; //flash effect" & @CRLF $sPageSource &= " else if ( letterNum==94 ) temp=41; //scroll up effect" & @CRLF $sPageSource &= " else if ( letterNum==95 ) temp=42; //sunrise effect" & @CRLF $sPageSource &= " else if ( letterNum==36 ) temp=44; //split effect" & @CRLF $sPageSource &= " else continue;" & @CRLF $sPageSource &= " for ( ii=0; ii<alphabet[temp].length;ii++ ){ messageArray[columnCount]=alphabet[temp][ii];columnCount++;}" & @CRLF $sPageSource &= " if ( ( temp!=39 ) && ( temp!=40 ) && ( temp!=41 ) ) {messageArray[columnCount]=""0000000"";columnCount++;}" & @CRLF $sPageSource &= "}" & @CRLF $sPageSource &= "//make 'led screen' with block 0-49 on row 1, block 50-99 on row 2, block 100-149 on row 3, etc.." & @CRLF $sPageSource &= "var b='';" & @CRLF $sPageSource &= "for ( var i=0; i<350; i++ ){//columns 50 columns x 7 rows" & @CRLF $sPageSource &= " rowPos=0+3*( i>49 )+3*( i>99 )+3*( i>149 )+3*( i>199 )+3*( i>249 )+3*( i>299 );" & @CRLF $sPageSource &= " colPos=0+150*( i>49 )+150*( i>99 )+150*( i>149 )+150*( i>199 )+150*( i>249 )+150*( i>299 );" & @CRLF $sPageSource &= " b+= ( NS ) ? '<LAYER NAME=""block' + i + '"" LEFT=""' + ( startXPos+i*3-colPos ) + '"" TOP=""' + ( startYPos+rowPos ) + '"" VISIBILITY=""show"" WIDTH=""2"" HEIGHT=""2"" BGCOLOR=""' + LEDoffColor + '""></LAYER>' : '<div id=""block' + i + '"" style=""position:absolute; left:' + ( startXPos+i*3-colPos ) + 'px; top:' + ( startYPos+rowPos ) + 'px; background-color:' + LEDoffColor +'; height: 2px; width: 2px;font-size:2px;""></div>';" & @CRLF $sPageSource &= "}" & @CRLF $sPageSource &= "document.write( b );" & @CRLF $sPageSource &= "var columnCounter=0; //keep track of postion of messageArray" & @CRLF $sPageSource &= "var bb=new Array(); //store particular LED's dom element here" & @CRLF $sPageSource &= " if ( NS ) { for ( var i=0; i<350; i++ ) { bb[i]=getCSS( ""block""+i )}}" & @CRLF $sPageSource &= " else {for ( var i=0; i<350; i++ ){ bb[i]=getCSS( ""block""+i ).style;}}" & @CRLF $sPageSource &= "var isOn=new Array();for ( var i=0; i<350; i++ ){ isOn[i]=0;} //keep track on on/off status of particular LED" & @CRLF $sPageSource &= "onArray=new Array(); var onCount=0; //array size counter" & @CRLF $sPageSource &= "function scroll(){" & @CRLF $sPageSource &= " onCount=0;" & @CRLF $sPageSource &= " if ( NS ) { for ( var i=0; i<301; i+=50 ){ if ( isOn[i]==1 ) { bb[i].bgColor=LEDoffColor; isOn[i]=0;} for ( var ii=1; ii<50; ii+=7 ){" & @CRLF $sPageSource &= " temp=i+ii;temp1=temp+1;temp2=temp+2;temp3=temp+3;temp4=temp+4;temp5=temp+5;temp6=temp+6;" & @CRLF $sPageSource &= " if ( isOn[temp]==1 ) {bb[temp].bgColor=LEDoffColor; isOn[temp]=0; bb[temp-1].bgColor=LEDonColor; isOn[temp-1]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp1]==1 ) {bb[temp1].bgColor=LEDoffColor; isOn[temp1]=0; bb[temp].bgColor=LEDonColor; isOn[temp]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp2]==1 ) {bb[temp2].bgColor=LEDoffColor; isOn[temp2]=0; bb[temp+1].bgColor=LEDonColor; isOn[temp+1]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp3]==1 ) {bb[temp3].bgColor=LEDoffColor; isOn[temp3]=0; bb[temp2].bgColor=LEDonColor; isOn[temp2]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp4]==1 ) {bb[temp4].bgColor=LEDoffColor; isOn[temp4]=0; bb[temp3].bgColor=LEDonColor; isOn[temp3]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp5]==1 ) {bb[temp5].bgColor=LEDoffColor; isOn[temp5]=0; bb[temp4].bgColor=LEDonColor; isOn[temp4]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp6]==1 ) {bb[temp6].bgColor=LEDoffColor; isOn[temp6]=0; bb[temp5].bgColor=LEDonColor; isOn[temp5]=1;}" & @CRLF $sPageSource &= " }}}" & @CRLF $sPageSource &= " else { for ( var i=0; i<301; i+=50 ){ if ( isOn[i]==1 ) { bb[i].backgroundColor=LEDoffColor; isOn[i]=0;} for ( var ii=1; ii<50; ii+=7 ){" & @CRLF $sPageSource &= " temp=i+ii;temp1=temp+1;temp2=temp+2;temp3=temp+3;temp4=temp+4;temp5=temp+5;temp6=temp+6;" & @CRLF $sPageSource &= " if ( isOn[temp]==1 ) {bb[temp].backgroundColor=LEDoffColor; isOn[temp]=0; bb[temp-1].backgroundColor=LEDonColor; isOn[temp-1]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp1]==1 ) {bb[temp1].backgroundColor=LEDoffColor; isOn[temp1]=0; bb[temp].backgroundColor=LEDonColor; isOn[temp]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp2]==1 ) {bb[temp2].backgroundColor=LEDoffColor; isOn[temp2]=0; bb[temp+1].backgroundColor=LEDonColor; isOn[temp+1]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp3]==1 ) {bb[temp3].backgroundColor=LEDoffColor; isOn[temp3]=0; bb[temp2].backgroundColor=LEDonColor; isOn[temp2]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp4]==1 ) {bb[temp4].backgroundColor=LEDoffColor; isOn[temp4]=0; bb[temp3].backgroundColor=LEDonColor; isOn[temp3]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp5]==1 ) {bb[temp5].backgroundColor=LEDoffColor; isOn[temp5]=0; bb[temp4].backgroundColor=LEDonColor; isOn[temp4]=1;}" & @CRLF $sPageSource &= " if ( isOn[temp6]==1 ) {bb[temp6].backgroundColor=LEDoffColor; isOn[temp6]=0; bb[temp5].backgroundColor=LEDonColor; isOn[temp5]=1;}" & @CRLF $sPageSource &= " }}}" & @CRLF $sPageSource &= " temp=messageArray[columnCounter]; flag=temp.charAt( 0 );//GET NEW COLUMN" & @CRLF $sPageSource &= " if ( temp.charAt( 1 )==""1"" ) {isOn[99]=1;} if ( temp.charAt( 2 )==""1"" ) {isOn[149]=1} if ( temp.charAt( 3 )==""1"" ) {isOn[199]=1}" & @CRLF $sPageSource &= " if ( temp.charAt( 4 )==""1"" ) {isOn[249]=1} if ( temp.charAt( 5 )==""1"" ) {isOn[299]=1} if ( temp.charAt( 6 )==""1"" ) {isOn[349]=1}" & @CRLF $sPageSource &= " if ( flag==""0"" ) {} else if ( flag==""1"" ) {isOn[49]=1;} else if ( flag==""X"" ) {pauseScroll();} else if ( flag==""Y"" ) {flashScroll();}" & @CRLF $sPageSource &= " else if ( flag==""D"" ) {dropEffect();} else if ( flag==""S"" ) {sunRiseEffect();} else if ( flag==""Q"" ) {splitEffect();}" & @CRLF $sPageSource &= " columnCounter++; if( columnCounter==columnCount ) columnCounter=0;" & @CRLF $sPageSource &= "}" & @CRLF $sPageSource &= "//______________pause effect________________" & @CRLF $sPageSource &= "function pauseScroll(){ clearInterval( loop ); setTimeout( ""LEDinit()"",3000 );}" & @CRLF $sPageSource &= "//______________onArray Section_____________" & @CRLF $sPageSource &= "onArray=new Array(); var onCount=0; //array size counter" & @CRLF $sPageSource &= "function makeOnArray(){ clearInterval( loop ); onCount=0; for ( var i=0; i<700; i++ ){if ( isOn[i]==1 ) {onArray[onCount]=i; onCount++;};}//make onArray of 'on' LEDS" & @CRLF $sPageSource &= "}//_________________________________" & @CRLF $sPageSource &= "//_______________flash effect_______________" & @CRLF $sPageSource &= "var flashCount=0;" & @CRLF $sPageSource &= "function flashScroll(){ makeOnArray(); flashCount=0; if ( NS ) {setTimeout( ""flashItNS()"",250 );} else {setTimeout( ""flashIt()"",250 );}}" & @CRLF $sPageSource &= "function flashItNS(){ flashCount++;" & @CRLF $sPageSource &= " if ( flashCount<14 ) {" & @CRLF $sPageSource &= " if ( flashCount % 2 == 0 ){ for ( var i=0; i<onCount; i++ ){ isOn[onArray[i]]=0;bb[onArray[i]].bgColor=LEDoffColor;}}" & @CRLF $sPageSource &= " else {for ( var i=0; i<onCount; i++ ){isOn[onArray[i]]=1;bb[onArray[i]].bgColor=LEDonColor;}}" & @CRLF $sPageSource &= " setTimeout( ""flashItNS()"",250 );" & @CRLF $sPageSource &= " }" & @CRLF $sPageSource &= " else {flashCount=0; setTimeout( ""LEDinit()"",250 );}" & @CRLF $sPageSource &= "}" & @CRLF $sPageSource &= "function flashIt(){ flashCount++;" & @CRLF $sPageSource &= " if ( flashCount<14 ) {" & @CRLF $sPageSource &= " if ( flashCount % 2 == 0 ){ for ( var i=0; i<onCount; i++ ){ isOn[onArray[i]]=0;bb[onArray[i]].backgroundColor=LEDoffColor;}}" & @CRLF $sPageSource &= " else {for ( var i=0; i<onCount; i++ ){isOn[onArray[i]]=1;bb[onArray[i]].backgroundColor=LEDonColor;}}" & @CRLF $sPageSource &= " setTimeout( ""flashIt()"",250 );" & @CRLF $sPageSource &= " }" & @CRLF $sPageSource &= " else {flashCount=0; setTimeout( ""LEDinit()"",250 );}" & @CRLF $sPageSource &= "}//_________________________________" & @CRLF $sPageSource &= "//____________scroll up effect______________" & @CRLF $sPageSource &= "dropArray=new Array();" & @CRLF $sPageSource &= "function dropEffect(){makeOnArray(); for ( var i=0; i<onCount; i++ ){ dropArray[i]=onArray[i]; } if ( NS ) {dropItNS();} else {dropIt();}}" & @CRLF $sPageSource &= "var dropCount=0;" & @CRLF $sPageSource &= "function dropItNS(){" & @CRLF $sPageSource &= " if ( dropCount<7 ){for ( var i=0; i<onCount; i++ ){ bb[dropArray[i]].bgColor=LEDoffColor; }" & @CRLF $sPageSource &= " for ( var i=0; i<onCount; i++ ){ temp=dropArray[i]; temp-=50;if ( temp<0 ) temp+=350;bb[temp].bgColor=LEDonColor; dropArray[i]=temp;}" & @CRLF $sPageSource &= " dropCount++; setTimeout( ""dropItNS()"",100 );" & @CRLF $sPageSource &= " } else {dropCount=0;setTimeout( ""LEDinit()"",100 );}" & @CRLF $sPageSource &= "}//_________________________________" & @CRLF $sPageSource &= "function dropIt(){" & @CRLF $sPageSource &= " if ( dropCount<7 ){ for ( var i=0; i<onCount; i++ ){ bb[dropArray[i]].backgroundColor=LEDoffColor; }" & @CRLF $sPageSource &= " for ( var i=0; i<onCount; i++ ){ temp=dropArray[i]; temp-=50; if ( temp<0 ) temp+=350; bb[temp].backgroundColor=LEDonColor; dropArray[i]=temp;}" & @CRLF $sPageSource &= " dropCount++; setTimeout( ""dropIt()"",100 );" & @CRLF $sPageSource &= " } else {dropCount=0;setTimeout( ""LEDinit()"",100 );}" & @CRLF $sPageSource &= "}//_________________________________" & @CRLF $sPageSource &= "//____________sunrise effect________________" & @CRLF $sPageSource &= "sunRiseCounter=0;sunRiseArray=new Array();" & @CRLF $sPageSource &= "sunRiseArray[0]=new Array( 50,101,102,103,154,155,156,207,208,259,260,261,212,163,164,115,116,117,168,169,170,221,222,223,274,275,276,227,228,179,180,131,132,83,134,135,186,187,238,239,240,241,292,293,344,295,296,247,198 );//Hills" & @CRLF $sPageSource &= "sunRiseArray[1]=new Array( 224,225,226 ); sunRiseArray[2]=new Array( 174,175,176,177 ); sunRiseArray[3]=new Array( 173,124,125,126,127,128,178 ); sunRiseArray[4]=new Array( 172,123,74,75,76,77,129 ); sunRiseArray[5]=new Array( 171,122,73,24,25,26,27,78,79,130 );" & @CRLF $sPageSource &= "function sunRiseEffect() { makeOnArray(); for ( var i=0; i<onCount; i++ ){ isOn[onArray[i]]=0; if ( !NS ) {bb[onArray[i]].backgroundColor=LEDoffColor;} else {bb[onArray[i]].bgColor=LEDoffColor;}}" & @CRLF $sPageSource &= " setTimeout( ""riseEffectUp()"",1000 );}" & @CRLF $sPageSource &= "function riseEffectUp() {" & @CRLF $sPageSource &= " if ( !NS ) { for ( var ii=0; ii<sunRiseArray[sunRiseCounter].length; ii++ ) {isOn[sunRiseArray[sunRiseCounter][ii]]=1;bb[sunRiseArray[sunRiseCounter][ii]].backgroundColor=LEDonColor;}}" & @CRLF $sPageSource &= " else {for ( var ii=0; ii<sunRiseArray[sunRiseCounter].length; ii++ ) {isOn[sunRiseArray[sunRiseCounter][ii]]=1;bb[sunRiseArray[sunRiseCounter][ii]].bgColor=LEDonColor;}}" & @CRLF $sPageSource &= " sunRiseCounter++; if ( sunRiseCounter>5 ) {sunRiseCounter=5;setTimeout( ""riseEffectDown()"",2000 );} else {setTimeout( ""riseEffectUp()"",250 );}}" & @CRLF $sPageSource &= "function riseEffectDown() {" & @CRLF $sPageSource &= " if ( !NS ) {for ( var ii=0; ii<sunRiseArray[sunRiseCounter].length; ii++ ) {isOn[sunRiseArray[sunRiseCounter][ii]]=0;bb[sunRiseArray[sunRiseCounter][ii]].backgroundColor=LEDoffColor;}}" & @CRLF $sPageSource &= " else {for ( var ii=0; ii<sunRiseArray[sunRiseCounter].length; ii++ ) {isOn[sunRiseArray[sunRiseCounter][ii]]=0;bb[sunRiseArray[sunRiseCounter][ii]].bgColor=LEDoffColor;}}" & @CRLF $sPageSource &= " sunRiseCounter--; if ( sunRiseCounter<1 ) {sunRiseCounter=0;setTimeout( ""LEDinit()"",1500 );}" & @CRLF $sPageSource &= " else {setTimeout( ""riseEffectDown()"",250 );}" & @CRLF $sPageSource &= "}//____________________________________" & @CRLF $sPageSource &= "//____________split scroll effect___________" & @CRLF $sPageSource &= "var splitCount=0;" & @CRLF $sPageSource &= "function splitEffect() { makeOnArray(); for ( var i=0; i<onCount; i++ ) { dropArray[i]=onArray[i]; }" & @CRLF $sPageSource &= " if ( NS ) {setTimeout( ""splitNS()"",55 );} else if ( IE ) {setTimeout( ""splitIt()"",55 );} else {setTimeout( ""splitIt()"",100 );}" & @CRLF $sPageSource &= "}" & @CRLF $sPageSource &= "function splitIt(){ for ( i=0;i<onCount;i++ ){ temp=dropArray[i];" & @CRLF $sPageSource &= " if ( temp<150 ) { if ( temp==100 ) {bb[temp].backgroundColor=LEDoffColor; temp=149; bb[temp-1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==50 ) {bb[temp].backgroundColor=LEDoffColor; temp=99; bb[temp-1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==0 ) {bb[temp].backgroundColor=LEDoffColor; temp=49; bb[temp-1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " else {bb[temp].backgroundColor=LEDoffColor; bb[temp-1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " dropArray[i]=temp-1; }" & @CRLF $sPageSource &= " else { if ( temp==199 ) {bb[temp].backgroundColor=LEDoffColor; temp=200; bb[temp+1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==349 ) {bb[temp].backgroundColor=LEDoffColor; temp=300; bb[temp+1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==299 ) {bb[temp].backgroundColor=LEDoffColor; temp=250; bb[temp+1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==249 ) {bb[temp].backgroundColor=LEDoffColor; temp=200; bb[temp+1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " else {bb[temp].backgroundColor=LEDoffColor; bb[temp+1].backgroundColor=LEDonColor;}" & @CRLF $sPageSource &= " dropArray[i]=temp+1; }" & @CRLF $sPageSource &= " } splitCount++; if ( splitCount<49 ) {if ( IE ) {setTimeout( ""splitIt()"",55 );} else {setTimeout( ""splitIt()"",100 );} } else {splitCount=0; LEDinit();}" & @CRLF $sPageSource &= "}" & @CRLF $sPageSource &= "function splitNS(){" & @CRLF $sPageSource &= " for ( i=0;i<onCount;i++ ){ temp=dropArray[i];" & @CRLF $sPageSource &= " if ( temp<150 ) { if ( temp==100 ) {bb[temp].bgColor=LEDoffColor; temp=149; bb[temp-1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==50 ) {bb[temp].bgColor=LEDoffColor; temp=99; bb[temp-1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==0 ) {bb[temp].bgColor=LEDoffColor; temp=49; bb[temp-1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " else {bb[temp].bgColor=LEDoffColor; bb[temp-1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " dropArray[i]=temp-1; }" & @CRLF $sPageSource &= " else { if ( temp==199 ) {bb[temp].bgColor=LEDoffColor; temp=200; bb[temp+1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==349 ) {bb[temp].bgColor=LEDoffColor; temp=300; bb[temp+1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==299 ) {bb[temp].bgColor=LEDoffColor; temp=250; bb[temp+1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " else if ( temp==249 ) {bb[temp].bgColor=LEDoffColor; temp=200; bb[temp+1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " else {bb[temp].bgColor=LEDoffColor; bb[temp+1].bgColor=LEDonColor;}" & @CRLF $sPageSource &= " dropArray[i]=temp+1; }" & @CRLF $sPageSource &= " } splitCount++; if ( splitCount<49 ) {setTimeout( ""splitNS()"",55 );} else {splitCount=0; LEDinit();}" & @CRLF $sPageSource &= "}//___________________________________" & @CRLF $sPageSource &= "function LEDinit(){if ( NS ) {loop=setInterval( ""scroll()"",55 );} else if ( IE ){loop=setInterval( ""scroll()"",55 );} else {loop=setInterval( ""scroll()"",100 );}}" & @CRLF $sPageSource &= "</SCRIPT>" & @CRLF $sPageSource &= "</BODY></HTML>" & @CRLF Return $sPageSource EndFunc The code is translated to AutoIt from the C++ code in ICoreWebView2.ExecuteScript() and from this example by Chimp. Compared to the original script by Chimp the ICoreWebView2ExecuteScriptCompletedHandler callback interface is added to the code. WebView2-4.au3 is included in the 7z-file at bottom of this post. If the code here is to be a replacement for IE.au3, then I think we'll have to translate all C/C++ code in WebView2.h to AutoIt code in WV2Interfaces.au3. I'll create a new post to document the implementation of callback interfaces.1 point
-
Getting started example step 4: Navigation eventsWebView2-2.au3: #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 <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPICom.au3> #include <WinAPI.au3> Global $hGui ; Project includes #include "..\Includes\WV2Interfaces.au3" WebView2() Func WebView2() ; Create WebView2 GUI $hGui = GUICreate( "WebView2 Sample", 1200, 900, -1, -1, $WS_OVERLAPPEDWINDOW ) ; Initialize COM _WinAPI_CoInitialize( $COINIT_APARTMENTTHREADED ) ; Create callback interface and functions CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate( True ) ; Forces CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke() below to be executed ; Create callback interface and functions CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate( True ) ; Create callback interface and functions CoreWebView2NavigationStartingEventHandlerCreate( True ) ; DllCall CreateCoreWebView2EnvironmentWithOptions Local $hWebView2Loader = DllOpen( @AutoItX64 ? "WebView2Loader-x64.dll" : "WebView2Loader-x86.dll" ) Local $aRet = DllCall( $hWebView2Loader, "long", "CreateCoreWebView2EnvironmentWithOptions", "wstr", "", "wstr", "", _ "ptr", NULL, "ptr", $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler ) If @error Or $aRet[0] Then Return ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions ERR" & @CRLF ) ConsoleWrite( "CreateCoreWebView2EnvironmentWithOptions OK" & @CRLF & @CRLF ) ; Show WebView2 GUI GUISetState( @SW_SHOW ) ; 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 $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() DllClose( $hWebView2Loader ) EndFunc ; 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 ) ConsoleWrite( "IsObj( $oCoreWebView2Environment ) = " & IsObj( $oCoreWebView2Environment ) & @CRLF & @CRLF ) ; 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 ; 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 ) ; Add NavigationStarting event handler Local $tEventRegistrationToken = DllStructCreate( "uint64" ) $oCoreWebView2.add_NavigationStarting( $pCoreWebView2NavigationStartingEventHandler, $tEventRegistrationToken ) ConsoleWrite( "DllStructGetData( $tEventRegistrationToken, 1 ) = " & DllStructGetData( $tEventRegistrationToken, 1 ) & @CRLF & @CRLF ) ; Forces CoreWebView2NavigationStartingEventHandler_Invoke() below to be executed ; Navigate to web page $oCoreWebView2.Navigate( "https://www.bing.com/" ) Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ; Copied from WV2Interfaces.au3 ; Executed as a consequence of $oCoreWebView2.add_NavigationStarting() above Func CoreWebView2NavigationStartingEventHandler_Invoke( $pSelf, $ptr1, $ptr2 ) ; Ret: long Par: ptr*;ptr* ConsoleWrite( "CoreWebView2NavigationStartingEventHandler_Invoke()" & @CRLF ) ; Create CoreWebView2NavigationStartingEventArgs object $oCoreWebView2NavigationStartingEventArgs = ObjCreateInterface( $ptr2, $sIID_ICoreWebView2NavigationStartingEventArgs, $dtag_ICoreWebView2NavigationStartingEventArgs ) ConsoleWrite( "IsObj( $oCoreWebView2NavigationStartingEventArgs ) = " & IsObj( $oCoreWebView2NavigationStartingEventArgs ) & @CRLF & @CRLF ) $oCoreWebView2NavigationStartingEventArgs.AddRef() ; Prevent the object from being deleted when the function ends ; Get navigation information Local $bIsUserInitiated, $bIsRedirected $oCoreWebView2NavigationStartingEventArgs.get_IsUserInitiated( $bIsUserInitiated ) $oCoreWebView2NavigationStartingEventArgs.get_IsRedirected( $bIsRedirected ) ; Confirm navigation If $bIsUserInitiated And Not $bIsRedirected Then Local $sUri $oCoreWebView2NavigationStartingEventArgs.get_Uri( $sUri ) If MsgBox( $MB_YESNO+$MB_ICONWARNING, "Navigation warning", "You are about to navigate to: " & $sUri & @CRLF & @CRLF & "Do you want to continue?" ) = $IDNO Then $oCoreWebView2NavigationStartingEventArgs.put_Cancel( True ) $oCoreWebView2.NavigateToString( "<h1>Navigation Canceled</h1><p>You chose to cancel navigation to the following URL: " & $sUri & "</p>" ) EndIf EndIf Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $ptr1, $ptr2 EndFunc The code is translated to AutoIt from the C++ code in the Getting started example step 4, from the C++ code in ICoreWebView2.add_NavigationStarting() and from the AutoHotkey code in WebView2.ahk. In case of a CreateCoreWebView2EnvironmentWithOptions ERR in the SciTE console then the cause of the problem and the solution is described by Chimp in this post above. WebView2.h, HelloWebView.cpp and the three dll-files contained in the 7z-file are copied from the NuGet package needed to compile the C++ Getting started example. Examples: WebView2-1.au3: Getting started example step 3: WebView window WebView2-2.au3: Getting started example step 4: Navigation events (this example) WebView2-3.au3: AutoIt implementation of the AutoHotkey example WebView2-4.au3: Scripting example based on code by Chimp WebView2-5.au3: Getting started example step 5: Scripting WebView2-6.au3: Getting started example step 6: Communication (doesn't work) WebView2.7z1 point
-
Thank you @LarsJ for your suggestion I copied the dlls into the autoit path, but again without success, however I think I have found the reason for the problem: 1) after copying the 2 dll to the autoit path, the error kept occurring 2) I tried to set #RequireAdmin on the script and, at this point, the following new error window appeared: "Microsoft Edge cannot read and write to the data directory: C:\ Program Files (x86) \ AutoIt3 \ autoit3_x64.exe.WebView2 \ EBWebView" so the problem is that the AutoIt3 directory doesn't have write permission for local users. That's all. it is not necessary to copy the DLLs to a location other than the script path. my solution has been to set write/modify permissions to the AutoIt3 folder so to allow the script to create its own subfolder (on first run). Once the subfolder was created, I restored the previous permission to the AutoIt3 folder and allowed the write/modify permission only to the newly created autoit3_x64.exe.WebView2 folder This way everything works fine (... so far ...) Thanks again for your tips P.S. @LarsJ This WebView2 script you wrote is elite. I tried to study it and I see that you have for example also used portions of code (Func ObjectFromTag) that I had already seen (with awe) created by the queen of developers @trancexx in this other post. But, now as then I must give up trying to understand. This type of code intimidates me, too complex for my poor understanding of the inner workings of Windows. However I like to see powerful code like this appear on the forum thanks to programmers, like you and many others, who master these intricacies with great ease. Thanks again1 point
-
@Chimp There is nothing special you should do. Everything is in the zip file from Larsj. Extract it, compile the example script an run it. Of course you need to have the runtime libraries installed.1 point
-
Hello, and Sory for the delay. I changed a litle bit the original metro_gui udf, with starting a new theme and this function Func _CreateGroup($Text, $Left, $Top, $Width, $Height) Local $Group_Array[4] $Group_Array[1] = False ; Set hover OFF $Group_Array[2] = "0" ; Type ;~ $Group_Array[15] = GetCurrentGUI() $Group_Color = "0xFF" & Hex($Group_Color, 6) $rayon = 20 $diam = $rayon * 2 Local $Brush_group = _GDIPlus_BrushCreateSolid($Group_Color) Local $hDrawPen = _GDIPlus_PenCreate(StringReplace($hDrawPen_Color, "0x", "0xFF"), 1 ) ; taille pen contour mouse out local $Group_Graphic = _iGraphicCreate($Width, $Height, StringReplace($GUIThemeColor, "0x", "0xFF"), 5, 5 ) ;Default hover state Local $hPath1 = _GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath1, $Width - $diam - 1, 0, $diam, $diam, 270, 90) _GDIPlus_PathAddArc($hPath1, $Width - $diam - 1, $Height - $diam - 1, $diam, $diam, 0, 90) _GDIPlus_PathAddArc($hPath1, 0, $Height - $diam - 1, $diam , $diam , 90, 90) _GDIPlus_PathAddArc($hPath1, 0, 0 , $diam, $diam, 180, 90) _GDIPlus_PathCloseFigure($hPath1) _GDIPlus_GraphicsFillPath($Group_Graphic[0], $hPath1, $Brush_group) _GDIPlus_GraphicsDrawPath($Group_Graphic[0], $hPath1, $hDrawPen) _GDIPlus_BrushDispose($Brush_group) _GDIPlus_PenDispose($hDrawPen) _GDIPlus_PathDispose($hPath1) ;Set graphic and return Bitmap handle $Group_Array[0] = GUICtrlCreatePic("", $Left, $Top, $Width, $Height) $Group_Array[3] = _iGraphicCreateBitmapHandle($Group_Array[0], $Group_Graphic) ;Set GUI Resizing GUICtrlSetResizing($Group_Array[0], 768) Return $Group_Array[0] EndFunc Case "LightGray" $GUIThemeColor = "0xEAEAEA" $FontThemeColor = "0x000000" $ButtonTextColor = "0x000000" $ActiveColor = "0xFFFFFF" $InactiveColor = "0xE0E0E0" $hDrawPen_Color = "0xBDBDBD" $GUIBorderColor = "0xD8D8D8" $ButtonBKColor = "0xE0E0E0" $Group_Color = "0xF6F6F6" $CB_Radio_Color = "0xFFFFFF" $CB_Radio_Hover_Color = "0xE8E8E8" $CB_Radio_CheckMark_Color = "0xffff" I tried to obtain something near macOS style...0 points