|
| 1 | +#AutoIt3Wrapper_UseX64=y |
| 2 | +#AutoIt3Wrapper_Run_AU3Check=Y |
| 3 | +#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y |
| 4 | +#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 |
| 5 | + |
| 6 | +; 017-MappedFolder.au3 |
| 7 | + |
| 8 | +#include <GUIConstantsEx.au3> |
| 9 | +#include <WindowsConstants.au3> |
| 10 | + |
| 11 | +#include "..\NetWebView2Lib.au3" |
| 12 | + |
| 13 | +_Example() |
| 14 | + |
| 15 | +Func _Example() |
| 16 | + Local $oMyError = ObjEvent("AutoIt.Error", __NetWebView2_COMErrFunc) |
| 17 | + #forceref $oMyError |
| 18 | + |
| 19 | + #Region ; GUI CREATION |
| 20 | + |
| 21 | + ; Create the GUI |
| 22 | + Local $hGUI = GUICreate("WebView2 .NET Manager - MappedFolder Demo", 1000, 800, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN)) |
| 23 | + GUISetBkColor(0x1A1A1A, $hGUI) |
| 24 | + |
| 25 | + ; Initialize WebView2 Manager and register events |
| 26 | + Local $oWebV2M = _NetWebView2_CreateManager() |
| 27 | + If @error Then Return SetError(@error, @extended, $oWebV2M) |
| 28 | + |
| 29 | + ; initialize browser - put it on the GUI |
| 30 | + Local $sProfileDirectory = @ScriptDir & "\NetWebView2Lib-UserDataFolder" |
| 31 | + _NetWebView2_Initialize($oWebV2M, $hGUI, $sProfileDirectory, 0, 0, 0, 0, True, True, 1.2, "0x2B2B2B") |
| 32 | + |
| 33 | + ; Now that it is Ready, we define Mapping & Scripts |
| 34 | + Local $sLocalFolder = @ScriptDir & "\MappedFolder" |
| 35 | + _NetWebView2_SetVirtualHostNameToFolderMapping($oWebV2M, "myapp.local", $sLocalFolder, 0) |
| 36 | + |
| 37 | + ; Finish Navigate |
| 38 | + _NetWebView2_Navigate($oWebV2M, "https://myapp.local/index.html") |
| 39 | + |
| 40 | + ; show the GUI after browser was fully initialized |
| 41 | + GUISetState(@SW_SHOW) |
| 42 | + |
| 43 | + #EndRegion ; GUI CREATION |
| 44 | + |
| 45 | + |
| 46 | + #Region ; GUI Loop |
| 47 | + ; Main Loop |
| 48 | + While 1 |
| 49 | + Switch GUIGetMsg() |
| 50 | + Case $GUI_EVENT_CLOSE |
| 51 | + ExitLoop |
| 52 | + EndSwitch |
| 53 | + WEnd |
| 54 | + |
| 55 | + Local $oJSBridge |
| 56 | + _NetWebView2_CleanUp($oWebV2M, $oJSBridge) |
| 57 | + GUIDelete($hGUI) |
| 58 | + #EndRegion ; GUI Loop |
| 59 | + |
| 60 | +EndFunc ;==>_Example |
| 61 | + |
0 commit comments