title: simulate a keypress in c#?
body: <p>I searched the internet and in the fourum but cant find how to do it. what i want to do is to send a text in a discord chat every 5 minutes. and i want to send it from my account so i want to write a simple console app thet just output text and an enter to another programe.
  I tried the sendInput class but dident get it to work.</p>
  <pre><code>  [DllImport(&quot;user64.dll&quot;)]
      public static extern int SetForegroundWindow(IntPtr hWnd);
      [STAThread]
      static void Main(string[] args)
      {
          
          while (true)
          {
              Process[] processes = Process.GetProcessesByName(&quot;iexplore&quot;);
              SendInput
              foreach (Process proc in processes)
              {
                  SetForegroundWindow(proc.MainWindowHandle);
                  SendKeys.
              }
  
              Thread.Sleep(5000);
          }
      }
  </code></pre>
  <p>How do i do that?</p>