I'm trying to manipulate the frontMostApplication in macOS and send unicode characters to it. For example when writing text.
So far, my approach has been to manipulate and simulate the keyboard like so
let active = NSWorkspace.shared.frontmostApplication
let space = CGEventSource(stateID: .hidSystemState)
let ev = CGEvent(keyboardEventSource: space, virtualKey: 0 as CGKeyCode, keyDown: true)
if let pid = active?.processIdentifier{
ev?.postToPid(pid)
}
Which will allow me to push an ascii a
to the app. I'm wondering how I can insert other characters, such as unicode emojis. I might be able to use ALT + combinations for unicode, but that seems tediously cumbersome, and I would expect there to be a better way.
Thanks!