Skip to content

Commit

Permalink
feat: findWindow using cgWindowId
Browse files Browse the repository at this point in the history
  • Loading branch information
ShlomoCode committed Jul 7, 2024
1 parent 2358ae3 commit 5ba6ab9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DockDoor/Utilities/WindowUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ final class WindowUtil {
/// Finds a window by its name in the provided AXUIElement windows.
static func findWindow(matchingWindow window: SCWindow, in axWindows: [AXUIElement]) -> AXUIElement? {
for axWindow in axWindows {
var cgWindowId: CGWindowID = 0
let windowIDStatus = _AXUIElementGetWindow(axWindow, &cgWindowId)
if windowIDStatus == .success && window.windowID == cgWindowId {
return axWindow
}

var axTitle: CFTypeRef?
AXUIElementCopyAttributeValue(axWindow, kAXTitleAttribute as CFString, &axTitle)
let axTitleString = (axTitle as? String) ?? ""
Expand Down

0 comments on commit 5ba6ab9

Please sign in to comment.