Skip to content

Commit 34cd032

Browse files
authored
Merge pull request #75 from mlipok/patch-1
Update Examples
2 parents cc81322 + 72b4c1c commit 34cd032

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

NetWebView2Lib.au3

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,10 +1326,21 @@ Func __NetWebView2_Events__OnDownloadStateChanged($oWebV2M, $hGUI, $sState, $sUR
13261326
EndFunc ;==>__NetWebView2_Events__OnDownloadStateChanged
13271327

13281328
Func __NetWebView2_Events__OnAcceleratorKeyPressed($oWebV2M, $hGUI, $oArgs)
1329+
$hGUI = HWnd("0x" & Hex($hGUI, 16))
1330+
Local Const $sArgsList = '[Handled=' & $oArgs.Handled & '; KeyEventKind=' & $oArgs.KeyEventKind & '; KeyEventLParam=' & $oArgs.KeyEventLParam & '; VirtualKey=' & $oArgs.VirtualKey & ']'
1331+
Local Const $s_Prefix = "[NetWebView2Lib:EVENT: OnAcceleratorKeyPressed]: GUI:" & $hGUI & " ARGS: " & ((IsObj($oArgs)) ? ($sArgsList) : ('ERRROR'))
13291332
#forceref $oWebV2M
1333+
;~ https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2acceleratorkeypressedeventargs?view=webview2-dotnet-1.0.705.50
1334+
;~ ConsoleWrite($oArgs.Handled & @CRLF) ; Indicates whether the AcceleratorKeyPressed event is handled by host.
1335+
;~ ConsoleWrite($oArgs.KeyEventKind & @CRLF) ; Gets the key event kind that caused the event to run
1336+
;~ ConsoleWrite($oArgs.KeyEventLParam & @CRLF) ; Gets the LPARAM value that accompanied the window message.
1337+
;~ ConsoleWrite('>> PhysicalKeyStatus=' & $oArgs.PhysicalKeyStatus & @CRLF) ; Gets a CoreWebView2PhysicalKeyStatus representing the information passed in the LPARAM of the window message. ==> ; https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2physicalkeystatus?view=webview2-dotnet-1.0.705.50
1338+
;~ ConsoleWrite($oArgs.VirtualKey & @CRLF) ; Gets the Win32 virtual key code of the key that was pressed or released.
1339+
1340+
If $oArgs.VirtualKey = 27 Then ; ESC 27 1b 033 Escape, next character is not echoed ; https://www.autoitscript.com/autoit3/docs/appendix/ascii.htm
1341+
;~ $oWebV2M.CancelDownloads($_sURLDownload_InProgress)
1342+
EndIf
13301343

1331-
$hGUI = HWnd("0x" & Hex($hGUI, 16))
1332-
Local Const $s_Prefix = "[NetWebView2Lib:EVENT: OnAcceleratorKeyPressed]: GUI:" & $hGUI & " ARGS: " & ((IsObj($oArgs)) ? ('OBJECT') : ('ERRROR'))
13331344
__NetWebView2_Log(@ScriptLineNumber, (StringLen($s_Prefix) > 150 ? StringLeft($s_Prefix, 150) & "..." : $s_Prefix), 1)
13341345
EndFunc ;==>__NetWebView2_Events__OnAcceleratorKeyPressed
13351346
#EndRegion ; NetWebView2Lib UDF - === EVENT HANDLERS ===

examples/004-FileViewerDemo_Loop.au3

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ EndFunc ;==>__NetWebView2_freezer
148148

149149
Func _NetWebView2_NavigateToPDF($oWebV2M, $s_URL_or_FileFullPath, Const $s_Parameters = '', Const $iSleep_ms = 1000, Const $bFreeze = True)
150150
If FileExists($s_URL_or_FileFullPath) Then
151+
$s_URL_or_FileFullPath = StringReplace($s_URL_or_FileFullPath, '\', '/')
151152
$s_URL_or_FileFullPath = StringReplace($s_URL_or_FileFullPath, ' ', '%20')
152153
$s_URL_or_FileFullPath = "file:///" & $s_URL_or_FileFullPath
153154
EndIf

examples/006-DownloadDemo.au3

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
; 6-DownloadDemo.au3
88

9+
Global $_sURLDownload_InProgress = ''
910
_Example()
1011

1112
Func _Example()
@@ -80,25 +81,39 @@ Func __UserEventHandler__OnDownloadStateChanged($oWebV2M, $hGUI, $sState, $sURL,
8081
If $bProgres_State = 0 Then
8182
ProgressOn("Dowload in progress", StringRegExpReplace($sURL, '(.+/)(.+)', '$2'), $s_Message, -1, -1, BitOR($DLG_NOTONTOP, $DLG_MOVEABLE))
8283
EndIf
84+
$_sURLDownload_InProgress = $sURL
8385
ProgressSet(Round($iPercent), $s_Message)
8486
$bProgres_State = 1
8587
Case "Interrupted"
8688
ProgressSet(100, "Done", "Interrupted")
8789
Sleep(3000)
90+
ProgressOff()
8891
$bProgres_State = 0
92+
$_sURLDownload_InProgress = ''
8993
Case "Completed"
9094
ProgressSet(100, "Done", "Completed")
9195
Sleep(3000)
96+
ProgressOff()
9297
$bProgres_State = 0
98+
$_sURLDownload_InProgress = ''
9399
EndSwitch
94100
EndFunc ;==>__UserEventHandler__OnDownloadStateChanged
95101

96102
Func __UserEventHandler__OnAcceleratorKeyPressed($oWebV2M, $hGUI, $oArgs)
97-
#forceref $oWebV2M
103+
$hGUI = HWnd("0x" & Hex($hGUI, 16))
104+
Local Const $sArgsList = '[Handled=' & $oArgs.Handled & '; KeyEventKind=' & $oArgs.KeyEventKind & '; KeyEventLParam=' & $oArgs.KeyEventLParam & '; VirtualKey=' & $oArgs.VirtualKey & ']'
105+
Local Const $s_Prefix = "[USER:EVENT: OnAcceleratorKeyPressed]: GUI:" & $hGUI & " ARGS: " & ((IsObj($oArgs)) ? ($sArgsList) : ('ERRROR'))
98106

99-
#TODO parse $oArgs to check if ESC KEY is pressed ==> $oWeb.CancelDownloads("https://fosszone.csd.auth.gr/tdf/libreoffice/stable/25.8.4/win/x86_64/LibreOffice_25.8.4_Win_x86-64.msi")
107+
;~ https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2acceleratorkeypressedeventargs?view=webview2-dotnet-1.0.705.50
108+
ConsoleWrite($oArgs.Handled & @CRLF) ; Indicates whether the AcceleratorKeyPressed event is handled by host.
109+
ConsoleWrite($oArgs.KeyEventKind & @CRLF) ; Gets the key event kind that caused the event to run
110+
ConsoleWrite($oArgs.KeyEventLParam & @CRLF) ; Gets the LPARAM value that accompanied the window message.
111+
;~ ConsoleWrite('>> PhysicalKeyStatus=' & $oArgs.PhysicalKeyStatus & @CRLF) ; Gets a CoreWebView2PhysicalKeyStatus representing the information passed in the LPARAM of the window message. ==> ; https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2physicalkeystatus?view=webview2-dotnet-1.0.705.50
112+
ConsoleWrite($oArgs.VirtualKey & @CRLF) ; Gets the Win32 virtual key code of the key that was pressed or released.
113+
114+
If $oArgs.VirtualKey = 27 Then ; ESC 27 1b 033 Escape, next character is not echoed ; https://www.autoitscript.com/autoit3/docs/appendix/ascii.htm
115+
$oWebV2M.CancelDownloads($_sURLDownload_InProgress)
116+
EndIf
100117

101-
$hGUI = HWnd("0x" & Hex($hGUI, 16))
102-
Local Const $s_Prefix = "[USER:EVENT: OnAcceleratorKeyPressed]: GUI:" & $hGUI & " ARGS: " & ((IsObj($oArgs)) ? ('OBJECT') : ('ERRROR'))
103118
__NetWebView2_Log(@ScriptLineNumber, (StringLen($s_Prefix) > 150 ? StringLeft($s_Prefix, 150) & "..." : $s_Prefix), 1)
104119
EndFunc ;==>__UserEventHandler__OnAcceleratorKeyPressed

0 commit comments

Comments
 (0)