I need to simulate the CMD + Option + D button at the same time. I have done all sorts and the best way I've seen is to do this:
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); CGEventRef cmdd = CGEventCreateKeyboardEvent(src, kVK_Command, true); CGEventRef cmdu = CGEventCreateKeyboardEvent(src, kVK_Command, false); CGEventRef optd = CGEventCreateKeyboardEvent(src, kVK_Option, true); CGEventRef optu = CGEventCreateKeyboardEvent(src, kVK_Option, false); CGEventRef dd = CGEventCreateKeyboardEvent(src, kVK_ANSI_D, true); CGEventRef du = CGEventCreateKeyboardEvent(src, kVK_ANSI_D, false); CGEventSetFlags(dd, kCGEventFlagMaskCommand);
However, this does not switch the dock, as when using my keyboard? Why is this? What am I doing wrong? I imported Carbon.h, so it seems like this should work?
source share