I am trying to send keystrokes for a public keyboard shortcut (e.g. control-F4) using CGEventCreateKeyboardEventand CGEventPost, but without succeeding. Sending such keystrokes with help CGPostKeyboardEventworked just fine, but the method has become deprecated, and I'm looking for an alternative.
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)118, true);
CGEventPost(kCGHIDEventTap, CGEventCreateKeyboardEvent(NULL, (CGKeyCode)118, true));
Will someone tell me what is wrong or something that I should read? I am afraid that this ability CGPostKeyboardEventto issue a system-wide shortcut is causing obsolescence. Any input would be appreciated!
source
share