title: Sending keystroke event 'paste' to a specific application Mac
body: <p>i am using a code to simulate a 'Paste ' to the frontmost application using carbon on MacOS. Now, i need to do that to a specific application not in frontmost. I am using this code so far with the use of PostToPsn :</p>
  
  <pre><code>   ProcessSerialNumber psn;
     //Using 8844 for testing purposes (safari)
     OSStatus err = GetProcessForPID(8844, &amp;psn);
  
     CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
     CGEventRef cmdDown = CGEventCreateKeyboardEvent(source,kVK_ANSI_V, YES);
     CGEventSetFlags(cmdDown, kCGEventFlagMaskCommand);
     CGEventRef cmdUp = CGEventCreateKeyboardEvent(source, kVK_ANSI_V, NO);
  
     if(err == noErr){
  
         CGEventPostToPSN(&amp;psn, cmdDown);
         CGEventPostToPSN(&amp;psn, cmdUp);
  
         CFRelease(cmdUp);
         CFRelease(cmdDown);
         CFRelease(source);
  
     }
  </code></pre>
  
  <p>It works using just a letter but when doing a combo with command, it doesn't work at all. </p>