diff --git a/src/main/desktop-pick.ts b/src/main/desktop-pick.ts index beb6f1e..ebf8efc 100644 --- a/src/main/desktop-pick.ts +++ b/src/main/desktop-pick.ts @@ -28,7 +28,7 @@ export interface DesktopPickResult { } export async function pickDesktopElement(): Promise { - const appWindows = BrowserWindow.getAllWindows().filter(w => !w.isDestroyed() && w.isVisible()); + const appWindows = BrowserWindow.getAllWindows().filter(w => !w.isDestroyed()); for (const w of appWindows) w.minimize(); try { const { stdout } = await run("powershell.exe", ["-NoProfile", "-STA", "-ExecutionPolicy", "Bypass", "-File", pickerScriptPath()], { timeout: 180000, windowsHide: true, maxBuffer: 4 * 1024 * 1024 }); @@ -55,7 +55,7 @@ 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()); + const appWindows = BrowserWindow.getAllWindows().filter(w => !w.isDestroyed()); 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; @@ -94,7 +94,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(); } + for (const w of appWindows) { if (!w.isDestroyed()) { w.show(); w.restore(); w.focus(); } } win.destroy(); if (!region) throw new RuntimeError("pick_cancelled", "未完成框选"); await new Promise(r => setTimeout(r, 300));