-
Posts
2,705 -
Joined
-
Last visited
-
Days Won
41
Gianni last won the day on September 25
Gianni had the most liked content!
About Gianni

- Birthday 05/02/1962
Profile Information
-
Location
Italy
Gianni's Achievements
-
Parsix reacted to a post in a topic:
MAP display
-
mLipok reacted to a post in a topic:
MAP display
-
ioa747 reacted to a post in a topic:
MAP display
-
donnyh13 reacted to a post in a topic:
MAP display
-
argumentum reacted to a post in a topic:
MAP display
-
WildByDesign reacted to a post in a topic:
MAP display
-
A simple _MAPdisplay() function: displays the contents of a MAP in a TreeView handles nested MAPs if the MAP contains an array (1D or 2D), it displays the contents in a draft form; for arrays greater than 2D, the array is indicated but not expanded If an array element contains a sub-MAP, a sub-array or other "non printable" variables, it is indicated the VarType but not recursively expanded This is the UDF (2 functions). Below there is a second script with examples #include <TreeViewConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _MapDisplay ; Description ...: ; Syntax ........: _MapDisplay(Byref $mMain) ; Parameters ....: $mMain - a map. ; Return values .: None ; Author ........: Gianni Addiego ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _MapDisplay(ByRef $mMain, $bPseudoParent = False) If Not IsMap($mMain) Then Return SetError(1, 0, '') ; Create and show the GUI Local $hGUI = GUICreate("Map Display", 850, 550) Local $idTreeView = GUICtrlCreateTreeView(10, 10, 830, 530, $TVS_HASBUTTONS + $TVS_HASLINES + $TVS_LINESATROOT, $WS_EX_CLIENTEDGE) GUICtrlSetFont($idTreeView, 8.5, 0, 0, "Courier New") GUISetState(@SW_SHOW) If $bPseudoParent Then ; (virtual root) Local $__mPseudoRoot[] $__mPseudoRoot['Root'] = $mMain _MapToTreeView($__mPseudoRoot, $idTreeView) Else _MapToTreeView($mMain, $idTreeView) EndIf ; Waiting loop Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGUI) $idTreeView = 0 Return EndFunc ;==>_MapDisplay ; Ebhanced recursive function Func _MapToTreeView(ByRef $map, $idParent) Local $aKeys = MapKeys($map) Local $key, $value, $idNewParentNode Local $iDimensions, $idNodeArray1D, $idNodeArray2D Local $iRows, $iColumns, $sRowText, $vCheckType For $i = 0 To UBound($aKeys) - 1 $key = $aKeys[$i] $value = $map[$key] ; Nested MAP If IsMap($value) Then $idNewParentNode = GUICtrlCreateTreeViewItem("[" & $key & "] (MAP)", $idParent) _MapToTreeView($value, $idNewParentNode) ; Array (1D or 2D) ElseIf IsArray($value) Then ; Check the number of array dimensions $iDimensions = UBound($value, $UBOUND_DIMENSIONS) If $iDimensions = 1 Then ; 1D Array Management $idNodeArray1D = GUICtrlCreateTreeViewItem("[" & $key & "] (1D ARRAY)", $idParent) For $j = 0 To UBound($value) - 1 $vCheckType = IsArray($value[$j]) ? '{Array}' _ : IsMap($value[$j]) ? '{MAP}' _ : IsObj($value[$j]) ? '{Object}' _ : IsDllStruct($value[$j]) ? '{DLLStruct}' _ : IsFunc($value[$j]) ? '{Function}' _ : $value[$j] GUICtrlCreateTreeViewItem("[" & $j & "]: " & $vCheckType, $idNodeArray1D) Next ElseIf $iDimensions = 2 Then ; 2D Array Management (Horizontal Columns) $idNodeArray2D = GUICtrlCreateTreeViewItem("[" & $key & "] (2D ARRAY)", $idParent) $iRows = UBound($value, $UBOUND_ROWS) $iColumns = UBound($value, $UBOUND_COLUMNS) For $r = 0 To $iRows - 1 $sRowText = "Row " & $r & " -> " ; Loop through columns and concatenate them horizontally For $c = 0 To $iColumns - 1 ; $vCheckType = IsArray($value[$r][$c]) ? '{Array}' : IsMap($value[$r][$c]) ? '{MAP}' : $value[$r][$c] $vCheckType = IsArray($value[$r][$c]) ? '{Array}' _ : IsMap($value[$r][$c]) ? '{MAP}' _ : IsObj($value[$r][$c]) ? '{Object}' _ : IsDllStruct($value[$r][$c]) ? '{DLLStruct}' _ : IsFunc($value[$r][$c]) ? '{Function}' _ : $value[$r][$c] $sRowText &= "[" & $vCheckType & "]" ; $sRowText &= $vCheckType If $c < $iColumns - 1 Then $sRowText &= " | " ; Separator between columns Next ; Create a single item for the entire row GUICtrlCreateTreeViewItem($sRowText, $idNodeArray2D) Next Else ; Arrays with 3 or more dimensions (uncommon, showing a warning only) GUICtrlCreateTreeViewItem("[" & $key & "] (" & $iDimensions & "D ARRAY)", $idParent) ; Unsupported EndIf Else ; Standard value $vCheckType = IsArray($value) ? '{Array}' _ : IsMap($value) ? '{MAP}' _ : IsObj($value) ? '{Object}' _ : IsDllStruct($value) ? '{DLLStruct}' _ : IsFunc($value) ? '{Function}' _ : $value GUICtrlCreateTreeViewItem($key & ": " & $vCheckType, $idParent) ; place a separetor between key and data (:) ; GUICtrlCreateTreeViewItem($key & " " & $vCheckType, $idParent) ; without separetor EndIf Next EndFunc ;==>_MapToTreeView This second script contains the UDF as well as two examples that generate two fairly complex maps and display them. #include <TreeViewConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _MapDisplay ; Description ...: ; Syntax ........: _MapDisplay(Byref $mMain) ; Parameters ....: $mMain - a map. ; Return values .: None ; Author ........: Gianni Addiego ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _MapDisplay(ByRef $mMain, $bPseudoParent = False) If Not IsMap($mMain) Then Return SetError(1, 0, '') ; Create and show the GUI Local $hGUI = GUICreate("Map Display", 850, 550) Local $idTreeView = GUICtrlCreateTreeView(10, 10, 830, 530, $TVS_HASBUTTONS + $TVS_HASLINES + $TVS_LINESATROOT, $WS_EX_CLIENTEDGE) GUICtrlSetFont($idTreeView, 8.5, 0, 0, "Courier New") GUISetState(@SW_SHOW) If $bPseudoParent Then ; (virtual root) Local $__mPseudoRoot[] $__mPseudoRoot['Root'] = $mMain _MapToTreeView($__mPseudoRoot, $idTreeView) Else _MapToTreeView($mMain, $idTreeView) EndIf ; Waiting loop Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGUI) $idTreeView = 0 Return EndFunc ;==>_MapDisplay ; Ebhanced recursive function Func _MapToTreeView(ByRef $map, $idParent) Local $aKeys = MapKeys($map) Local $key, $value, $idNewParentNode Local $iDimensions, $idNodeArray1D, $idNodeArray2D Local $iRows, $iColumns, $sRowText, $vCheckType For $i = 0 To UBound($aKeys) - 1 $key = $aKeys[$i] $value = $map[$key] ; Nested MAP If IsMap($value) Then $idNewParentNode = GUICtrlCreateTreeViewItem("[" & $key & "] (MAP)", $idParent) _MapToTreeView($value, $idNewParentNode) ; Array (1D or 2D) ElseIf IsArray($value) Then ; Check the number of array dimensions $iDimensions = UBound($value, $UBOUND_DIMENSIONS) If $iDimensions = 1 Then ; 1D Array Management $idNodeArray1D = GUICtrlCreateTreeViewItem("[" & $key & "] (1D ARRAY)", $idParent) For $j = 0 To UBound($value) - 1 $vCheckType = IsArray($value[$j]) ? '{Array}' _ : IsMap($value[$j]) ? '{MAP}' _ : IsObj($value[$j]) ? '{Object}' _ : IsDllStruct($value[$j]) ? '{DLLStruct}' _ : IsFunc($value[$j]) ? '{Function}' _ : $value[$j] GUICtrlCreateTreeViewItem("[" & $j & "]: " & $vCheckType, $idNodeArray1D) Next ElseIf $iDimensions = 2 Then ; 2D Array Management (Horizontal Columns) $idNodeArray2D = GUICtrlCreateTreeViewItem("[" & $key & "] (2D ARRAY)", $idParent) $iRows = UBound($value, $UBOUND_ROWS) $iColumns = UBound($value, $UBOUND_COLUMNS) For $r = 0 To $iRows - 1 $sRowText = "Row " & $r & " -> " ; Loop through columns and concatenate them horizontally For $c = 0 To $iColumns - 1 ; $vCheckType = IsArray($value[$r][$c]) ? '{Array}' : IsMap($value[$r][$c]) ? '{MAP}' : $value[$r][$c] $vCheckType = IsArray($value[$r][$c]) ? '{Array}' _ : IsMap($value[$r][$c]) ? '{MAP}' _ : IsObj($value[$r][$c]) ? '{Object}' _ : IsDllStruct($value[$r][$c]) ? '{DLLStruct}' _ : IsFunc($value[$r][$c]) ? '{Function}' _ : $value[$r][$c] $sRowText &= "[" & $vCheckType & "]" ; $sRowText &= $vCheckType If $c < $iColumns - 1 Then $sRowText &= " | " ; Separator between columns Next ; Create a single item for the entire row GUICtrlCreateTreeViewItem($sRowText, $idNodeArray2D) Next Else ; Arrays with 3 or more dimensions (uncommon, showing a warning only) GUICtrlCreateTreeViewItem("[" & $key & "] (" & $iDimensions & "D ARRAY)", $idParent) ; Unsupported EndIf Else ; Standard value $vCheckType = IsArray($value) ? '{Array}' _ : IsMap($value) ? '{MAP}' _ : IsObj($value) ? '{Object}' _ : IsDllStruct($value) ? '{DLLStruct}' _ : IsFunc($value) ? '{Function}' _ : $value GUICtrlCreateTreeViewItem($key & ": " & $vCheckType, $idParent) ; place a separetor between key and data (:) ; GUICtrlCreateTreeViewItem($key & " " & $vCheckType, $idParent) ; without separetor EndIf Next EndFunc ;==>_MapToTreeView ; ----- Example zone ----- #include <date.au3> #include <InetConstants.au3> ; The functions Example1 and Example2 simply generate a rather complex MAP. ; Both returned MAPs are displayed by the _MapDisplay() function. _MapDisplay(Example1()) _MapDisplay(Example2()) Func Example1() ; --- Example 1 --- ; Create a MAP containing nested MAPs ; Read a file CSV containing european States, Regions, Provinces ; Read the file directly to a variable without saving it to a local file. Local $dData = InetRead("https://gisco-services.ec.europa.eu/distribution/v2/nuts/csv/NUTS_AT_2024.csv", BitAND($INET_FORCERELOAD, $INET_BINARYTRANSFER)) ; Convert the ANSI compatible binary string back into a string. Local $sData = BinaryToString($dData, $SB_UTF8) ; $SB_UTF8 (4) = binary data is UTF8 Local $a2D = _StringToArray2D($sData, ',') ; convert a CSV into a two-dimensional array ; _ArrayDisplay($a2D) Local $mContinents[] ; only Europe in this context Local $mCountries[] Local $mRegions[] ; Local $mProvinces[] Local $mMAP[] ; an empty MAP For $i = 1 To UBound($a2D) - 1 $a2D[$i][4] = StringLen($a2D[$i][1]) & $a2D[$i][2] $a2D[$i][5] = StringLeft($a2D[$i][1], 4) Next _ArraySort($a2D, 0, 1, 0, 4) ; create a nested MAP : Continents -> Countries -> Regions -> Provinces $mContinents['Europe'] = $mMAP ; first submap For $i = 1 To UBound($a2D) - 1 Switch StringLen($a2D[$i][1]) Case 2 ; State code $mContinents["Europe"][$a2D[$i][2]] = $mMAP $mCountries[$a2D[$i][1]] = $a2D[$i][2] ; <- populate the map of Countries Case 4 ; Region code $mRegions[$a2D[$i][1]] = $a2D[$i][2] ; <- populate the map of Regions ; We place the region within the map of its State $mContinents["Europe"][$mCountries[$a2D[$i][0]]][$a2D[$i][2]] = $mMAP Case 5 ; Province code ; We place the Province within the map of its Region $mContinents["Europe"][$mCountries[$a2D[$i][0]]][$mRegions[$a2D[$i][5]]][$a2D[$i][2]] = "" ; the last leaf on the branch EndSwitch Next Return $mContinents EndFunc ;==>Example1 ; --- Example 2 --- Func Example2() ; Create a MAP containing a nested MAP containing Arrays Local $mMyMAP[], $mMAP[] $mMyMAP["FirsKey"] = "Simple String" $mMyMAP["SecondKey"] = 150 ; a number $mMyMAP["Calendar"] = $mMAP Local $iYear = @YEAR ; -> Example 2026 $mMyMAP["Calendar"][$iYear] = $mMAP ; Key "Calendar" subKey 2026 contains another empty MAP For $i = 1 To 12 ; Populate the 2026 map with 12 keys each named as a month. $mMyMAP["Calendar"][$iYear][_DateToMonth($i)] = _GenerateMonth($iYear, $i) ; <- Each 2D array contains the calendar for that month. ; _ArrayDisplay($mMyMAP["Calendar"][$iYear][_DateToMonth($i)]) ; Debug Next ; Add some 1D and 2D arrays to the MAP Local $aMonths[12] = [ _ "January", "February", "March", "April", _ "May", "June", "July", "August", _ "September", "October", "November", "December" _ ] $mMyMAP["Months"] = $aMonths Local $aMonthsMultiLang = [ _ ["English", "Italiano", "Español", "Français", "Deutsch", "Português", "Nederlands", "Polski"], _ ["January", "Gennaio", "Enero", "Janvier", "Januar", "Janeiro", "Januari", "Styczeń"], _ ["February", "Febbraio", "Febrero", "Février", "Februar", "Fevereiro", "Februari", "Luty"], _ ["March", "Marzo", "Marzo", "Mars", "März", "Março", "Maart", "Marzec"], _ ["April", "Aprile", "Abril", "Avril", "April", "Abril", "April", "Kwiecień"], _ ["May", "Maggio", "Mayo", "Mai", "Mai", "Maio", "Mei", "Maj"], _ ["June", "Giugno", "Junio", "Juin", "Juni", "Junho", "Juni", "Czerwiec"], _ ["July", "Luglio", "Julio", "Juillet", "Juli", "Julho", "Juli", "Lipiec"], _ ["August", "Agosto", "Agosto", "Août", "August", "Agosto", "Augustus", "Sierpień"], _ ["September", "Settembre", "Septiembre", "Septembre", "September", "Setembro", "September", "Wrzesień"], _ ["October", "Ottobre", "Octubre", "Octobre", "Oktober", "Outubro", "Oktober", "Październik"], _ ["November", "Novembre", "Noviembre", "Novembre", "November", "Novembro", "November", "Listopad"], _ ["December", "Dicembre", "Diciembre", "Décembre", "Dezember", "Dezembro", "December", "Grudzień"] _ ] $mMyMAP["MultiLangMonths"] = $aMonthsMultiLang Local $aZodiacSigns[12] = [ _ "Aries", "Taurus", "Gemini", "Cancer", _ "Leo", "Virgo", "Libra", "Scorpio", _ "Sagittarius", "Capricorn", "Aquarius", "Pisces" _ ] $mMyMAP["ZodiacSigns"] = $aZodiacSigns Local $aFamousScientists[6] = [ _ "Albert Einstein", "Isaac Newton", "Marie Curie", _ "Galileo Galilei", "Nikola Tesla", "Charles Darwin" _ ] $mMyMAP["Scientists"] = $aFamousScientists Local $aFamousPainters[6] = [ _ "Leonardo da Vinci", "Vincent van Gogh", "Pablo Picasso", _ "Claude Monet", "Michelangelo", "Rembrandt" _ ] $mMyMAP["Painters"] = $aFamousPainters Local $aFamousMusicians[6] = [ _ "Wolfgang Amadeus Mozart", "Ludwig van Beethoven", "Johann Sebastian Bach", _ "Frederic Chopin", "Pyotr Ilyich Tchaikovsky", "Jimi Hendrix" _ ] $mMyMAP["Musicians"] = $aFamousMusicians ; ------------------------------------- ; check for VarTypes output on TreeView ; ------------------------------------- Local $aArray[2] = [1, "Example"] Local $mMAP[] Local $dBinary = Binary("0x00204060") Local $bBoolean = False Local $pPtr = Ptr(-1) Local $hWnd = WinGetHandle(AutoItWinGetTitle()) Local $iInt = 1 Local $fFloat = 2.9 Local $oObject = ObjCreate("Scripting.Dictionary") Local $sString = "Some text" Local $tStruct = DllStructCreate("wchar[256]") Local $vKeyword = Default Local $fuFunc = ConsoleWrite Local $fuUserFunc = Example1 ; a 2D array containing also a sub array a MAP and other VarTypes ; nested array, MAP and not "printable" variables are indicated but not expanded Local $aWorldCities = [["London", "New York", "Tokyo", $oObject], _ ["Rome", "Beijing", $aFamousPainters, "Moscow"], _ [MsgBox, "Munich", "Athens", "Lisbon"], _ [$mMAP, "Warsaw", "Prague", "Copenhagen"]] $mMyMAP["NestedArray"] = $aWorldCities $mMyMAP["VarTypes"] = $mMAP $mMyMAP["VarTypes"]["Array"] = $aArray $mMyMAP["VarTypes"]["Map"] = $mMAP $mMyMAP["VarTypes"]["Binary"] = $dBinary $mMyMAP["VarTypes"]["Boolean"] = $bBoolean $mMyMAP["VarTypes"]["Ptr"] = $pPtr $mMyMAP["VarTypes"]["Wnd"] = $hWnd $mMyMAP["VarTypes"]["Int"] = $iInt $mMyMAP["VarTypes"]["Float"] = $fFloat $mMyMAP["VarTypes"]["Object"] = $oObject $mMyMAP["VarTypes"]["String"] = $sString $mMyMAP["VarTypes"]["Struct"] = $tStruct $mMyMAP["VarTypes"]["Keyword"] = $vKeyword $mMyMAP["VarTypes"]["Func"] = MsgBox $mMyMAP["VarTypes"]["Func2"] = $fuFunc $mMyMAP["VarTypes"]["Func3"] = Example1 $mMyMAP["VarTypes"]["UserFunc"] = $fuUserFunc Return $mMyMAP EndFunc ;==>Example2 ; ======================== Func _StringToArray2D($sFile, $delim = ";") ; this function is extracted, adapted and slightly modified from the _FileReadToArray() function in file.au3 Local $aArray ; remove last line separator if any at the end of the file If StringRight($sFile, 1) = @LF Then $sFile = StringTrimRight($sFile, 1) If StringRight($sFile, 1) = @CR Then $sFile = StringTrimRight($sFile, 1) If StringInStr($sFile, @LF) Then $aArray = StringSplit(StringStripCR($sFile), @LF) ElseIf StringInStr($sFile, @CR) Then ;; @LF does not exist so split on the @CR $aArray = StringSplit($sFile, @CR) Else ;; unable to split the file If StringLen($sFile) Then Dim $aArray[2] = [1, $sFile] ; returns the whole file in one element Else Return SetError(2, 0, 0) ; File is empty EndIf EndIf ; now split 1D $aArray to 2D $aColumns according to delimiter Local $aColumns[$aArray[0]][1] ; create a new [2D] array with same nr. of lines of $aArray For $i = 1 To $aArray[0] ; scan all lines of the array $TempRow = StringSplit($aArray[$i], $delim, 2) ; split the line If UBound($TempRow) > UBound($aColumns, 2) Then ReDim $aColumns[$aArray[0]][UBound($TempRow)] For $ii = 0 To UBound($TempRow) - 1 $aColumns[$i - 1][$ii] = $TempRow[$ii] Next Next Return $aColumns EndFunc ;==>_StringToArray2D ;============================================== Func _GenerateMonth($iYear = @YEAR, $iMonth = @MON, $ISO = True) ; this function creates a month calendar into an 7x7 array Local $aMonth[7][7], $iDOW Local $iFirstDOW = $ISO ? _DateToDayOfWeekISO($iYear, $iMonth, 1) : _DateToDayOfWeek($iYear, $iMonth, 1) For $iDay = 1 To 7 $aMonth[0][$iDay - 1] = $ISO ? _DateDayOfWeek(Mod($iDay, 7) + $ISO, $DMW_LOCALE_SHORTNAME) : _DateDayOfWeek($iDay, $DMW_LOCALE_SHORTNAME) Next For $iDay = 1 To _DateDaysInMonth($iYear, $iMonth) $iDOW = $ISO ? _DateToDayOfWeekISO($iYear, $iMonth, $iDay) : _DateToDayOfWeek($iYear, $iMonth, $iDay) $aMonth[Int(($iFirstDOW + $iDay - 2) / 7) + 1][$iDOW - 1] = $iDay Next Return $aMonth EndFunc ;==>_GenerateMonth
-
Gianni reacted to a post in a topic:
Learning WinRt from AutoIt goal to read OCR (and understand the logic)
-
Gianni reacted to a post in a topic:
TrayToolBar v1.0.1.7
-
Gianni reacted to a post in a topic:
Gdi+ Canvas
-
Gianni reacted to a post in a topic:
WinRT - WinUI3
-
Gianni reacted to a post in a topic:
Range of Integers continuously and exactly represented in floating-point
-
Gianni reacted to a post in a topic:
BrainBake DSP
-
Gianni reacted to a post in a topic:
BrainBake DSP
-
Gianni reacted to a post in a topic:
SQLite and datetime
-
robertocm reacted to a post in a topic:
SQLite3.dll can't be loaded
-
donnyh13 reacted to a post in a topic:
A sign of life; a development update; Sven (SOLVE-SMART) says Goodbye to AutoIt (Community)!
-
Danyfirex reacted to a post in a topic:
A sign of life; a development update; Sven (SOLVE-SMART) says Goodbye to AutoIt (Community)!
-
MattyD reacted to a post in a topic:
Adding different language support to a GUI
-
Adding different language support to a GUI
Gianni replied to Bert's topic in AutoIt General Help and Support
In SciTE select UTF-8 encoding to save the script, while to save the .ini file with Notepad, select UTF-16 LE encoding -
Does anyone have thefoolonthehill's debugger?
Gianni replied to JonF's topic in AutoIt General Help and Support
At the following link the "download" button seems to work: https://web.archive.org/web/20210724011512/http://www.thefoolonthehill.net/drupal/AutoIt Debugger -
Using ObjCreateInterface() and ObjectFromTag() Functions
Gianni replied to LarsJ's topic in AutoIt Example Scripts
Okay, thanks for the clarification, @MattyD. I'll keep your suggestion in mind. ... I also read some of your interesting topics while searching for a solution on the site. 👍 Bye and thanks again. 👋 -
Using ObjCreateInterface() and ObjectFromTag() Functions
Gianni replied to LarsJ's topic in AutoIt Example Scripts
Wow! ... so the additional interfaces after the first aren't independent, but must all be chained together to form a larger interface that inherits all the methods of the previous interfaces... Enlightening! Thanks so much, DanyFirex, as always, you're a great help. You're fantastic! 👍 -
Using ObjCreateInterface() and ObjectFromTag() Functions
Gianni replied to LarsJ's topic in AutoIt Example Scripts
Hello friends In this topic, @LarsJ explained how to implement COM callback interfaces, pointers, and objects. But I'm facing a problem I can't solve right now. The WebView2 component, used as the base product on which @LarsJ's examples are based, is constantly evolving, with new features added with new versions. These additions are made by adding new interfaces. For example, the ICoreWebView2 base interface, which was present when this post was written, has been joined by the ICoreWebView2_2, ICoreWebView2_3, and so on, currently up to ICoreWebView2_28. Well, the problem I'm having is: how can I use the methods of the new interfaces in addition to those in the base interface? For example, the ICoreWebView2_8 interface contains, among others, the get_IsMuted(), put_IsMuted(), get_IsDocumentPlayingAudio() methods, which I'd like to try using as a generic example. I've prepared and simplified one of the scripts from LarsJ's examples to create a lightweight script that hopefully someone brilliant can implement into a working example. To run the script without complications, you must first download the zip file available in first post and unzip it to a folder of your choice, as long as you have write permissions to that folder. Then save the script from this post to the Examples folder present in the unzipped folder and run it. There are two AutoIt buttons overlaying the WebView2 embedded in the page: the one on the left, as an example, uses the basic version of an ICoreWebView2Environment interface to check the installed WebView2 version, while the one on the right contains a snippet that currently doesn't work (lines 87-105) The basic objects: Environment, Controller, and WebView are already instantiated and implemented in the variables $oCoreWebView2Environment, $oCoreWebView2Controller, and $oCoreWebView2. The ICoreWebView2_8 interface declarations have also been inserted at the beginning of the script. The goal now is to make this interface usable. Searching the forum, I found a post by @Danyfirex (Get CLSID from IID - Developer General Discussion - AutoIt Forums) for a similar problem. It seems that the .QueryInterface method on $oCoreWebView2 needs to be used, but my attempts have been unsuccessful. I think the problem may be both in the way I'm trying to make the ICoreWebView2_8 interface operational, and in the type declarations in $dtag_ICoreWebView2_8 on line 19. Any help is welcome, and I thank in advance anyone who knows how to proceed. #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt("MustDeclareVars", 1) #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPICom.au3> #include <WinAPI.au3> Global $hGui ; Project includes #include "..\Includes\WV2Interfaces.au3" Global $dtag_ICoreWebView2Environment_mod = StringReplace($dtag_ICoreWebView2Environment, "get_BrowserVersionString hresult();", "get_BrowserVersionString hresult(wstr*);") ; == ICoreWebView2_8 Interface ==================================================== Global Const $sIID_ICoreWebView2_8 = "{E9632730-6E1E-43AB-B7B8-7B2C9E62E094}" Global Const $dtag_ICoreWebView2_8 = _ "add_IsMutedChanged hresult(ptr*;struct*);" & _ ; ICoreWebView2IsMutedChangedEventHandler *eventHandler, EventRegistrationToken *token "remove_IsMutedChanged hresult(struct);" & _ ; EventRegistrationToken token "get_IsMuted hresult(BOOL*);" & _ ; BOOL *value "put_IsMuted hresult(BOOL);" & _ ; BOOL value "add_IsDocumentPlayingAudioChanged hresult(ptr*;struct*);" & _ ; ICoreWebView2IsDocumentPlayingAudioChangedEventHandler *eventHandler, EventRegistrationToken *token "remove_IsDocumentPlayingAudioChanged hresult(struct);" & _ ; EventRegistrationToken token "get_IsDocumentPlayingAudio hresult(bool);" ; BOOL *value ?? (BOOL* or BOOL) Global $pICoreWebView2_8, $oCoreWebView2_8, $tICoreWebView2_8 Global $tRIID_ICoreWebView2_8 = _WinAPI_GUIDFromString($sIID_ICoreWebView2_8) #cs Global Const $ICoreWebView2_8_Prefix = "CoreWebView2_8_" $pICoreWebView2_8 = ObjectFromTag($ICoreWebView2_8_Prefix, $dtag_ICoreWebView2_8, $tICoreWebView2_8) #ce ; ================================================================================= WebView2() Func WebView2() ; Create WebView2 GUI $hGui = GUICreate("WebView2 Sample", 950, 600, -1, -1, $WS_OVERLAPPEDWINDOW) ; Create AutoIt controls Local $idButton1 = GUICtrlCreateButton("WebView2 version", 10, 150, 170, 40) Local $idButton2 = GUICtrlCreateButton("Test2", 190, 150, 170, 40) Local $idLabelResult = GUICtrlCreateLabel("", 370, 150, 170, 40) ; --- Initialize and embed WebView2 ---------- _WinAPI_CoInitialize($COINIT_APARTMENTTHREADED) CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerCreate(True) CoreWebView2CreateCoreWebView2ControllerCompletedHandlerCreate(True) Local $hWebView2Loader = DllOpen(@AutoItX64 ? "WebView2Loader-x64.dll" : "WebView2Loader-x86.dll") Local $aRet = DllCall($hWebView2Loader, "long", "CreateCoreWebView2EnvironmentWithOptions", "wstr", "", "wstr", @ScriptDir, _ "ptr", Null, "ptr", $pCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler) If @error Or $aRet[0] Then Return ConsoleWrite("CreateCoreWebView2EnvironmentWithOptions ERR" & @CRLF) ; -------------------------------------------- ; after above initialization we have 3 main objects: ; $oCoreWebView2Environment ; $oCoreWebView2Controller ; $oCoreWebView2 ; Show WebView2 GUI GUISetState(@SW_SHOW) Local $vReturnedValue ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESIZED, $GUI_EVENT_RESTORE Local $tRect = _WinAPI_GetClientRect($hGui) $oCoreWebView2Controller.put_Bounds($tRect) Case $idButton1 ; I use a simple method from the basic "Environment" interface. GUICtrlSetData($idLabelResult, "") $oCoreWebView2Environment.get_BrowserVersionString($vReturnedValue) ; get a simple synchronous property MsgBox(0, '', "WebView2 Version is " & $vReturnedValue) GUICtrlSetData($idLabelResult, "current WebView2 Version is" & @CRLF & $vReturnedValue) Case $idButton2 ; attempting to use methods of a later version interface (ICoreWebView2_8) #cs From interface ICoreWebView2_8 I would like to test this 2 synchronous methods get_IsMuted() - audio status put_IsMuted() — toggle audio get_IsDocumentPlayingAudio() - Is Audio Playing? #ce ;#cs --- This attempt to use QueryInterface fails --- Local $peek Local $HRESULT $HRESULT = $oCoreWebView2.QueryInterface($tRIID_ICoreWebView2_8, $pICoreWebView2_8) ConsoleWrite('Debug: line ' & @ScriptLineNumber & ' @error: ' & @error & @TAB & _ '$HRESULT -> ' & VarGetType($HRESULT) & ' ' & $HRESULT & @TAB & _ '$pICoreWebView2_8 -> ' & VarGetType($pICoreWebView2_8) & ' ' & $pICoreWebView2_8 & @CRLF) $oCoreWebView2_8 = ObjCreateInterface($pICoreWebView2_8, $sIID_ICoreWebView2_8, $dtag_ICoreWebView2_8) ConsoleWrite('Debug: line ' & @ScriptLineNumber & ' @error: ' & @error & @TAB & _ '$oCoreWebView2_8 -> ' & VarGetType($oCoreWebView2_8) & ' ' & $oCoreWebView2_8 & @CRLF) $HRESULT = $oCoreWebView2_8.get_IsDocumentPlayingAudio($peek) ConsoleWrite('Debug: line ' & @ScriptLineNumber & ' @error: ' & @error & @TAB & _ '$HRESULT -> ' & VarGetType($HRESULT) & ' ' & $HRESULT & @TAB & _ '$Peek -> ' & VarGetType($peek) & ' ' & $peek & @CRLF) ;#ce MsgBox(32, '', "?? How do I use methods from the ICoreWebView2_8 interface " & _ "in relation to the WebView2 control referenced by the $oCoreWebView2 variable ??" & @CRLF & @CRLF & _ "Thanks") ; $oCoreWebView2.Navigate("https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_8") Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup CoreWebView2CreateCoreWebView2ControllerCompletedHandlerDelete() CoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerDelete() DllClose($hWebView2Loader) EndFunc ;==>WebView2 ; Copied from WV2Interfaces.au3 ; Executed automatically when the callback interface is created Func CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke($pSelf, $long, $ptr) ; Ret: long Par: long;ptr* ConsoleWrite("CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke" & @CRLF) ; Create CoreWebView2Environment object $oCoreWebView2Environment = ObjCreateInterface($ptr, $sIID_ICoreWebView2Environment, $dtag_ICoreWebView2Environment_mod) ConsoleWrite("IsObj( $oCoreWebView2Environment ) = " & IsObj($oCoreWebView2Environment) & @CRLF & @CRLF) $oCoreWebView2Environment.AddRef() ; Set $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler callback pointer for the WebView2 GUI $oCoreWebView2Environment.CreateCoreWebView2Controller($hGui, $pCoreWebView2CreateCoreWebView2ControllerCompletedHandler) ; Forces CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke() below to be executed Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ;==>CoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_Invoke ; Copied from WV2Interfaces.au3 ; Executed as a consequence of $oCoreWebView2Environment.CreateCoreWebView2Controller() above Func CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke($pSelf, $long, $ptr) ; Ret: long Par: long;ptr* ConsoleWrite("CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke" & @CRLF) ; Create CoreWebView2Controller object $oCoreWebView2Controller = ObjCreateInterface($ptr, $sIID_ICoreWebView2Controller, $dtag_ICoreWebView2Controller) ConsoleWrite("IsObj( $oCoreWebView2Controller ) = " & IsObj($oCoreWebView2Controller) & @CRLF) $oCoreWebView2Controller.AddRef() ; Prevent the object from being deleted when the function ends ; Set bounds for the CoreWebView2 object Local $tRect = _WinAPI_GetClientRect($hGui) $oCoreWebView2Controller.put_Bounds($tRect) ; Create CoreWebView2 object $oCoreWebView2Controller.get_CoreWebView2($pCoreWebView2) $oCoreWebView2 = ObjCreateInterface($pCoreWebView2, $sIID_ICoreWebView2, $dtag_ICoreWebView2) ConsoleWrite("IsObj( $oCoreWebView2 ) = " & IsObj($oCoreWebView2) & @CRLF & @CRLF) ; Navigate to web page $oCoreWebView2.Navigate("https://www.youtube.com/watch?v=oSexfR0Ubzw") Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $long EndFunc ;==>CoreWebView2CreateCoreWebView2ControllerCompletedHandler_Invoke ; -- Callback functions ----- Func CoreWebView2_8_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* Return 0 ; S_OK = 0x00000000 #forceref $pSelf, $pRIID, $pObj EndFunc ;==>CoreWebView2_8_QueryInterface Func CoreWebView2_8_AddRef($pSelf) ; Ret: dword Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2_8_AddRef Func CoreWebView2_8_Release($pSelf) ; Ret: dword Return 1 ; For AddRef/Release #forceref $pSelf EndFunc ;==>CoreWebView2_8_Release -
I recorded for about a minute just by pressing the Start button and without changing any settings, but when I open the file, the media player displays this message: "Cannot open Capture_..._... It's using unsupported encoding settings." (win11 x64) Am I doing something wrong?
-
Animation file size: 57182968 bytes Dimension: 1920 x 1080 Frame count: 115 Duration: 10000 ms Estimated FPS: 11.5 GPU about 40% Intel(R) HD Graphics 530 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (3.19 GHz)
-
Add a visual counter to a loop!
Gianni replied to mr-es335's topic in AutoIt General Help and Support
... or also with two counters ... one of which is a little more "visual" #include <WindowsStylesConstants.au3> Func ViewCustomCmdsList() Local $hwnd = GUICreate("", 200, 30, -1, -1, $WS_POPUP) Local $hwPrg = GUICtrlCreateProgress(0, 0, 200, 30) GUISetState(@SW_SHOWNOACTIVATE, $hwnd) WinActivate($hSAWSTUDIO_MAIN) ; ----------------------------------------------- ; Select Custom Cmds button Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 250, 378, 1, 0) Sleep(1000) ; --------------------- ; Select each Cmd in turn Sleep($iTimeOut) Send("{DOWN +3}") For $i = 2 To 27 Sleep($iTimeOut) ToolTip($i & " of 27", 450, 440) GUICtrlSetData($hwPrg, $i * (100 / 27)) Sleep($iDelayTime) Send("{DOWN}") Next ; --------------------- ToolTip("") GUIDelete($hwnd) Sleep(1000) Send("{ESC}") EndFunc ;==>ViewCustomCmdsList ; ----------------------------------------------- -
…because even mathematics knows how to send its greetings... MathGreetings.zip
-
Hi @Danyfirex Thanks so much for the helpful information 👍. I tried COMView and it's a really useful tool. Saludos and thanks for the help. 👋 P.S. COMVew working link: (https://web.archive.org/web/20250719112603/https://www.japheth.de/COMView.html) COMView download: (https://web.archive.org/web/20251029175716/https://www.japheth.de/Download/COMView.zip)
-
Thanks!, @Danyfirex, you're a champion!. Can I ask how we can get that ID so we can retrieve it for future updates on that OCX (without bothering you )? Bye, thanks again, and happy holidays everyone!
-
There's a new version of the OCX (Version 2.0.10 (2025-12-15)) on the OrdoWebView2 Control page, but unfortunately it doesn't work here. ...perhaps a new IID (interface identifier) needs to be used, but I don't know where @Danyfirex found the IID for the previous version... Does anyone have any idea where to find it?
-
Try inserting the following line immediately after the RunAs line, you should get some more information about the nature of the problem... ConsoleWrite(_WinAPI_GetLastError() & @CRLF & _WinAPI_GetLastErrorMessage() & @CRLF)