@@ -21,13 +21,13 @@ Func _Example()
2121
2222 #Region ; GUI CREATION
2323
24- HotKeySet (" {ESC} " , " _DownloadCancel" )
24+ HotKeySet (" {ESC} " , _DownloadCancel)
2525
2626 ; Create the GUI
2727 $hGUI = GUICreate (" WebView2 .NET Manager - [ Press ESC to cancell the download ]" , 1000 , 800 )
2828
2929 ; Initialize WebView2 Manager and register events
30- Local $oWebV2M = _NetWebView2_CreateManager(" Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0" , " " , " --mute-audio" )
30+ Local $oWebV2M = _NetWebView2_CreateManager(" Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0" , " __MyNetWebView2_WebViewEvents__ " , " --mute-audio" )
3131 $_g_oWeb = $oWebV2M
3232 If @error Then Return SetError (@error , @extended , $oWebV2M )
3333
@@ -36,7 +36,7 @@ Func _Example()
3636 If @error Then Return SetError (@error , @extended , $oWebV2M )
3737
3838 ; initialize browser - put it on the GUI
39- Local $sProfileDirectory = @TempDir & " \NetWebView2Lib-UserDataFolder"
39+ Local $sProfileDirectory = @TempDir & " \..\ NetWebView2Lib-UserDataFolder"
4040 _NetWebView2_Initialize($oWebV2M , $hGUI , $sProfileDirectory , 0 , 0 , 0 , 0 , True , True , True , 1.2 , " 0x2B2B2B" )
4141
4242 ; show the GUI after browser was fully initialized
@@ -74,7 +74,7 @@ EndFunc ;==>_Example
7474; =======================================================================================
7575
7676; Listen for Manager OnDownloadStarting Events
77- Func __NetWebView2_WebViewEvents__OnDownloadStarting ($sUri , $sDefaultPath )
77+ Func __MyNetWebView2_WebViewEvents__OnDownloadStarting ($sUri , $sDefaultPath )
7878 ConsoleWrite (" -> [OnDownloadStarting]:: $sUri: " & $sUri & " , $sDefaultPath: " & $sDefaultPath & @CRLF )
7979
8080 ; --- STANDARD MODE (EDGE) ---
@@ -87,29 +87,31 @@ Func __NetWebView2_WebViewEvents__OnDownloadStarting($sUri, $sDefaultPath)
8787 ; InetGet($sUri, @ScriptDir & "\Manual_Download.zip", 1, 1) ; 1 = wait for completion, 1 = force reload
8888 ; ConsoleWrite("--> Edge download CANCELLED. AutoIt is handling it via InetGet." & @CRLF)
8989
90- ConsoleWrite (" <- OnDownloadStarting event finished. Standard Edge download proceeds unless IsDownloadHandled=True." & @CRLF )
91- EndFunc
90+ ConsoleWrite (" <- OnDownloadStarting event finished. Standard Edge download proceeds unless IsDownloadHandled=True." & @CRLF )
91+ EndFunc ; ==>__MyNetWebView2_WebViewEvents__OnDownloadStarting
9292
9393; Listen for Manager OnDownloadStateChanged Events
94- Func __NetWebView2_WebViewEvents__OnDownloadStateChanged($sState , $sUri , $iTotalBytes , $iReceivedBytes )
95- Local $iPercent = 0
96- If $iTotalBytes > 0 Then $iPercent = Round (($iReceivedBytes / $iTotalBytes ) * 100 )
97-
98- ; Convert to MB for easy-to-read log
99- Local $fReceivedMB = Round ($iReceivedBytes / 1024 / 1024 )
100- Local $fTotalMB = Round ($iTotalBytes / 1024 / 1024 )
101-
102- Switch $sState
103- Case " InProgress"
104- ConsoleWrite (" ++> Downloading: " & $iPercent & " % (" & $fReceivedMB & " / " & $fTotalMB & " MB)" & @CRLF )
105- Case " Interrupted"
106- ConsoleWrite (" !!!> DOWNLOAD STOPPED/INTERRUPTED: " & $sUri & @CRLF )
107- Case " Completed"
108- ConsoleWrite (" --> DOWNLOAD FINISHED: " & $sUri & @CRLF )
109- EndSwitch
110- EndFunc
94+ Func __MyNetWebView2_WebViewEvents__OnDownloadStateChanged($sState , $sUri , $iTotalBytes , $iReceivedBytes )
95+ ConsoleWrite (" ! __MyNetWebView2_WebViewEvents__OnDownloadStateChanged" & @CRLF )
96+
97+ Local $iPercent = 0
98+ If $iTotalBytes > 0 Then $iPercent = Round (($iReceivedBytes / $iTotalBytes ) * 100 )
99+
100+ ; Convert to MB for easy-to-read log
101+ Local $iReceived_MegaBytes = Round ($iReceived_Bytes / 1024 / 1024 )
102+ Local $iTotal_MegaBytes = Round ($iTotal_Bytes / 1024 / 1024 )
103+
104+ Switch $sState
105+ Case " InProgress"
106+ ConsoleWrite (" ++> Downloading: " & $iPercent & " % (" & $iReceived_MegaBytes & " / " & $iTotal_MegaBytes & " _MegaBytes)" & @CRLF )
107+ Case " Interrupted"
108+ ConsoleWrite (" !!!> DOWNLOAD STOPPED/INTERRUPTED: " & $sUri & @CRLF )
109+ Case " Completed"
110+ ConsoleWrite (" --> DOWNLOAD FINISHED: " & $sUri & @CRLF )
111+ EndSwitch
112+ EndFunc ; ==>__MyNetWebView2_WebViewEvents__OnDownloadStateChanged
111113
112114Func _DownloadCancel()
113115 ConsoleWrite (" HotKeyPress: _DownloadCancel" & @CRLF )
114116 $_g_oWeb .CancelDownloads(" https://fosszone.csd.auth.gr/tdf/libreoffice/stable/25.8.4/win/x86_64/LibreOffice_25.8.4_Win_x86-64.msi" )
115- EndFunc
117+ EndFunc ; ==>_DownloadCancel
0 commit comments