A powerful bridge that allows AutoIt to use the modern Microsoft Edge WebView2 (Chromium) engine via a C# COM wrapper. This project enables you to render modern HTML5, CSS3, and JavaScript directly inside your AutoIt applications with a 100% event-driven architecture.
đź”— link to AutoIt forum https://www.autoitscript.com/forum/topic/213375-webview2autoit-autoit-webview2-component-com-interop
- Chromium Engine: Leverage the speed and security of modern Microsoft Edge.
- Bi-directional Communication: Send messages from JS to AutoIt (
postMessage) and execute JS from AutoIt (ExecuteScript). - Event-Driven: No more
While/Sleeploops to check for updates. Uses COM Sinks for instant notifications. - Advanced JSON Handling: Includes a built-in
JsonParserfor deep-path data access (e.g.,user.items\[0].name). - Content Control: Built-in Ad-blocker, CSS injection, and Zoom control.
- Dual Architecture: Fully supports both x86 and x64 environments.
- Extension Support: Load and use Chromium extensions (unpacked).
- Advanced Cookie & CDP Control: Full cookie manipulation and raw access to Chrome DevTools Protocol.
- Kiosk & Security Mode: Enhanced methods to restrict user interaction for production environments.
-
.NET Framework 4.8 or higher.
-
Microsoft Edge WebView2 Runtime.
- The registration script will check for this and provide a download link if missing.
-
Extract the
NetWebView2Libfolder to a permanent location. -
Clean & Prepare (Essential Step):
-
If you have a previous version installed, it is highly recommended to run the included
\bin\RegCleaner.au3before registering the new version. -
This ensures that any stale registry entries from previous builds are purged, preventing "Object action failed" errors and GUID conflicts.
-
-
Registration:
-
Run
\bin\Register_web2.au3to register the library. -
This script verifies the WebView2 Runtime presence and registers
NetWebView2Lib.dllfor COM Interop on both 32-bit and 64-bit architectures.
-
-
Uninstallation:
- To remove the library from your system, simply run
\bin\Unregister.au3.
- To remove the library from your system, simply run
-
Run Examples:
- Execute any script in the
\Example\*folder to see the bridge in action.
- Execute any script in the
This project is provided "as-is". You are free to use, modify, and distribute it for both personal and commercial projects.
This update introduces critical flexibility for Chromium engine initialization, allowing developers to pass command-line arguments directly to the browser.
The new AdditionalBrowserArguments property allows you to configure the Chromium engine with specialized switches before it starts. This is essential for advanced automation, proxy configuration, and performance tuning.
- Pre-Initialization: These arguments are applied during the environment creation phase. You must set this property before calling
.Initialize(). - Powerful Switches: Support for many Chromium flags, including:
--disable-gpu: Disables hardware acceleration (useful for legacy hardware or headless snapshots).--mute-audio: Starts the browser in complete silence.--proxy-server="http://1.2.3.4:8080": Forces all traffic through a specific proxy.--incognito: Starts in private browsing mode.--user-agent="...": A secondary way to override the default identity.
The NetJson.Parser has received a massive feature upgrade to support production-grade data manipulation directly from AutoIt.
- Smart Typing & Deep Creation:
SetTokenValuenow automatically creates missing parent objects and intelligently detects data types (Boolean, Null, Numbers) while preserving leading zeros in identifiers. - Data Querying: New
GetTokenCountandGetKeysmethods allow for deep inspection of JSON structures without manual parsing. - Array Power Tools: Built-in
SortArrayandSelectUnique(deduplication) leverage native LINQ performance to manage large data sets in memory.
- ExportPageData(format, filePath): Automate saving pages as HTML or MHTML (Single File) without dialogs.
- PrintToPdfStream(): Capture the page as a PDF and retrieve it as a Base64 string directly in AutoIt—no temporary files needed.
- HiddenPdfToolbarItems: Take full control of the PDF viewer toolbar by hiding specific buttons (Save, Print, Search, etc.) through bitwise flags.
## đź“– NetWebView2Lib Version 1.4.3 - (2026-01-20) (Quick Reference)
Determines whether the user is able to use the context menu or keyboard shortcuts to open the DevTools window.
object.AreDevToolsEnabled[ = Value]
Activates or Deactivates the contextual menus of the WebView2 browser.
object.AreDefaultContextMenusEnabled[ = Value]
Determines whether the standard JavaScript dialogs (alert, confirm, prompt) are enabled.
object.AreDefaultScriptDialogsEnabled[ = Value]
Determines whether browser-specific accelerator keys are enabled (e.g., Ctrl+P, F5, etc.).
object.AreBrowserAcceleratorKeysEnabled[ = Value]
Determines whether the status bar is visible.
object.IsStatusBarEnabled[ = Value]
Gets or sets the current zoom factor (e.g., 1.0 for 100%).
object.ZoomFactor[ = Value]
Sets the background color of the WebView using a Hex string (e.g., "#FFFFFF" or "0xFFFFFF").
object.BackColor[ = Value]
Determines whether host objects (like the 'autoit' bridge) are accessible from JavaScript.
object.AreHostObjectsAllowed[ = Value]
Determines how the control is anchored when the parent window is resized.
object.Anchor[ = Value]
Note: Not supported natively by WebView2, provided for compatibility.
object.BorderStyle[ = Value]
Determines whether new window requests are allowed or redirected to the same window.
object.AreBrowserPopupsAllowed[ = Value]
Enables or disables custom context menu handling.
object.CustomMenuEnabled[ = Value]
Sets additional command-line arguments to be passed to the Chromium engine during initialization. Must be set BEFORE calling Initialize().
object.AdditionalBrowserArguments[ = Value]
HiddenPdfToolbarItems
Controls the visibility of buttons in the PDF viewer toolbar using a bitwise combination of CoreWebView2PdfToolbarItems (e.g., 1=Save, 2=Print, 4=Search).
object.HiddenPdfToolbarItems[ = Value]
Initializes the WebView2 control within a parent window.
object.Initialize(ParentHandle As HWND, UserDataFolder As String, X As Integer, Y As Integer, Width As Integer, Height As Integer)
Navigates the browser to the specified URL.
object.Navigate(Url As String)
Loads the provided HTML content directly into the browser.
object.NavigateToString(HtmlContent As String)
Executes the specified JavaScript code in the current document.
object.ExecuteScript(Script As String)
Changes the dimensions of the WebView2 control.
object.Resize(Width As Integer, Height As Integer)
Disposes of the WebView2 control and releases resources.
object.Cleanup()
Returns the Bridge object for advanced AutoIt-JavaScript interaction.
object.GetBridge()
Saves the current page as a PDF file.
object.ExportToPdf(FilePath As String)
Checks if the WebView2 control is fully initialized and ready for use.
object.IsReady()
Toggles between Native (true) and Custom (false) context menu modes.
object.SetContextMenuEnabled(Enabled As Boolean)
Locks down the WebView by disabling DevTools, Context Menus, and Zoom.
object.LockWebView()
Disables major browser features for a controlled environment.
object.DisableBrowserFeatures()
Navigates back to the previous page in history.
object.GoBack()
Navigates forward to the next page in history.
object.GoForward()
Resets the zoom factor to the default 100%.
object.ResetZoom()
Injects a block of CSS code into the current page.
object.InjectCss(CssCode As String)
Removes any CSS previously injected via InjectCss.
object.ClearInjectedCss()
Toggles visual highlights on common web elements for auditing purposes.
object.ToggleAuditHighlights(Enable As Boolean)
Enables or disables the built-in ad blocker.
object.SetAdBlock(Active As Boolean)
Adds a domain pattern to the ad block list.
object.AddBlockRule(Domain As String)
Clears all active ad block rules.
object.ClearBlockRules()
Asynchronously retrieves the full HTML source (sent via OnMessageReceived with 'HTML_SOURCE|').
object.GetHtmlSource()
Asynchronously retrieves the currently selected text (sent via OnMessageReceived with 'SELECTED_TEXT|').
object.GetSelectedText()
Sets the zoom factor (wrapper for ZoomFactor property).
object.SetZoom(Factor As Double)
Parses a JSON string into the internal JSON storage.
object.ParseJsonToInternal(Json As String)
Retrieves a value from the internal JSON storage using a path.
object.GetInternalJsonValue(Path As String)
Clears all browsing data including cookies, cache, and history.
object.ClearBrowserData()
Reloads the current page.
object.Reload()
Stops any ongoing navigation or loading.
object.Stop()
Opens the standard Print UI dialog.
object.ShowPrintUI()
Mutes or unmutes the audio output of the browser.
object.SetMuted(Muted As Boolean)
Returns true if the browser audio is currently muted.
object.IsMuted()
Sets a custom User Agent string for the browser.
object.SetUserAgent(UserAgent As String)
Returns the title of the current document.
object.GetDocumentTitle()
Returns the current URL of the browser.
object.GetSource()
Enables or disables JavaScript execution.
object.SetScriptEnabled(Enabled As Boolean)
Enables or disables the Web Message communication system.
object.SetWebMessageEnabled(Enabled As Boolean)
Enables or disables the browser status bar.
object.SetStatusBarEnabled(Enabled As Boolean)
Captures a screenshot of the current view to a file.
object.CapturePreview(FilePath As String, Format As String)
Calls a Chrome DevTools Protocol (CDP) method directly.
object.CallDevToolsProtocolMethod(MethodName As String, ParametersJson As String)
Retrieves all cookies (results sent via OnMessageReceived as 'COOKIES_B64|').
object.GetCookies(ChannelId As String)
Adds or updates a cookie in the browser.
object.AddCookie(Name As String, Value As String, Domain As String, Path As String)
Deletes a specific cookie.
object.DeleteCookie(Name As String, Domain As String, Path As String)
Deletes all cookies from the current profile.
object.DeleteAllCookies()
Opens the print dialog (via window.print()).
object.Print()
Adds a browser extension from an unpacked folder.
object.AddExtension(ExtensionPath As String)
Removes an extension by its ID.
object.RemoveExtension(ExtensionId As String)
Returns true if navigating back is possible.
object.GetCanGoBack()
Returns true if navigating forward is possible.
object.GetCanGoForward()
Returns the Process ID (PID) of the browser process.
object.GetBrowserProcessId()
URL-encodes a string. `object.EncodeURI(Value As String)
URL-decodes a string.
object.DecodeURI(Value As String)
Encodes a string to Base64 (UTF-8).
object.EncodeB64(Value As String)
Decodes a Base64 string back to plain text.
object.DecodeB64(Value As String)
Sets the zoom factor for the control.
object.SetZoomFactor(Factor As Double)
Opens the DevTools window for the current project.
object.OpenDevToolsWindow()
Gives focus to the WebView control.
object.WebViewSetFocus()
Enables or disables robust "Smart Anchor" resizing. Uses Win32 subclassing to perfectly sync with any parent window (AutoIt/Native). Sends "WINDOW_RESIZED" via OnMessageReceived on completion.
object.SetAutoResize(Enabled As Boolean)
Registers a script that will run automatically every time a new page loads.
object.AddInitializationScript(Script As String)
Binds the internal JSON data to a browser variable.
object.BindJsonToBrowser(VariableName As String)
Syncs JSON data to internal parser and optionally binds it to a browser variable.
object.SyncInternalData(Json As String, BindToVariableName As String)
Executes JavaScript on the current page immediately.
object.ExecuteScriptOnPage(Script As String)
Executes JavaScript and returns the result synchronously (Blocking wait).
object.ExecuteScriptWithResult(Script As String)
Clears the browser cache (DiskCache and LocalStorage).
object.ClearCache()
Asynchronously retrieves the entire visible text content of the document (sent via OnMessageReceived with 'Inner_Text|').
object.GetInnerText()
Exports the current page data as HTML (0) or MHTML (1). If FilePath is provided, it saves to disk; otherwise, it returns the content as a string.
object.ExportPageData(Format As Integer, FilePath As String)
Captures the current page as a PDF and returns the content as a Base64-encoded string.
object.PrintToPdfStream()
Fired when a message or notification is sent from the library to AutoIt.
object_OnMessageReceived(Message As String)
Fired when the browser starts navigating to a new URL.
object_OnNavigationStarting(Url As String)
Fired when navigation has finished.
object_OnNavigationCompleted(IsSuccess As Boolean, WebErrorStatus As Integer)
Fired when the document title changes.
object_OnTitleChanged(NewTitle As String)
Fired when the current URL changes.
object_OnURLChanged(NewUrl As String)
Fired when a custom context menu is requested (if SetContextMenuEnabled is false).
object_OnContextMenu(MenuData As String)
Fired when the zoom factor is changed.
object_OnZoomChanged(Factor As Double)
Fired when the browser receives focus.
object_OnBrowserGotFocus(Reason As Integer)
Fired when the browser loses focus.
object_OnBrowserLostFocus(Reason As Integer)
Fired when a context menu is requested (Simplified for AutoIt).
object_OnContextMenuRequested(LinkUrl As String, X As Integer, Y As Integer, SelectionText As String)
Parses a JSON string. Automatically detects if it's an Object or an Array.
bool Parse(Json As String)
Retrieves a value by JSON path (e.g., "items[0].name").
string GetTokenValue(Path As String)
Returns the count of elements if the JSON is an array (Legacy wrapper for GetTokenCount).
int GetArrayLength(Path As String)
Returns the count of elements (array items or object properties) at the specified path.
int GetTokenCount(Path As String)
Returns a delimited string of keys for the object at the specified path.
string GetKeys(Path As String, Delimiter As String)
Updates or adds a value at the specified path. Supports Deep Creation (automatic path creation) and Smart Typing (auto-detection of bool/null/numbers).
void SetTokenValue(Path As String, Value As String)
Loads JSON content directly from a file.
bool LoadFromFile(FilePath As String)
Saves the current JSON state back to a file.
bool SaveToFile(FilePath As String)
Checks if a path exists in the current JSON structure.
bool Exists(Path As String)
Clears the internal data.
void Clear()
Returns the full JSON string.
string GetJson()
Escapes a string to be safe for use in JSON.
string EscapeString(PlainText As String)
Unescapes a JSON string back to plain text.
string UnescapeString(EscapedText As String)
Returns the JSON string with nice formatting (Indented).
string GetPrettyJson()
Minifies a JSON string (removes spaces and new lines).
string GetMinifiedJson()
Merges another JSON string into the current JSON structure.
bool Merge(JsonContent As String)
Merges JSON content from a file into the current JSON structure.
bool MergeFromFile(FilePath As String)
Returns the type of the token at the specified path (e.g., Object, Array, String).
string GetTokenType(Path As String)
Removes the token at the specified path.
bool RemoveToken(Path As String)
Searches the JSON structure using a JSONPath query and returns a JSON array of results.
string Search(Query As String)
Flattens the JSON structure into a single-level object with dot-notated paths.
string Flatten()
Clones the current JSON data to another named parser instance.
bool CloneTo(ParserName As String)
Flattens the JSON structure into a table-like string with specified delimiters.
string FlattenToTable(ColDelim As String, RowDelim As String)
Encodes a string to Base64 (UTF-8).
string EncodeB64(PlainText As String)
Decodes a Base64 string back to plain text.
string DecodeB64(Base64Text As String)
Decodes a Base64 string and saves the binary content directly to a file.
bool DecodeB64ToFile(Base64Text As String, FilePath As String)
Sorts a JSON array by a specific key.
bool SortArray(ArrayPath As String, Key As String, Descending As Boolean)
Removes duplicate objects from a JSON array based on a key's value.
bool SelectUnique(ArrayPath As String, Key As String)
