66#include < Array.au3>
77#include < GuiEdit.au3>
88#include < Misc.au3>
9+ #include " ..\NetWebView2Lib.au3"
910
1011_VersionChecker(" 1.2.0.0" ) ; DLL Version Check
1112
@@ -22,9 +23,11 @@ Global $hGUI, $idURL, $idStatusLabel
2223Global $g_bURLFullSelected = False
2324Global $g_bAutoRestoreSession = False
2425
25- Main()
26+ _Example()
27+
28+ Func _Example()
29+ ConsoleWrite (" ! MicrosoftEdgeWebview2 : version check: " & _NetWebView2_IsAlreadyInstalled() & ' ERR=' & @error & ' EXT=' & @extended & @CRLF )
2630
27- Func Main()
2831 #Region ; === Gui AutoIt ===
2932 $hGUI = GUICreate (" AutoIt" , 1285 , 850 , - 1 , - 1 , BitOR ($WS_OVERLAPPEDWINDOW , $WS_CLIPCHILDREN ))
3033 GUISetBkColor (0x1E1E1E , $hGUI )
@@ -120,7 +123,7 @@ Func Main()
120123 $oManager .GetCookies(GUICtrlRead ($idURL ))
121124
122125 Case $idBtnRestoreSession
123- Local $sURL = GUICtrlRead ($idURL )
126+ $sURL = GUICtrlRead ($idURL )
124127 Local $sDomainOnly = StringRegExpReplace ($sURL , " https?://([^/]+).*" , " $1" )
125128 _RestoreSession($sDomainOnly )
126129
@@ -147,7 +150,7 @@ Func Main()
147150 GUICtrlSetData ($idStatusLabel , " Reload" )
148151
149152 Case $idURL
150- $oManager .Navigate( GUICtrlRead ($idURL ))
153+ _NetWebView2_Navigate( $oManager , GUICtrlRead ($idURL ))
151154 GUICtrlSetData ($idStatusLabel , " Navigate: " & GUICtrlRead ($idURL ))
152155
153156 EndSwitch
@@ -159,7 +162,7 @@ Func Main()
159162
160163 WEnd
161164
162- EndFunc ; ==>Main
165+ EndFunc ; ==>_Example
163166; ---------------------------------------------------------------------------------------
164167Func _CleanExit() ; CleanExit
165168 ; Check if the object exists before calling methods to avoid COM errors during crash
@@ -170,8 +173,8 @@ Func _CleanExit() ; CleanExit
170173 ; Release the event sinks
171174 $oManager = 0
172175 $oBridge = 0
173- $oEvtManager = 0
174- $oEvtBridge = 0
176+ ; ~ $oEvtManager = 0
177+ ; ~ $oEvtBridge = 0
175178 $oMyError = 0
176179
177180 ConsoleWrite (" --> Application exited cleanly." & @CRLF )
@@ -199,7 +202,7 @@ EndFunc ;==>Bridge_OnMessageReceived
199202; ---------------------------------------------------------------------------------------
200203Func WebView_OnMessageReceived($sMessage )
201204 ConsoleWrite (" +> [CORE EVENT]: " & $sMessage & @CRLF )
202- Local Static $bIsInitialized , $ sCurentURL = " " , $sLastRestoredDomain = " "
205+ Local Static $sCurentURL = " " , $sLastRestoredDomain = " "
203206 Local $sDomain
204207
205208 ; Separating messages that have parameters (e.g. TITLE_CHANGED|...)
@@ -208,8 +211,7 @@ Func WebView_OnMessageReceived($sMessage)
208211
209212 Switch $sCommand
210213 Case " INIT_READY"
211- $bIsInitialized = True ; We note that we are finished.
212- $oManager .Navigate(GUICtrlRead ($idURL ))
214+ _NetWebView2_Navigate($oManager , GUICtrlRead ($idURL ))
213215 GUISetState (@SW_SHOW , $hGUI )
214216
215217 Case " NAV_STARTING"
@@ -368,8 +370,11 @@ Func ShowWebNotification($sMessage, $sBgColor = "#4CAF50", $iDuration = 3000) ;
368370
369371 $oManager .ExecuteScript($sJS )
370372EndFunc ; ==>ShowWebNotification
373+
371374; ---------------------------------------------------------------------------------------
372375Func WM_SIZE($hWnd , $iMsg , $wParam , $lParam ) ; Synchronizes WebView size with the GUI window
376+ #forceref $hWnd, $iMsg
377+
373378 If $wParam = 1 Then Return $GUI_RUNDEFMSG ; 1 = SIZE_MINIMIZED
374379
375380 Local $iNewWidth = BitAND ($lParam , 0xFFFF )
0 commit comments