Ja, anscheinend können Sie dies unter https://majestysoftware.wordpress.com/2015/03/31/swift-scripting-part-1/ tun. Apple hat es jedoch nicht leicht gemacht.
Um den Mac-Desktop zu automatisieren, verwenden Sie normalerweise Apple-Skript. https://support.apple.com/de-de/HT202905
Ab OSX 10.10 können Sie JavaScript-Skripts für den Mac verwenden. Ich denke, das ist Apples Versuch, das Scripting einfacher zu machen, da das Apple-Skript IMO sehr schmerzhaft sein kann. https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/Articles/Introduction.html