fix: 拾取/框选的窗口收集不再过滤最小化窗口,恢复时 show+restore+focus
This commit is contained in:
parent
11fc88eec9
commit
483b01c8b6
@ -28,7 +28,7 @@ export interface DesktopPickResult {
|
||||
}
|
||||
|
||||
export async function pickDesktopElement(): Promise<DesktopPickResult> {
|
||||
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<Array<{ title: string; proce
|
||||
return JSON.parse(jsonLine) as Array<{ title: string; process: string }>;
|
||||
}
|
||||
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));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user