Reputation: 349
I'm using this code to simulate a space down/release event in Objective-C:
CGEventRef CGEventCreateKeyboardEvent (CGEventSourceRef source, CGKeyCode virtualKey, bool keyDown);
CGEventRef simulateSpaceUp, simulateSpaceDown;
simulateSpaceDown = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)49, true);
simulateSpaceUp = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)49, false);
I know its incomplete, what am I missing?
UPDATE:
Using this to post:
CGEventPost(kCGSessionEventTap, simulateSpaceDown);
Almost there, though still not working...
Upvotes: 1
Views: 951
Reputation:
You have to post the event using CGEventPost. Just creating it doesn't do anything.
Upvotes: 1