Leaderboard
Popular Content
Showing content with the highest reputation on 04/26/2025 in all areas
-
Are you annoyed by the limitations of the standard Windows message dialog created by MsgBox? Would you like to have coloured backgrounds and text? To choose the justification and font? Do you want to be able to place the message box other than in the centre of the screen? Centred on your GUI, for example, or at a particular location on screen? What about having user-defined text on as many buttons as you need? And user-defined icons? Or a visible countdown of the timeout? Finally, would you like to choose whether the message box has a button on your already too-crowded taskbar? If the answer to any of these questions is "YES" then the ExtMsgBox UDF is for you! [NEW VERSION] 16 Feb 24 Changed: Some additional functionality added to the "TimeOut" parameter of _ExtMsgBox: - A positive integer sets the EMB timeout as before. - A negative integer will double the size of the countdown timer if it is used. - A colon-delimited string (eg: "10:5") will set the normal EMB timeout (first integer) and will also initially disable the EMB buttons for the required period (second integer). New UDF and examples in the zip. Older version changes: ChangeLog.txt As always, I realise nearly all of the DLL calls in these UDFs could be made by using commands in other UDFs like WinAPI.au3 - but as with all my UDFs (which you can find in my sig below) I am trying to prevent the need for any other include files. The UDF and examples (plus StringSize) in zip format: ExtMsgBox.zip Courteous comments and constructive criticisms welcome - guess which I prefer! M231 point
-
Although I think the best way to use WebView2 in AutoIt would be to complete and use the work started by @LarsJ in this other @mLipok's topic, now it is possible to use WebView2 in AutoIt in a much simpler way. This is possible thanks to this ocx control and thanks to @Danyfirex for his decisive contribution. Now we can easily start embedding one or more WebView2 controls in our GUI in AutoIt. What we need is: the OrdoWebView2.ocx control and the \OrdoRC6 folder. These two are installed together with other programs (in the C:\Program Files (x86)\OrdoWebView2Control folder) by running the OrdoWebView2ActiveXControl.2.0.9.exe program downloadable from this link: https://freeware.ordoconcept.net/OrdoWebview2.php by clicking on "Download OrdoWebView2 SDK" at the bottom of the screen. Or, more simply, you can find them directly attached to this post by @Danyfirex. As explained in this post on VBForums (https://www.vbforums.com/showthread.php?899415-OrdoWebview2-ActiveX-WebView2-Browser-Control-(Replacement-of-the-MS-browser-control)&p=5651133&viewfull=1#post5651133): "On the latest versions of Windows 10 and Windows 11, only the following components are needed: OrdoWebView2.ocx OrdoRC6 folder and its contents, in the same directory as OrdoWebView2.ocx Finally, you need to register OrdoWebView2.ocx with regsvr32.exe OrdoWebView2.ocx". Also: Our AutoIt script and the OrdoWebView2.au3 must also be in the same directory along with the above. I have extracted the essential parts needed to create the WebView2 object from the DanyFirex's original example and grouped them into the OrdoWebView2.au3 UDF so that it can be easily included into a program. This is just a quick draft to get you started, but it can definitely be improved. Suggestions are welcome. Here are the basic UDF and a very basic example script: Embed 4 WebView2 controls in an AutoIt GUI More scripts to follow to test the functionality and interaction between OrdoWebView2 and AutoIt. See you later. P.S. Here is a reference link to the OrdoWebView2.ocx help (https://freeware.ordoconcept.net/Help/OrdoWebView2/) OrdoWebView2.au3 ; From the following POST By DanyFirex: ; https://www.autoitscript.com/forum/topic/204362-microsoft-edge-webview2-embed-web-code-in-your-native-application/page/9/#findComment-1542694 ; ... first draft to be continue ... #include <WinAPI.au3> Global Const $gATL = DllOpen("ATL.DLL") Global Const $gOleaut32 = DllOpen("oleaut32.dll") _WinAPI_CoInitialize($COINIT_APARTMENTTHREADED) AtlAxWinInit() Global $pProgID = SysAllocString('OrdoWebView2.OrdoWebView') Func webview2_GUI_Create($w, $h, $x, $y, $hMain, _ $sEventsPrefix = '', _ ; ......................... The prefix of the functions you define to handle receiving events. The prefix is appended by the Objects event name. $sLang = "", _ ; ................................. Language defined by the 2-letter code from ISO 639. If omitted, the chosen language will be that of the user's system. $bIsPrivateNavigation = False, _ ; ............... if TRUE the browser goes into private browsing mode. Default value is False $sBrowserInstallPath = "", _ ; ................... sets the installation directory of the WebView2 fixed version. Only considered if UseEdgeFixedVersion is TRUE. $sUserDataFolder = "", _ ; ....................... defines the user's browsing data directory. If empty, use default user assignment directory. Ignored if IsPrivateNavigation is true $sAdditionalBrowserArguments = "", _ ; ........... Allows passing parameters to the Chromium WebView2 browser through command line switches. You can find a list of Chromium Command Line Switches here $iAllowSingleSignOnUsingOSPrimaryAccount = 0) ; .. Determines whether to enable single sign on with Azure Active Directory Local $hGUI_1 = GUICreate('', $w, $h, $x, $y, $WS_POPUPWINDOW) ; BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN)) Local $hResult = AtlAxCreateControl($pProgID, $hGUI_1) ; _SysFreeString($pProgID) Local $pIUnkown = AtlAxGetControl($hGUI_1) ; ConsoleWrite("AtlAxGetControl: " & $pIUnkown & @CRLF) _WinAPI_SetParent($hGUI_1, $hMain) ; trap this child gui within the main gu GUISetState(@SW_SHOW, $hGUI_1) Local $oOrdoWebView2 = ObjCreateInterface($pIUnkown, "{E54909AA-1705-44A9-8235-B24F74366B3F}") Local $oOrdoWebViewEvents = ObjEvent($oOrdoWebView2, $sEventsPrefix, "__OrdoWebView") ; ConsoleWrite("$oOrdoWebView2: " & IsObj($oOrdoWebView2) & @CRLF) ; ConsoleWrite($oOrdoWebView2.GetWebView2Version() & @CRLF) ; ConsoleWrite($oOrdoWebView2.GetMostRecentInstallPath() & @CRLF) #cs $oOrdoWebView2.Anchor = True $oOrdoWebView2.Search_URL = "https://search.yahoo.com/search?p=%1" $oOrdoWebView2.HomeURL = "http://www.google.com" $oOrdoWebView2.SearchEngine = 2 $oOrdoWebView2.SearchAuto = True #ce $oOrdoWebView2.UseEdgeFixedVersion = False $oOrdoWebView2.InitEx($sLang, $bIsPrivateNavigation, $sBrowserInstallPath, $sUserDataFolder, $sAdditionalBrowserArguments, $iAllowSingleSignOnUsingOSPrimaryAccount) While Not $oOrdoWebView2.IsWebViewInit() ;wait initialization otherwise Navigate will fail Sleep(100) WEnd Local $aReturn = [$oOrdoWebView2, $hGUI_1] Return $aReturn ; $oOrdoWebView2 EndFunc ;==>webview2_GUI_Create Func AtlAxCreateControl($pProgID, $HWND) Local $aCall = DllCall($gATL, "long", "AtlAxCreateControl", "ptr", $pProgID, "handle", $HWND, "ptr", 0, "ptr", 0) If @error Then Return SetError(1, 0, -1) Return $aCall[0] EndFunc ;==>AtlAxCreateControl Func AtlAxGetControl($HWND) Local $aCall = DllCall($gATL, "long", "AtlAxGetControl", "handle", $HWND, "ptr*", 0) If @error Then Return SetError(1, 0, -1) Return $aCall[2] EndFunc ;==>AtlAxGetControl Func AtlAxWinInit() Local $aCall = DllCall($gATL, "bool", "AtlAxWinInit") If @error Then Return SetError(1, 0, -1) Return $aCall[0] EndFunc ;==>AtlAxWinInit Func _SysFreeString($pBSTR) ; Author: Prog@ndy If Not $pBSTR Then Return SetError(2, 0, 0) DllCall($gOleaut32, "none", "SysFreeString", "ptr", $pBSTR) If @error Then Return SetError(1, 0, 0) EndFunc ;==>_SysFreeString Func SysAllocString($str) ; Author: monoceres Local $aCall = DllCall($gOleaut32, "ptr", "SysAllocString", "wstr", $str) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ;==>SysAllocString OrdoWebView2_Demo.au3 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "OrdoWebView2.au3" Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") _TestOrdoWebView() Func _TestOrdoWebView() Local $hMain_GUI = GUICreate("Main GUI", 990, 810, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN)) GUISetState(@SW_SHOW, $hMain_GUI) Local $hAutoIt_Button_1 = GUICtrlCreateButton("test", 10, 785) ; Create 4 controls Local $aWebView1 = webview2_GUI_Create(480, 380, 10, 10, $hMain_GUI) Local $aWebView2 = webview2_GUI_Create(480, 380, 500, 10, $hMain_GUI) Local $aWebView3 = webview2_GUI_Create(480, 380, 10, 400, $hMain_GUI) Local $aWebView4 = webview2_GUI_Create(480, 380, 500, 400, $hMain_GUI) ; Navigate to web pages $aWebView1[0].Navigate("https://www.kevs3d.co.uk/dev/js1kdragons/") ; "http://www.3quarks.com/en/SegmentDisplay/" $aWebView2[0].Navigate("https://gridstackjs.com/demo/anijs.html") ; "https://retejs.org/") $aWebView3[0].Navigate("https://www.youtube.com/watch?v=ojBYW3ycVTE") $aWebView4[0].Navigate("https://freeware.ordoconcept.net/OrdoWebview2.php") ; "https://freeware.ordoconcept.net/Help/OrdoWebView2/" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hAutoIt_Button_1 MsgBox(0, 'AutoIt', 'Hi') EndSwitch WEnd _SysFreeString($pProgID) GUIDelete($aWebView1[1]) GUIDelete($aWebView2[1]) GUIDelete($aWebView3[1]) GUIDelete($aWebView4[1]) GUIDelete($hMain_GUI) EndFunc ;==>_TestOrdoWebView ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc1 point
-
A first attempt at interaction between AutoIt and OrdoWebView2 it seems to me that some small anomalies occur (but maybe it's me who doesn't use them correctly), such as: the value of an AutoIt variable set by reading the value of a property of a browser object is not immediately available in AutoIt, but delays must be inserted before reading its value. However, I have set 3 callback functions related to the following events: "navigation completed"; "zoom change" and "asynchronous JS result". In particular, this last event should be executed only if you use the execution of a javascript script using the RunJsAsync() method. well, although I have not used that method in the AutoIt script but have only used the RunJs() method, I see that the JSAsyncResult callback function is occasionally executed anyway (?). Well, this test script uses a web page that contains a "label" where the text changes to "I'm not a robot" only when the three red cubes have been clicked. (You could use this as a sort of graphical "CAPTCHA"). You can rotate the cube by dragging with the mouse so that any red cubes that are "on the back" come to the forefront so that you can click them. The interaction with AutoIt consists of reading the value of that JS field to check when it changes to "I'm not a robot" and acting accordingly in AutoIt. It seems to work, but I think I still need to dig deeper into this functionality. The zoom change event is executed when the browser zoom is changed. To change the zoom you can hold down the "ctrl" key on the keyboard and simultaneously rotate the mouse wheel up or down. To reset the zoom to 100% press "ctrl" and zero on the numpad. Here is the "experiment". #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "OrdoWebView2.au3" Global $bReloaded = False ; to be used in NavigationCompleted callback function _TestOrdoWebView() Func _TestOrdoWebView() Local $hMain_GUI = GUICreate("Main GUI", 500, 520, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN)) Local $hButton1 = GUICtrlCreateButton("I give up", 10, 495, 480, 20) GUISetState(@SW_SHOW, $hMain_GUI) Local $aEBWebView1 = webview2_GUI_Create(480, 480, 10, 10, $hMain_GUI, "_OrdoWebView_") ; 6° parameter: Events Callback funcion name prefix ; a javascript function to be injected in Document for a later use from AutoIt via .RunJs or .RunJsAsync $aEBWebView1[0].AddScriptToExecuteOnDocumentCreated("function getQSValue(qsExpr){return document.getElementById((qsExpr)).innerHTML}") ; Load web page $aEBWebView1[0].Navigate("https://shzlw.github.io/design/I-am-not-a-robot.html") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton1 MsgBox(0, 'AutoIt', "Test failed. Goodbye") ExitLoop EndSwitch If $aEBWebView1[0].RunJs("getQSValue", "label") = "I'm not a robot" Then MsgBox(0, 'AutoIt', "Great! You are not a robot. Welcome human!") $aEBWebView1[0].Reload Do ConsoleWrite('.') Until $bReloaded $bReloaded = False ; if there is not this MsgBox to produce a long delay sometimes the reload is executed twice MsgBox(0, 'AutoIt', "Play again") EndIf WEnd _SysFreeString($pProgID) GUIDelete($aEBWebView1[1]) GUIDelete($hMain_GUI) EndFunc ;==>_TestOrdoWebView ; --- CallBack functions --- Volatile Func _OrdoWebView_NavigationCompleted($IsSuccess, $WebErrorStatus) ConsoleWrite("_OrdoWebView_NavigationCompleted" & @CRLF) $bReloaded = True EndFunc ;==>_OrdoWebView_NavigationCompleted Volatile Func _OrdoWebView_ZoomChanged($iValue) ConsoleWrite("New Zoom Value is : " & $iValue & @CRLF) TrayTip("Zoom changed", "New zoom value is: " & $iValue, 3, 17) EndFunc ;==>_OrdoWebView_ZoomChanged Volatile Func _OrdoWebView_JSAsyncResult($vResult, $vToken, $sErrString) ConsoleWrite("Javascript result: " & $vResult & @CRLF & $vToken & @CRLF & $sErrString & @CRLF) EndFunc ;==>_OrdoWebView_JSAsyncResult1 point
-
Indeed, no need to register anything other than OrdoWebView2.ocx You just need a folder containing the files as shown in the figure below \MYFOLDER | OrdoWebView2.ocx | OrdoWebView2.au3 | OrdoWebView2_Demo.au3 | \---OrdoRC6 cairo_sqlite.dll DirectCOM.dll RC6.dll RC6Widgets.dll RegisterRC6inPlace.vbs RegisterRC6WidgetsInPlace.vbs WebView2Loader.dll _Library-Licenses.txt _Version-History.txt (You can find the necessary files in the 7z file in @Danyfirex's post as indicated in first post above) As @Ninedid, I also did the following: created a folder containing necessary files as above opened a DOS prompt with administrative rights; placed the current directory where the OrdoWebView2.ocx file is located I typed the following command: regsvr32 .\OrdoWebView2.ocx I received the popup message with the message "DllRegisterServer in .\OrdoWebView2.ocx succeeded" That's it, then running the OrdoWebView2_Demo.au3 file everything worked fine thanks all for the feedbacks1 point
-
Idk if this will make any difference, but when I registered the ocx I was inside the folder where it was located (instead of entering the full path). ps. i did not install the SDK. Just the .7z of Dany pps. you need to run it x86, it does not work x641 point