title: Programmatically Insert Text at active window that is not owned by App
body: <p>I want to code an application, that pastes for example the <code>DateTime</code> by just pressing a single button into my active window. </p>
  
  <p>For example:</p>
  
  <ul>
  <li>My application is running in the backround (Maybe systemtray)</li>
  <li>I am using Google Chrome and want to find out whats happening around the world</li>
  <li>I type "News" into google and press <code>F7</code> (or any other programmed key)</li>
  <li>My application detects <code>F7</code> was pressed and pastes <code>Now.ToShortDateString</code> to the active <code>Cursor Position</code> of Google Chrome</li>
  </ul>
  
  <p>Is that possible? I have already figuered out how to grab KeyPresses without my form beeing active by using the Windows Api of <code>user32.dll</code></p>
  
  <p>I also want to avoid using the <code>clipboard</code>.
  Otherwise i could for example use</p>
  
  <pre><code>Dim clipb As String= My.Computer.Clipboard.GetText()
  My.Computer.Clipboard.SetText(Now.ToShortDateString)
  'simulate CTRL+V
  My.Computer.Clipboard.SetText(clipb)
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>Since it seems that i have to simulate each KeyStroke on my own I decided to switch technique: </p>
  
  <ul>
  <li>Save clipboard</li>
  <li>Overwrite clipboard</li>
  <li>Simulate CTRL+V</li>
  <li>restore user-clipboard</li>
  </ul>
  
  <p>I managed to write the following code for that:</p>
  
  <pre><code>        Dim UserClipboard As Object = My.Computer.Clipboard.GetDataObject()
          My.Computer.Clipboard.SetText(Now.ToString)
          System.Windows.Forms.SendKeys.Send("^(v)")
          My.Computer.Clipboard.SetDataObject(UserClipboard)
  </code></pre>
  
  <p>It seems to be working for copied Files. 
  If I used <code>My.Computer.GetText()</code> and <code>My.Computer.SetText(UserText)</code> instead it would work for Text. I can't figure out how to tell my application when it should use which function.</p>
  
  <p>Also seems, that simulating <code>CTRL+V</code> doesnt work in <code>WinWord</code>
  Solution for this one: I was using CTRL+SHIFT+U for simulating keysends which is used by winword itself for underlining text.</p>