From ee3c28896eab2dd4f074236d453b531936063424 Mon Sep 17 00:00:00 2001 From: DarkFlameMaster <1004452714@qq.com> Date: Tue, 5 May 2026 19:41:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?docs:=E6=B7=BB=E5=8A=A0HTML=E9=81=AE?= =?UTF-8?q?=E7=BD=A9=E7=82=B9=E5=87=BB=E7=A9=BF=E9=80=8F=E7=9A=84=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=96=B9=E6=B3=95=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dev/js/htmlMask.md | 59 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/src/dev/js/htmlMask.md b/src/dev/js/htmlMask.md index 214dbe2..85c6626 100644 --- a/src/dev/js/htmlMask.md +++ b/src/dev/js/htmlMask.md @@ -106,6 +106,59 @@ if (htmlMask.exists("my-overlay")) { } ``` +#### setClickThrough(windowId, enabled) + +设置指定窗口的点击穿透模式。窗口默认处于点击穿透状态。 + +**参数**: +- `windowId`:字符串类型,窗口 ID +- `enabled`:布尔类型,`true` 表示点击穿透(鼠标事件穿过窗口),`false` 表示可交互(窗口接收鼠标和键盘事件) + +**示例**: +```javascript +const winId = htmlMask.show("assets/index.html"); + +// 关闭点击穿透,使窗口可交互 +htmlMask.setClickThrough(winId, false); + +// 恢复点击穿透,使窗口不再拦截鼠标事件 +htmlMask.setClickThrough(winId, true); +``` + +#### getClickThrough(windowId) + +获取指定窗口的点击穿透状态。 + +**参数**: +- `windowId`:字符串类型,窗口 ID + +**返回值**:布尔类型,`true` 表示当前处于点击穿透模式,`false` 表示可交互模式 + +**示例**: +```javascript +const winId = htmlMask.show("assets/index.html"); +const isClickThrough = htmlMask.getClickThrough(winId); +log.info("当前点击穿透状态: {isClickThrough}", isClickThrough); // true +``` + +#### toggleClickThrough(windowId) + +切换指定窗口的点击穿透模式(穿透 ↔ 可交互)。 + +**参数**: +- `windowId`:字符串类型,窗口 ID + +**示例**: +```javascript +const winId = htmlMask.show("assets/index.html"); + +// 第一次切换:穿透 → 可交互 +htmlMask.toggleClickThrough(winId); + +// 第二次切换:可交互 → 穿透 +htmlMask.toggleClickThrough(winId); +``` + ### 2. 消息通信 所有消息遵循统一的 JSON 格式(根据web api格式设计): @@ -355,7 +408,8 @@ window.chrome.webview.postMessage(JSON.stringify({ ### 窗口 - 最多同时打开 **5** 个 HTML 遮罩窗口(打开过多窗口非常影响性能,请尽量使用数据通信的形式响应式更新内容) -- 遮罩窗口是**透明**、**置顶**、**点击穿透**的(不可交互) +- 遮罩窗口是**透明**、**置顶**、**默认点击穿透**的 +- 可通过 `setClickThrough` 动态切换点击穿透模式,切换为可交互模式时窗口会自动获得焦点 ### 生命周期 - JS 脚本结束时自动关闭所有遮罩窗口 @@ -376,6 +430,9 @@ window.chrome.webview.postMessage(JSON.stringify({ | 窗口 | closeAll | - | void | | 窗口 | getWindowIds | - | string[] | | 窗口 | exists | id | bool | +| 窗口 | setClickThrough | windowId, enabled | void | +| 窗口 | getClickThrough | windowId | bool | +| 窗口 | toggleClickThrough | windowId | void | | 通信 | send | windowId, url, jsonData | void | | 通信 | request | windowId, url, jsonData, timeoutMs? | string? | | 通信 | receive | windowId, timeoutMs? | string? | From 3b9884b9a44736912da9b132fc25e97c29d03d72 Mon Sep 17 00:00:00 2001 From: DarkFlameMaster <1004452714@qq.com> Date: Tue, 5 May 2026 19:43:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?clean:=E6=B8=85=E7=90=86=E5=B7=B2Revert?= =?UTF-8?q?=E7=9A=84BvPage=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dev/js/BvPage.md | 111 ------------------------------------------- 1 file changed, 111 deletions(-) diff --git a/src/dev/js/BvPage.md b/src/dev/js/BvPage.md index 548d7c8..63744a7 100644 --- a/src/dev/js/BvPage.md +++ b/src/dev/js/BvPage.md @@ -307,117 +307,6 @@ public List Ocr(Rect rect = default) -### OcrMatch - -**参数说明** -| 参数 | 类型 | 必填 | 描述 | -|------|------|------|------| -| target | string | 是 | 目标字符串 | -| rect | Rect | 否 | 感兴趣区域,默认为全屏 | -| threshold | double? | 否 | 匹配阈值 (0~1),null 使用配置中的默认阈值 | - -**返回值** -- 类型:`bool` -- 可能取值: - - `true`:匹配成功 - - `false`:匹配失败 - -**使用场景** -- 判断截图中是否包含目标文字 -- 使用模糊匹配进行文本识别 - -**JavaScript 调用示例** - -```javascript -// 判断屏幕上是否包含"确认"文字 -const matched = page.OcrMatch("确认"); -log.info('匹配结果:', matched); - -// 指定区域和阈值 -const matched2 = page.OcrMatch("确认", new OpenCvSharp.OpenCvSharp.Rect(0, 0, 500, 500), 0.8); -``` - -
-查看C#实现 - -```csharp -public bool OcrMatch(string target, Rect rect = default, double? threshold = null) -{ - var matchService = OcrFactory.PaddleMatch; - var actualThreshold = threshold - ?? TaskContext.Instance().Config.OtherConfig.OcrConfig.OcrMatchDefaultThreshold; - - var screen = TaskControl.CaptureToRectArea(); - try - { - var roi = rect == default ? null : screen.DeriveCrop(rect); - try - { - var score = matchService.OcrMatch((roi ?? screen).SrcMat, target); - return score >= actualThreshold; - } - finally - { - roi?.Dispose(); - } - } - finally - { - screen.Dispose(); - } -} -``` - -
- -### WaitForOcrMatch - -**参数说明** -| 参数 | 类型 | 必填 | 描述 | -|------|------|------|------| -| target | string | 是 | 目标字符串 | -| rect | Rect | 否 | 感兴趣区域,默认为全屏 | -| threshold | double? | 否 | 匹配阈值 (0~1),null 使用配置中的默认阈值 | -| timeout | int? | 否 | 超时时间(毫秒),null 使用 DefaultTimeout | - -**返回值** -- 类型:`Task` -- 可能取值: - - `true`:在超时前匹配成功 - - `false`:超时未匹配 - -**使用场景** -- 等待目标文字出现 -- 重复截图并使用模糊匹配 - -**JavaScript 调用示例** - -```javascript -// 等待"确认"文字出现,最多等待10秒 -const matched = await page.WaitForOcrMatch("确认", default, default, 10000); -log.info('等待结果:', matched); - -// 简化调用 -const matched2 = await page.WaitForOcrMatch("确认"); -``` - -
-查看C#实现 - -```csharp -public async Task WaitForOcrMatch(string target, Rect rect = default, double? threshold = null, int? timeout = null) -{ - var actualTimeout = timeout ?? DefaultTimeout; - var retryCount = DefaultRetryInterval > 0 ? actualTimeout / DefaultRetryInterval : 1; - - return await NewRetry.WaitForAction(() => OcrMatch(target, rect, threshold), - _cancellationToken, retryCount, DefaultRetryInterval); -} -``` - -
- - ## 交互方法 ### Click From 71478fc6ac8598efbd14dae7f3aba597d00b69c6 Mon Sep 17 00:00:00 2001 From: DarkFlameMaster <1004452714@qq.com> Date: Thu, 7 May 2026 00:02:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Revert=20"clean:=E6=B8=85=E7=90=86=E5=B7=B2?= =?UTF-8?q?Revert=E7=9A=84BvPage=E6=96=B9=E6=B3=95"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3b9884b9a44736912da9b132fc25e97c29d03d72. --- src/dev/js/BvPage.md | 111 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/src/dev/js/BvPage.md b/src/dev/js/BvPage.md index 63744a7..548d7c8 100644 --- a/src/dev/js/BvPage.md +++ b/src/dev/js/BvPage.md @@ -307,6 +307,117 @@ public List Ocr(Rect rect = default) +### OcrMatch + +**参数说明** +| 参数 | 类型 | 必填 | 描述 | +|------|------|------|------| +| target | string | 是 | 目标字符串 | +| rect | Rect | 否 | 感兴趣区域,默认为全屏 | +| threshold | double? | 否 | 匹配阈值 (0~1),null 使用配置中的默认阈值 | + +**返回值** +- 类型:`bool` +- 可能取值: + - `true`:匹配成功 + - `false`:匹配失败 + +**使用场景** +- 判断截图中是否包含目标文字 +- 使用模糊匹配进行文本识别 + +**JavaScript 调用示例** + +```javascript +// 判断屏幕上是否包含"确认"文字 +const matched = page.OcrMatch("确认"); +log.info('匹配结果:', matched); + +// 指定区域和阈值 +const matched2 = page.OcrMatch("确认", new OpenCvSharp.OpenCvSharp.Rect(0, 0, 500, 500), 0.8); +``` + +
+查看C#实现 + +```csharp +public bool OcrMatch(string target, Rect rect = default, double? threshold = null) +{ + var matchService = OcrFactory.PaddleMatch; + var actualThreshold = threshold + ?? TaskContext.Instance().Config.OtherConfig.OcrConfig.OcrMatchDefaultThreshold; + + var screen = TaskControl.CaptureToRectArea(); + try + { + var roi = rect == default ? null : screen.DeriveCrop(rect); + try + { + var score = matchService.OcrMatch((roi ?? screen).SrcMat, target); + return score >= actualThreshold; + } + finally + { + roi?.Dispose(); + } + } + finally + { + screen.Dispose(); + } +} +``` + +
+ +### WaitForOcrMatch + +**参数说明** +| 参数 | 类型 | 必填 | 描述 | +|------|------|------|------| +| target | string | 是 | 目标字符串 | +| rect | Rect | 否 | 感兴趣区域,默认为全屏 | +| threshold | double? | 否 | 匹配阈值 (0~1),null 使用配置中的默认阈值 | +| timeout | int? | 否 | 超时时间(毫秒),null 使用 DefaultTimeout | + +**返回值** +- 类型:`Task` +- 可能取值: + - `true`:在超时前匹配成功 + - `false`:超时未匹配 + +**使用场景** +- 等待目标文字出现 +- 重复截图并使用模糊匹配 + +**JavaScript 调用示例** + +```javascript +// 等待"确认"文字出现,最多等待10秒 +const matched = await page.WaitForOcrMatch("确认", default, default, 10000); +log.info('等待结果:', matched); + +// 简化调用 +const matched2 = await page.WaitForOcrMatch("确认"); +``` + +
+查看C#实现 + +```csharp +public async Task WaitForOcrMatch(string target, Rect rect = default, double? threshold = null, int? timeout = null) +{ + var actualTimeout = timeout ?? DefaultTimeout; + var retryCount = DefaultRetryInterval > 0 ? actualTimeout / DefaultRetryInterval : 1; + + return await NewRetry.WaitForAction(() => OcrMatch(target, rect, threshold), + _cancellationToken, retryCount, DefaultRetryInterval); +} +``` + +
+ + ## 交互方法 ### Click