我需要Windows API中的类似SendInput的东西。

我看到了这种方法,但我不知道是否有将Unicode字符转换为虚拟Key代码的方法。

CGEventRef CGEventCreateKeyboardEvent (
   CGEventSourceRef source,
   CGKeyCode virtualKey,
   bool keyDown
);

最佳答案

CGEventRef e = CGEventCreateKeyboardEvent(NULL, NULL, true);
CGEventKeyboardSetUnicodeString(e, unicodeStringLength, unicodeString);
CGEventPost(kCGHIDEventTap, e);

关于macos - 如何将Unicode字符发送到事件应用程序?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6943969/

10-10 19:38