title: C# p/invoke to RegisterHotKey for the key combo ALT+TAB not working (returns 0)
body: <p>I'm using the following code to intercept the ALT+TAB key sequence in my c# application.</p>
  
  <p>Some relevant snippets:</p>
  
  <pre><code>[DllImport("user32.dll")]
  private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>bool ret = RegisterHotKey(this.Handle, 0, MOD_ALT, 0x09);
  Console.WriteLine("return value:" + ret);
  Console.WriteLine("lasterror=" + Marshal.GetLastWin32Error());
  </code></pre>
  
  <p>and</p>
  
  <pre><code>    protected override void WndProc(ref Message m)
      {
          if (m.Msg == WM_HOTKEY)
          {
              MessageBox.Show("Generic hotkey interception");
              if (m.WParam.ToInt32() == 0)
              {
                  MessageBox.Show("ALT+TAB intercepted");
              }
          }
          base.WndProc(ref m);
      }
  </code></pre>
  
  <p>Pretty much in the second snippet, ret is false, but when I replace MOD_ALT (which is 0x01) with MOD_SHIFT (0x04), ret becomes true and the hotkey interception works.</p>
  
  <p>I was wondering why this is the case, because the many examples I've seen on the web state that they work.</p>