How to simulate Caps Lock keystroke with CGEventCreateKeyboardEvent in OS X
Has anyone had any luck simulating Caps Lock keystroke with CGEventCreateKeyboardEvent on OS X? Basically I have tried alphabetic character and alphanumeric character okay but Caps Lock. Hopefully, I would like to simulate Caps Lock keystroke to trun on/off the LED. I don't know what problem is for my test code. Has anyone had experinces for this? #include <stdio.h> #include <ApplicationServices/ApplicationServices.h> main() { bool wasCapsLockDown = CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, 57); if (wasCapsLockDown) printf("On\n"); else printf("Off\n"); ProcessSerialNumber psn;