From e59034d7008bb79dd51bde7b13d6d9872d003f8c Mon Sep 17 00:00:00 2001 From: yu <191972707@qq.com> Date: Thu, 29 Oct 2026 17:12:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8B=BE=E5=8F=96/=E6=A1=86=E9=80=89?= =?UTF-8?q?=E6=97=B6=E6=9C=80=E5=B0=8F=E5=8C=96=E5=BA=94=E7=94=A8=E8=87=AA?= =?UTF-8?q?=E8=BA=AB=E7=AA=97=E5=8F=A3=EF=BC=8C=E5=AE=8C=E6=88=90=E5=90=8E?= =?UTF-8?q?=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/desktop-pick.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/desktop-pick.ts b/src/main/desktop-pick.ts index 0513c89..0b9143b 100644 --- a/src/main/desktop-pick.ts +++ b/src/main/desktop-pick.ts @@ -28,6 +28,8 @@ export interface DesktopPickResult { } export async function pickDesktopElement(): Promise { + const appWindows = BrowserWindow.getAllWindows().filter(w => !w.isDestroyed() && w.isVisible()); + for (const w of appWindows) w.minimize(); const { stdout } = await run("powershell.exe", ["-NoProfile", "-STA", "-ExecutionPolicy", "Bypass", "-File", pickerScriptPath()], { timeout: 180000, windowsHide: false, maxBuffer: 4 * 1024 * 1024 }); const jsonLine = stdout.trim().split(/\\r?\\n/).reverse().find(l => l.trim().startsWith("{")); if (!jsonLine) throw new RuntimeError("picker_failed", "拾取未返回结果"); @@ -48,6 +50,8 @@ export async function listVisibleWindows(): Promise; } export async function pickScreenRegion(): Promise<{ x: number; y: number; width: number; height: number; imagePath: string }> { + const appWindows = BrowserWindow.getAllWindows().filter(w => !w.isDestroyed() && w.isVisible()); + for (const w of appWindows) w.minimize(); const display = screen.getPrimaryDisplay(); const sx = display.bounds.x, sy = display.bounds.y, sw = display.bounds.width, sh = display.bounds.height; const win = new BrowserWindow({ @@ -85,6 +89,7 @@ export async function pickScreenRegion(): Promise<{ x: number; y: number; width: if ((error as Error).message.includes("已取消框选")) throw error; } } + for (const w of appWindows) { if (!w.isDestroyed()) w.restore(); } win.destroy(); if (!region) throw new RuntimeError("pick_cancelled", "未完成框选"); await new Promise(r => setTimeout(r, 300)); @@ -103,4 +108,4 @@ export async function pickScreenRegion(): Promise<{ x: number; y: number; width: ].join(""); await run("powershell.exe", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", psScript], { timeout: 30000, windowsHide: true }); return { ...region, imagePath }; -} \ No newline at end of file +}