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