This is an Example of Selected Mission Control Window. Safari is Selected
And this is an example of no windows selected 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
}
}
}