Skip to content

Commit f1fa988

Browse files
authored
v1.4.1
## Version 1.4.1 - (2026-01-03) ### 🚀 Data Intelligence & JSON Manipulation This update transforms the `NetJson.Parser` into a full-featured JSON management suite, allowing for complex data merging and structure inspection directly from AutoIt. #### **Added** - **Advanced JSON Methods** (DispIds 214 - 221): - `Merge(string jsonContent)`: **(214)** Performs a deep merge of a new JSON string into the existing structure. Uses `Union` strategy for arrays to prevent duplicates. - `MergeFromFile(string filePath)`: **(215)** Efficiently reads a JSON file from disk and merges it directly into the current session. - `GetTokenType(string path)`: **(216)** Returns the .NET/Newtonsoft type of a specific node (e.g., _Object, Array, String, Integer, Boolean_). Essential for dynamic data validation. - `RemoveToken(string path)`: **(217)** Allows dynamic deletion of specific keys or array elements, providing full CRUD (Create, Read, Update, Delete) capabilities - **`Search(string query)`**: **(218)** Executes a JSONPath query and returns a JSON array of all matching tokens. Enables powerful filtering and deep searching with a single call. - **`Flatten()`**: **(219)** Flattens the JSON structure into a single-level object with dot-notated paths. - **`CloneTo(string parserName)`**: **(220)** Clones the current JSON data to another named parser instance. - **`FlattenToTable(string colDelim, string rowDelim)`**: **(221)** Flattens the JSON structure into a table-like string with specified delimiters. - **Web Content Extraction** (DispId 200): - **`GetInnerText()`**: **(200)** Retrieves the entire visible text content (`innerText`) of the document. The result is returned asynchronously via the `OnMessageReceived` event with the `Inner_Text|` prefix. This enables powerful web scraping and content analysis without manual DOM parsing. #### **Improvements** - **Enhanced Error Handling**: All new JSON and Web methods are wrapped in try-catch blocks to prevent COM crashes when dealing with malformed data or invalid DOM states. - **Memory Efficiency**: `MergeFromFile` utilizes local C# file streams, reducing the memory overhead for the calling AutoIt script when handling large configuration files. - **Unified Messaging**: Content extraction now follows the standardized `Command|Data` format, making it easier to route messages in the AutoIt event loop.
1 parent 9abfede commit f1fa988

File tree

11 files changed

+828
-195
lines changed

11 files changed

+828
-195
lines changed

Doc/README.md

Lines changed: 151 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# AutoIt WebView2 Component (COM Interop)
1+
## AutoIt WebView2 Component (COM Interop)
22

33
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.
44

55
---
6-
7-
## 🚀 Key Features
6+
### 🚀 Key Features
87

98
* **Chromium Engine**: Leverage the speed and security of modern Microsoft Edge.
109
* **Bi-directional Communication**: Send messages from JS to AutoIt (`postMessage`) and execute JS from AutoIt (`ExecuteScript`).
@@ -16,19 +15,17 @@ A powerful bridge that allows **AutoIt** to use the modern **Microsoft Edge WebV
1615
- **Advanced Cookie & CDP Control**: Full cookie manipulation and raw access to Chrome DevTools Protocol.
1716
- **Kiosk & Security Mode**: Enhanced methods to restrict user interaction for production environments.
1817

19-
2018
---
2119

22-
## 🛠 Prerequisites
20+
### 🛠 Prerequisites
2321

2422
1. **.NET Framework 4.8** or higher.
2523
2. **Microsoft Edge WebView2 Runtime**.
2624

2725
* *The registration script will check for this and provide a download link if missing.*
2826

29-
3027
---
31-
## 📦 Deployment \& Installation
28+
### 📦 Deployment \& Installation
3229

3330
1. **Extract** NetWebView2Lib folder to a permanent location.
3431
2. **Run**:
@@ -40,12 +37,122 @@ A powerful bridge that allows **AutoIt** to use the modern **Microsoft Edge WebV
4037

4138
1. **Run `\Example\*`** to see the bridge in action.
4239

40+
---
41+
### 🛠️ Migration Note (Important)
42+
43+
Due to changes in the COM Dispatch IDs (DispIds) for better organization, it is **highly recommended** to run the included `RegCleaner.au3` before registering the new version. This ensures that any stale registry entries from previous builds are purged, preventing "Object action failed" errors.
4344

4445
---
46+
### ⚖️ License
47+
48+
This project is provided "as-is". You are free to use, modify, and distribute it for both personal and commercial projects.
4549

46-
## 📖 NetWebView2Lib Version 1.4.0 - Reference (Quick View)
50+
<p align="center">
51+
<img src="https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png" width="100%">
52+
</p>
53+
54+
## NetWebView2Lib v1.4.0 - Major Update
55+
56+
This version introduces significant architectural improvements, focusing on deep integration with WebView2 settings and a more robust event-driven system.
57+
58+
### ✨ Key Highlights
59+
60+
* **Comprehensive Settings Control**: Direct access to browser behaviors via new properties. Toggle DevTools, Context Menus, Script Dialogs, and Browser Accelerators (`AreDevToolsEnabled`, `AreDefaultContextMenusEnabled`, etc.) directly from your AutoIt script.
61+
62+
* 🎯 **Permanent JS Injection**: Introducing `AddInitializationScript`. Injected JavaScript (like bridges or libraries) now persists across page navigations and refreshes automatically, managed via a new Script ID tracking system.
63+
64+
* **Custom Context Menus**: Intercept right-clicks with the new `OnContextMenu` event. Receive rich JSON metadata including coordinates, element tags, selected text, and source URLs to build native-looking custom menus.
65+
66+
* **Focus & Lifecycle Management**: Navigation is now fully observable through `OnNavigationStarting` and `OnNavigationCompleted`.
67+
68+
* **Integrated Utilities**: Added native methods for `Encode/DecodeURI` and `Base64` (UTF-8) to handle data transfers between AutoIt and JavaScript seamlessly.
69+
70+
* **Enhanced State Sync**: Real-time events for Title, URL, and Zoom changes to keep your AutoIt GUI perfectly in sync with the browser state.
71+
72+
<p align="center">
73+
<img src="https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png" width="100%">
74+
</p>
75+
76+
### 📖 Understanding the WebDemo (v1.4)
77+
78+
The **`WebDemo_v1.4.au3`** is not just a browser,
79+
it is a showcase of **Bi-directional Intelligence**.
80+
It demonstrates how AutoIt can "read" the DOM state via COM events to provide a context-specific user interface.
81+
82+
#### 1. Context-Aware Menu (The "Right-Click" Magic)
83+
84+
The demo intercepts the native context menu and replaces it with a dynamic AutoIt menu. The options change based on the **HTML element** under your cursor:
85+
86+
- **📥 Table Intelligence**:
87+
88+
- **Action**: Right-click anywhere inside a `<table>`.
89+
90+
- **What happens**: The library detects the `tagName`, calculates the table's index via coordinates, and offers an **Export to CSV** option. It uses the `bridge.js` to scrape the data directly from the browser's memory.
91+
92+
- **📋 Form Automation**:
93+
94+
- **Action**: Right-click on an `<input>`, `<textarea>`, or `<form>`.
95+
96+
- **What happens**:
97+
98+
- **Map Form to JSON**: Automatically crawls the form and generates a JSON file with all current values.
99+
100+
- **Fill Form from JSON**: Lets you select a previously saved JSON file to instantly re-populate the form.
101+
102+
- **🔍 Smart Selection**:
103+
104+
- **Action**: Highlight any text on the page and right-click.
105+
106+
- **What happens**: The menu offers a Google Search for that specific string, using the new native `EncodeURI` method to handle special characters.
107+
108+
109+
#### 2. Advanced Utilities
110+
111+
- **📸 Full Page Screenshot**: Unlike standard screen captures, this utility renders the **entire document** (including the parts you need to scroll to see) and saves it as a high-quality PNG.
112+
113+
- **⚡ Persistent Bridge**: Notice that even if you navigate to a new website or refresh, the "Table Export" and "Form Mapping" still work. This is thanks to the new `AddInitializationScript` which ensures our `bridge.js` is part of every page's DNA.
114+
115+
---
47116

48-
## Properties
117+
#### ⚙️ How it Works: The "Context-JSON" Bridge
118+
119+
The secret behind this intelligent menu is the seamless communication between the Browser's DOM and AutoIt's COM interface.
120+
121+
#### The Workflow:
122+
123+
1. **The Trigger**: When you right-click, the `bridge.js` (injected via `AddInitializationScript`) intercepts the event.
124+
125+
2. **Data Gathering**: It instantly gathers metadata about the element under the mouse (Coordinates, Tag Type, Selected Text, Image Sources, etc.).
126+
127+
3. **The Dispatch**: This metadata is packed into a **JSON string** and sent to AutoIt via the `OnContextMenu` event.
128+
129+
4. **The Decision**: AutoIt receives the JSON, parses it using `NetJson.Parser`, and decides which menu items to show.
130+
131+
132+
#### Why JSON?
133+
134+
- **Structure**: It allows passing multiple data points (X, Y, Tag, URL) in a single, organized string.
135+
136+
- **Performance**: By prefixing with `JSON:`, we bypass complex string encoding, making the communication near-instant.
137+
138+
- **Flexibility**: You can easily add more data points to the `bridge.js` without ever changing the core DLL.
139+
140+
141+
---
142+
143+
#### 💡 Pro Tip for Developers:
144+
145+
> "You can extend this! If you want to detect specifically if a user clicked on a **Video** or a **PDF link**, just update the `bridge.js` to include those tags.
146+
147+
148+
149+
<p align="center">
150+
<img src="https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png" width="100%">
151+
</p>
152+
153+
## 📖 NetWebView2Lib Version 1.4.1 (Quick Reference)
154+
155+
### Properties
49156

50157
##### AreDevToolsEnabled
51158
Determines whether the user is able to use the context menu or keyboard shortcuts to open the DevTools window.
@@ -91,7 +198,7 @@ Note: Not supported natively by WebView2, provided for compatibility.
91198
Determines whether new window requests are allowed or redirected to the same window.
92199
`object.AreBrowserPopupsAllowed[ = Value]`
93200

94-
## Methods
201+
### Methods
95202

96203
##### Initialize
97204
Initializes the WebView2 control within a parent window.
@@ -325,7 +432,7 @@ Gives focus to the WebView control.
325432
Registers a script that will run automatically every time a new page loads.
326433
`object.AddInitializationScript(Script As String)`
327434

328-
## Events
435+
### Events
329436

330437
##### OnMessageReceived
331438
Fired when a message or notification is sent from the library to AutoIt.
@@ -365,9 +472,9 @@ Fired when the browser loses focus.
365472

366473
---
367474

368-
# JsonParser (ProgId: NetJson.Parser)
475+
### JsonParser (ProgId: NetJson.Parser)
369476

370-
## Methods
477+
#### Methods
371478

372479
##### Parse
373480
Parses a JSON string. Automatically detects if it's an Object or an Array.
@@ -421,11 +528,39 @@ Returns the JSON string with nice formatting (Indented).
421528
Minifies a JSON string (removes spaces and new lines).
422529
`string GetMinifiedJson()`
423530

424-
---
531+
##### Merge
532+
Performs a deep merge of a new JSON string into the existing structure. Uses `Union` strategy for arrays to prevent duplicates.
533+
`Merge(string jsonContent)`
534+
535+
##### MergeFromFile
536+
Efficiently reads a JSON file from disk and merges it directly into the current session.
537+
`MergeFromFile(string filePath)`
425538

426-
## ⚖️ License
539+
##### GetTokenType
540+
Returns the .NET/Newtonsoft type of a specific node (e.g., _Object, Array, String, Integer, Boolean_). Essential for dynamic data validation.
541+
`GetTokenType(string path)`
542+
543+
##### RemoveToken
544+
Allows dynamic deletion of specific keys or array elements, providing full CRUD (Create, Read, Update, Delete) capabilities
545+
`RemoveToken(string path)`
546+
547+
##### Search
548+
Executes a JSONPath query and returns a JSON array of all matching tokens. Enables powerful filtering and deep searching with a single call.
549+
`Search(string query)`
550+
551+
##### Flatten
552+
Flattens the JSON structure into a single-level object with dot-notated paths.
553+
`Flatten()`
554+
555+
##### CloneTo
556+
Clones the current JSON data to another named parser instance.
557+
`CloneTo(string parserName)`
558+
559+
560+
##### FlattenToTable
561+
Flattens the JSON structure into a table-like string with specified delimiters.
562+
`FlattenToTable(string colDelim, string rowDelim)`
427563

428-
This project is provided "as-is". You are free to use, modify, and distribute it for both personal and commercial projects.
429564

430565
---
431566

0 commit comments

Comments
 (0)