title: How do I reliably invoke clipboard copy/paste actions in other apps without messing with input queue
body: <p>A while ago I wrote a simple app, which surrounds selected text in any input field in any application with some unicode symbols when user presses some hotkey. Basically, app's logic is as follows:</p>
  
  <ul>
  <li>Register global hotkey.</li>
  <li>Hotkey fired, now set clipboard monitor and invoke clipboard copy to see if some text was selected.</li>
  <li>If clipboard has changed and now contains text, surround said text with symbols and then invoke clipboard paste, so input field will be updated with modified text.</li>
  </ul>
  
  <p>The problem is, I can't get copy/paste functionality from other apps in a reliable way. What I have tried to date:</p>
  
  <ol>
  <li>If I send WM_COPY/WM_PASTE, it's more often ignored than not, depending on the application.</li>
  <li>If I use SendInput, keybd_event or any other keyboard-messing stuff to press/unpress usual clipboard hotkeys, it will often tamper with user-pressed keys: copy/paste uses control or shift, which are also quite popular for all generic hotkeys in all apps, my app included.</li>
  <li>If I use Journal Hook to directly inject keyboard messages into system input queue, sometimes it will work fine, and sometimes weird glitches will occur. Also, other applications may be using JournalHook for themselves, and that will mess my app badly. Not to mention that default security policies make journal hook hard to use.</li>
  <li>I've been trying to get/set text in the input fields using Windows UI automation instead of clipboard magic, but it rarely works.</li>
  </ol>
  
  <p>So, if you know other ways to make other applications reliably use copy/paste functionality, or can even devise entirely different approach, I'd really appreciate you telling me :)</p>