defina rapidamente o tamanho e a posição de todas as janelas da tela
É possível obter rapidamente uma lista de todos os aplicativos com uma janela em primeiro plano e definir o tamanho e a posição dessas janelas.
Eu recebo a lista de propriedades do Windows como esta
let type = CGWindowListOption.optionOnScreenOnly
let windowList = CGWindowListCopyWindowInfo(type, kCGNullWindowID) as NSArray? as? [[String: AnyObject]]
for entry in windowList!
{
var owner = entry[kCGWindowOwnerName as String] as! String
var bounds = entry[kCGWindowBounds as String] as? [String: Int]
var pid = entry[kCGWindowOwnerPID as String] as? Int32
print ("\(owner) \(bounds) \(pid) ")
if owner == "Erinnerungen"
{ bounds!["X"] = 0
bounds!["Y"] = 0
print("reset bounds")
let appRef = AXUIElementCreateApplication(pid!); //TopLevel Accessability Object of PID
print(appRef)
var value: AnyObject?
let result = AXUIElementCopyAttributeValue(appRef, kAXWindowsAttribute as CFString, &value)
if result == .success, let windowList = value as? [AXUIElement]
{ // DO ANYTHING
} else
{ print("Result no Success or no valid windowlist returnd")
}
}
}
Agora tento mudar algumas das propriedades, mas isso não tem efeito. Também tentar obter o AttributeValue para o Objeto de acessibilidade de nível superior do PID retorna AXError (kAXErrorCannotComplete = -25204)