Does anyone know of any Swift APIs for interacting at the level of the OS itself?
Does anyone know of any Swift APIs for interacting at the level of the OS itself?
I know you asked about Swift, but...
If you're ok with third party software, I would recommend keyboard maestro. In addition to triggers (keyboard-based and others), it offers a pretty high level API over the macOS automation stuff you'd typically hack together with AppleScript, such as "activate app", "bring window at index i to front", "simulate keystroke", "insert text", "move the mouse to x,y relative to Element", "run JS in frontmost browser tab", etc. And that's only roughly 5% of what it can do.
With keyboard maestro I don't see much point in writing one's own native automation apps. The APIs it exposes are just as powerful as what you could write yourself and a heck of a lot easier to use.