Remove VoiceInk exclusion in screen capture guard

This commit is contained in:
Beingpax 2025-09-24 12:03:11 +05:45
parent 66debc2cd4
commit 8abc8a3ddd

View File

@ -15,12 +15,9 @@ class ScreenCaptureService: ObservableObject {
private func getActiveWindowInfo() -> (title: String, ownerName: String, windowID: CGWindowID)? {
let windowListInfo = CGWindowListCopyWindowInfo([.optionOnScreenOnly], kCGNullWindowID) as? [[String: Any]] ?? []
// Find the frontmost window that isn't our own app
if let frontWindow = windowListInfo.first(where: { info in
let layer = info[kCGWindowLayer as String] as? Int32 ?? 0
let ownerName = info[kCGWindowOwnerName as String] as? String ?? ""
// Exclude our own app and system UI elements
return layer == 0 && ownerName != "VoiceInk" && !ownerName.contains("Dock") && !ownerName.contains("Menu Bar")
return layer == 0
}) {
guard let windowID = frontWindow[kCGWindowNumber as String] as? CGWindowID,
let ownerName = frontWindow[kCGWindowOwnerName as String] as? String,
@ -40,7 +37,6 @@ class ScreenCaptureService: ObservableObject {
return captureFullScreen()
}
// Capture the specific window
let cgImage = CGWindowListCreateImage(
.null,
.optionIncludingWindow,
@ -113,7 +109,6 @@ class ScreenCaptureService: ObservableObject {
}
}
// Configure the recognition level
request.recognitionLevel = .accurate
request.usesLanguageCorrection = true
@ -140,7 +135,6 @@ class ScreenCaptureService: ObservableObject {
logger.notice("🎬 Starting screen capture")
// Get window info
guard let windowInfo = getActiveWindowInfo() else {
logger.notice("❌ Failed to get window info")
return nil
@ -148,14 +142,12 @@ class ScreenCaptureService: ObservableObject {
logger.notice("🎯 Found window: \(windowInfo.title, privacy: .public) (\(windowInfo.ownerName, privacy: .public))")
// Start with window metadata
var contextText = """
Active Window: \(windowInfo.title)
Application: \(windowInfo.ownerName)
"""
// Capture and process window content
if let capturedImage = captureActiveWindow() {
let extractedText = await withCheckedContinuation({ continuation in
extractText(from: capturedImage) { text in