I have bindings that insert text into the current application as a sequence of keypresses. Each keypress is executed by:
https://github.com/sboosali/workflow-osx/blob/master/cbits/objc_workflow.m#L115
e.g. "A"
becomes (0x00020000, 0x00)
(i.e. (ShiftModifier, AKey)
).
However, this has limitations, such as filtering away Unicode characters. Rather than "indirectly" inserting text via keypresses, how could I "directly" insert text, including arbitrary Unicode?
Alternatives:
A subset of Unicode could be supported with the
Option
modifier, as capital letters are supported with theShift
modifier. However, it's only a subset.Inserting text via the clipboard supports all of Unicode. However, this overwrites the previous clipboard contents, and needs a variable-length delay.
(I've been reading through the documentation (like https://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSTextInputClient_Protocol/index.html#//apple_ref/occ/intfm/NSTextInputClient/insertText:replacementRange:), but I can't seem to get a hold of any of the objects I would need (like NSTextInputClient
)).