Here’s code to simulate a Cmd–S action: CGKeyCode inputKeyCode = kVK_ANSI_S; CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); CGEventRef saveCommandDown = CGEventCreateKeyboardEvent(source, inputKeyCode, YES); CGEventSetFlags(saveCommandDown, kCGEventFlagMaskCommand); CGEventRef saveCommandUp = CGEventCreateKeyboardEvent(source, inputKeyCode, NO); CGEventPost(kCGAnnotatedSessionEventTap, saveCommandDown); CGEventPost(kCGAnnotatedSessionEventTap, saveCommandUp); CFRelease(saveCommandUp); CFRelease(saveCommandDown); CFRelease(source); A CGKeyCode is nothing more than an unsigned integer: typedef uint16_t CGKeyCode; //From CGRemoteOperation.h Your real issue will be … Read more