title: PostMessage to Current Active Process doesn't work for all process?
body: <p>I have this code:</p>
  
  <pre><code>    const UInt32 WM_KEYDOWN = 0x0100;
  
      const int VK_DOWN = 0x28;
      const int VK_UP = 0x26;
  
      [DllImport("user32.dll")]
      static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
  
      [DllImport("user32.dll")]
      private static extern IntPtr GetForegroundWindow();
  
      [DllImport("user32.dll")]
      private static extern Int32 GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
  
      private static Process GetProcessByHandle(IntPtr hwnd)
      {
          try
          {
              uint processID;
              GetWindowThreadProcessId(hwnd, out processID);
              return Process.GetProcessById((int)processID);
          }
          catch { return null; }
      }
  
      public static Process GetActiveProcess()
      {
          IntPtr hwnd = GetForegroundWindow();
          return hwnd != null ? GetProcessByHandle(hwnd) : null;
      }
  
      public static void KeyUp()
      {
          PostMessage(GetActiveProcess().MainWindowHandle, WM_KEYDOWN, VK_UP, 0);
      }
  
      public static void KeyDown()
      {
          PostMessage(GetActiveProcess().MainWindowHandle, WM_KEYDOWN, VK_DOWN, 0);
      }
  </code></pre>
  
  <p>When i call the KeyUp/KeyDown it works only on some process, proccess like text editos, visual studio.</p>
  
  <p>But doesn't work on Explorer.exe, iTunes.exe, Chrome.exe, Outlook.exe, FileZilla.exe and more..</p>
  
  <p>I ran debug on console:</p>
  
  <pre><code>    while (true)
      {
          Process currentProcess = GetActiveProcess();
          if (currentProcess != null)
              Console.WriteLine(currentProcess.MainWindowTitle);
          Thread.Sleep(1000);
      }
  </code></pre>
  
  <p>Here what I get from some applications:</p>
  
  <pre><code>ProjName - Microsoft Visual Studio (Administrator)
  ?PostMessage to Current Active Proccess doesn't work for all proccess ? - StackOverFlow - Google Chrome?
  FileZilla
  Inbox - Outlook Data File - Microsoft Outlook
  </code></pre>
  
  <p>And on Explorer.exe i get empty line..</p>