Skip to content

Commit

Permalink
fix: some app is active but can not get windows
Browse files Browse the repository at this point in the history
workaround: sometimes some apps are launched and are actived but OS returns the windows.count == 0. we wait for a moment. For example: Bear.app. At this scenario, AXUIElementCopyAttributeValue(self, kAXWindowsAttribute, &value) returns success but  AXUIElementCopyAttributeValue(self, kAXPositionAttribute, &value) and AXUIElementCopyAttributeValue(self, kAXSizeAttribute, &value) return attributeUnsupported. After we wait for a moment, all things run well.
  • Loading branch information
metacodes authored Mar 20, 2022
1 parent d058db6 commit 5d33d3a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/logic/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ class Application: NSObject {
if group == nil && !self.wasLaunchedBeforeAltTab && CGSSpaceGetType(cgsMainConnectionId, Spaces.currentSpaceId) == .fullscreen {
throw AxError.runtimeError
}
// workaround: sometimes some apps are launched and are actived but OS returns the windows.count == 0. we wait for a moment
// for example: Bear.app
if group == nil && !self.wasLaunchedBeforeAltTab && self.runningApplication.isActive {
throw AxError.runtimeError
}
}
}
}
Expand Down

0 comments on commit 5d33d3a

Please sign in to comment.