Hi,
My app needs to send key strokes to other applications. Sending key strokes works by using CGEventCreateKeyboardEvent/CGEventSetFlags/CGEventPost/CFRelease sequence. Normal key strokes and key strokes with modifiers works. I am even able to send only modifier key strokes (e.g. only Alt). The issue is that when I send only modifier key and then press normal key from the keyboard that does not work (e.g. my app- command then p from keyboard). Holding down modifier key from my app works but as soon as normal key is pressed from keyboard modifier key is released.
Also I have never been able to get the modifier keys to work the following way:
event1 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, true); (shift down)
event2 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)6, true); (z down)
event3 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)6, false); (z up)
event4 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, false); (shift up)
Modifier keys only work if I set them with CGEventSetFlags.
Could the issue be CGEventSource and CGEventTapLocation? What should these values be in CGEventCreateKeyboardEvent and CGEventPost?
Other ideas?
Thanks!