Skip to content

Commit 3b62443

Browse files
authored
v1.5.0
1 parent 2e9365e commit 3b62443

File tree

1 file changed

+87
-26
lines changed

1 file changed

+87
-26
lines changed

README.md

Lines changed: 87 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,45 +64,50 @@ This project is provided "as-is". You are free to use, modify, and distribute it
6464
<img src="https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png" width="100%">
6565
</p>
6666

67-
## 🚀 What's New in v1.4.3 - Major Update
67+
## 🚀 What's New in v1.5.0 - Professional Snapshots & Downloads
6868

69-
This update introduces critical flexibility for Chromium engine initialization, allowing developers to pass command-line arguments directly to the browser.
69+
This major update introduces professional-grade snapshot tools using the DevTools Protocol, enhanced download management, and native HTTP status tracking for precise automation.
7070

7171
### ⚡ Key Features & Enhancements
7272

73-
#### **1. Command-Line Argument Support**
73+
#### **1. Proactive Snapshot Engine**
7474

75-
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.
75+
The new `CaptureSnapshot(cdpParameters)` method provides direct access to the `Page.captureSnapshot` CDP method. This allows you to capture MHTML snapshots or other CDP-supported formats directly as strings.
7676

77-
- **Pre-Initialization:** These arguments are applied during the environment creation phase. You must set this property **before** calling `.Initialize()`.
78-
- **Powerful Switches:** Support for many Chromium flags, including:
79-
- `--disable-gpu`: Disables hardware acceleration (useful for legacy hardware or headless snapshots).
80-
- `--mute-audio`: Starts the browser in complete silence.
81-
- `--proxy-server="http://1.2.3.4:8080"`: Forces all traffic through a specific proxy.
82-
- `--incognito`: Starts in private browsing mode.
83-
- `--user-agent="..."`: A secondary way to override the default identity.
77+
- **Unified Method:** `ExportPageData` has been consolidated into `CaptureSnapshot` for a cleaner API.
78+
- **PascalCase Compliance:** Promoted internal `captureSnapshot` to a public, standard-compliant `CaptureSnapshot` method.
79+
- **Event Consistency:** Correctly wired up `OnZoomChanged` to the browser engine's zoom events.
8480

85-
#### **2. Advanced JSON Manipulation (JsonParser)**
81+
#### **2. Custom Download Management**
8682

87-
The `NetJson.Parser` has received a massive feature upgrade to support production-grade data manipulation directly from AutoIt.
83+
You now have full control over the browser's download lifecycle.
8884

89-
- **Smart Typing & Deep Creation:** `SetTokenValue` now automatically creates missing parent objects and intelligently detects data types (Boolean, Null, Numbers) while preserving leading zeros in identifiers.
90-
- **Data Querying:** New `GetTokenCount` and `GetKeys` methods allow for deep inspection of JSON structures without manual parsing.
91-
- **Array Power Tools:** Built-in `SortArray` and `SelectUnique` (deduplication) leverage native LINQ performance to manage large data sets in memory.
85+
- **Automated Routing:** Use `SetDownloadPath(path)` to force all downloads into a specific folder or file. If a path points to an existing directory, the library intelligently appends the suggested filename.
86+
- **UI Control:** Toggle the browser's download shelf visibility using the `IsDownloadUIEnabled` property.
87+
- **Clean Event Contract**: The `OnDownloadStarting` event has been simplified to provide core metadata (URI, DefaultPath). Programmatic overrides now use the new `SetDownloadPath` and `IsDownloadHandled` properties/methods, ensuring 100% reliable path redirection from AutoIt, bypassing legacy COM `ByRef` limitations.
88+
- **Manual Mode Bypass**: Setting `IsDownloadHandled = True` during the `OnDownloadStarting` event will now immediately cancel the Edge download engine (`e.Cancel = true`). This allows AutoIt to handle the download externally (e.g., via `InetGet`) using its own logic. Active downloads can be monitored via `ActiveDownloadsList` and cancelled via `CancelDownloads()`
89+
- **IsZoomControlEnabled**: New property to enable/disable the built-in zoom mechanism (Ctrl+Wheel, etc.).
90+
- **UnLockWebView Method**: Added `UnLockWebView()` to re-enable restricted features previously disabled by `LockWebView()`.
9291

93-
#### **3. Advanced Export & PDF Management**
92+
#### **3. Native HTTP Status Tracking & Deadlock Prevention**
9493

95-
- **ExportPageData(format, filePath):** Automate saving pages as HTML or MHTML (Single File) without dialogs.
96-
- **PrintToPdfStream():** Capture the page as a PDF and retrieve it as a Base64 string directly in AutoIt—no temporary files needed.
97-
- **HiddenPdfToolbarItems:** Take full control of the PDF viewer toolbar by hiding specific buttons (Save, Print, Search, etc.) through bitwise flags.
94+
Track server responses with precision using the new `OnWebResourceResponseReceived` event. This is essential for detecting link rot (404s), server errors (500s), or validating API response responses directly from AutoIt. It provides the status code, reason phrase, and the original request URL.
9895

96+
- **Deadlock Shield:** By default, this event now only triggers for the main document (`HttpStatusCodeDocumentOnly = True`). This prevents the event flood (e.g., hundreds of 404s for missing icons or scripts) that previously caused AutoIt's GUI to deadlock.
97+
- **Granular Control:** Use `HttpStatusCodeEventsEnabled` to toggle the event entirely or disable the filter for deep resource auditing.
9998

100-
---
99+
#### **4. Memory-Based Binary Support**
100+
101+
The new `DecodeB64ToBinary(base64Text)` method decodes Base64 data directly into a raw byte array. This is perfect for high-speed processing of images or PDFs entirely in memory.
102+
103+
and a `CapturePreviewAsBase64(format)` method to Captures a screenshot of the current page content and returns it as a Base64-encoded data URL
101104

105+
---
102106
<p align="center">
103107
<img src="https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png" width="100%">
104108
</p>
105-
## 📖 NetWebView2Lib Version 1.4.3 - (2026-01-20) (Quick Reference)
109+
## 📖 NetWebView2Lib Version 1.5.0 - (Quick Reference)
110+
106111

107112
### NetWebView2Lib (ProgId: NetWebView2.Manager)
108113

@@ -164,6 +169,30 @@ Sets additional command-line arguments to be passed to the Chromium engine durin
164169
Controls the visibility of buttons in the PDF viewer toolbar using a bitwise combination of CoreWebView2PdfToolbarItems (e.g., 1=Save, 2=Print, 4=Search).
165170
`object.HiddenPdfToolbarItems[ = Value]`
166171

172+
##### IsDownloadUIEnabled
173+
Determines whether the browser's default download UI (shelf/bubble) is shown.
174+
`object.IsDownloadUIEnabled[ = Value]`
175+
176+
##### HttpStatusCodeEventsEnabled
177+
Enables or disables the `OnWebResourceResponseReceived` event entirely.
178+
`object.HttpStatusCodeEventsEnabled[ = Value]`
179+
180+
##### HttpStatusCodeDocumentOnly
181+
Determines whether `OnWebResourceResponseReceived` triggers for all resources (False) or only for the main document (True). Essential for preventing GUI deadlocks in AutoIt.
182+
`object.HttpStatusCodeDocumentOnly[ = Value]`
183+
184+
##### IsDownloadHandled
185+
Determines whether the download is handled by the application. If set to **True** during `OnDownloadStarting`, the internal Edge download is cancelled.
186+
`object.IsDownloadHandled[ = Value]`
187+
188+
##### ActiveDownloadsList
189+
Returns a pipe-separated string of all active download URIs.
190+
`object.ActiveDownloadsList`
191+
192+
##### IsZoomControlEnabled
193+
Determines whether user can zoom the page (Ctrl+MouseWheel, shortcuts).
194+
`object.IsZoomControlEnabled[ = Value]`
195+
167196
#### Method
168197

169198
##### Initialize
@@ -208,9 +237,13 @@ Toggles between Native (true) and Custom (false) context menu modes.
208237
`object.SetContextMenuEnabled(Enabled As Boolean)`
209238

210239
##### LockWebView
211-
Locks down the WebView by disabling DevTools, Context Menus, and Zoom.
240+
Locks down the WebView by disabling context menus, dev tools, zoom control, and default error pages.
212241
`object.LockWebView()`
213242

243+
##### UnLockWebView
244+
Re-enables the features previously restricted by `LockWebView()`.
245+
`object.UnLockWebView()`
246+
214247
##### DisableBrowserFeatures
215248
Disables major browser features for a controlled environment.
216249
`object.DisableBrowserFeatures()`
@@ -381,9 +414,13 @@ Encodes a string to Base64 (UTF-8).
381414
`object.EncodeB64(Value As String)`
382415

383416
##### DecodeB64
384-
Decodes a Base64 string back to plain text.
417+
Decodes a Base64 string back to **plain text** (UTF-8).
385418
`object.DecodeB64(Value As String)`
386419

420+
##### DecodeB64ToBinary
421+
Decodes a Base64 string directly into a **raw byte array**. Optimized for memory-based binary processing (e.g., images, PDFs).
422+
`object.DecodeB64ToBinary(Base64Text As String)`
423+
387424
##### SetZoomFactor
388425
Sets the zoom factor for the control.
389426
`object.SetZoomFactor(Factor As Double)`
@@ -428,8 +465,20 @@ Clears the browser cache (DiskCache and LocalStorage).
428465
Asynchronously retrieves the entire visible text content of the document (sent via OnMessageReceived with 'Inner_Text|').
429466
`object.GetInnerText()`
430467

468+
##### CaptureSnapshot
469+
Captures page data using Chrome DevTools Protocol. Can return MHTML or other CDP formats based on the `cdpParameters` JSON string.
470+
`object.CaptureSnapshot(CdpParameters As String)`
471+
472+
##### SetDownloadPath
473+
Sets a global default folder or file path for all browser downloads. If a directory is provided, the filename is automatically appended by the library.
474+
`object.SetDownloadPath(Path As String)`
475+
476+
##### CancelDownloads
477+
Cancels active downloads. If `uri` is empty or omitted, cancels all active downloads.
478+
`object.CancelDownloads([Uri As String])`
479+
431480
##### ExportPageData
432-
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.
481+
[LEGACY] Consolidated into **CaptureSnapshot**.
433482
`object.ExportPageData(Format As Integer, FilePath As String)`
434483

435484
##### PrintToPdfStream
@@ -442,6 +491,10 @@ Captures the current page as a PDF and returns the content as a Base64-encoded s
442491
Fired when a message or notification is sent from the library to AutoIt.
443492
`object_OnMessageReceived(Message As String)`
444493

494+
##### OnWebResourceResponseReceived
495+
Fired when a web resource response is received (useful for tracking HTTP Status Codes).
496+
`object_OnWebResourceResponseReceived(StatusCode As Integer, ReasonPhrase As String, RequestUrl As String)`
497+
445498
##### OnNavigationStarting
446499
Fired when the browser starts navigating to a new URL.
447500
`object_OnNavigationStarting(Url As String)`
@@ -477,6 +530,14 @@ Fired when the browser loses focus.
477530
##### OnContextMenuRequested
478531
Fired when a context menu is requested (Simplified for AutoIt).
479532
`object_OnContextMenuRequested(LinkUrl As String, X As Integer, Y As Integer, SelectionText As String)`
533+
534+
##### OnDownloadStarting
535+
Fired when a download is starting. Provides core metadata to allow decision making. Path overrides and UI suppression should be handled via the `DownloadResultPath` and `IsDownloadHandled` properties.
536+
`object_OnDownloadStarting(Uri As String, DefaultPath As String)`
537+
538+
##### OnDownloadStateChanged
539+
Fired when a download state changes (e.g., Progress, Completed, Failed).
540+
`object_OnDownloadStateChanged(State As String, Uri As String, TotalBytes As Long, ReceivedBytes As Long)`
480541

481542

482543
---
@@ -582,7 +643,7 @@ Encodes a string to Base64 (UTF-8).
582643
`string EncodeB64(PlainText As String)`
583644

584645
##### DecodeB64
585-
Decodes a Base64 string back to plain text.
646+
Decodes a Base64 string back to **plain text** (UTF-8).
586647
`string DecodeB64(Base64Text As String)`
587648

588649
##### DecodeB64ToFile

0 commit comments

Comments
 (0)