0

This is an Example of Selected Mission Control Window. Safari is Selected This is an Example of Selected Mission Control Window. Safari is Selected

And this is an example of no windows selected on mission control without selected window on mission control

How it's possible unselect this window?

Using Swift/Obj-C/Applescript or whatever. But without changing the mouse location

My progress is this, I reached to the attribute AXSelectedChildren of Mission Control windows. Code Below

for entry in  (CGWindowListCopyWindowInfo(CGWindowListOption.optionOnScreenOnly, kCGNullWindowID) as NSArray? as? [[String: AnyObject]])!
    {
        if entry[kCGWindowOwnerName as String] as! String == "Dock"
        {
            let bounds: NSDictionary = entry[kCGWindowBounds as String] as! NSDictionary

            if (bounds["Y"] as! NSNumber) != 0{ //if Mission Control is Launched

                let dockAppElement = AXUIElementCreateApplication((entry[kCGWindowOwnerPID as String] as? Int32)!)

                var dockAttributeValues: AnyObject?

                _ = AXUIElementCopyAttributeValue(dockAppElement, kAXChildrenAttribute as CFString, &dockAttributeValues)

                var childrenRef = (dockAttributeValues as! [AXUIElement]).last // group 1 of Dock
                _ = AXUIElementCopyAttributeValue(childrenRef!, kAXChildrenAttribute as CFString, &dockAttributeValues)

                childrenRef = (dockAttributeValues as! [AXUIElement]).first // group 1 of group 1 of Dock
                _ = AXUIElementCopyAttributeValue(childrenRef!, kAXChildrenAttribute as CFString, &dockAttributeValues)

                childrenRef = (dockAttributeValues as! [AXUIElement]).first // group 1 of group 1 of group 1 of Dock
                _ = AXUIElementCopyAttributeValue(childrenRef!, kAXSelectedChildrenAttribute as CFString, &dockAttributeValues)
                        
                if let selectedWindow = (dockAttributeValues as! [AXUIElement]).first{ // selected Children of group 1 of group 1 of group 1 of Dock
                    _ = AXUIElementCopyAttributeValue(selectedWindow, kAXTitleAttribute as CFString, &dockAttributeValues)
                    if let titleWindow = (dockAttributeValues as? String){print(titleWindow)}

                }
                else{ // if selectedChildren == nil
                    print("no windows selected")
                }
                break
             }
         }
     }
a_kira
  • 195
  • 10
  • Where are you writing code? – El Tomato Aug 22 '21 at 00:58
  • I have a Project in Xcode, using https://github.com/soffes/HotKey to trigger actions like this. My project only need access to accessibility. I launch Mission Control and run this code with Hotkey – a_kira Aug 22 '21 at 01:18
  • Is `selectedChildren` `nil`? Is `kAXSelectedAttribute` of the window `true`? Have you tried setting it to `false`? – Willeke Aug 22 '21 at 10:11
  • The selectedChildren of List is = selectedWindow. The selectedWindow don't have kAXSelectedAttribute, only have kAXEnabledAttribute, and this is not settable. The attribute kAXSelectedChildren of list that contains all children windows, too is not settable. – a_kira Aug 23 '21 at 21:48

0 Answers0