title: C# Hook Global Keyboard Events - .net 4.0
body: <p>As part of a media player application I'm working on, I want to hook global key presses for media control keys (play, skip forward, skip back, etc).</p>
  <p>I've been searching for about 2 hours now trying to find a solution - but I couldn't find one that worked. I found several Stack Overflow answers about the same thing, but none of them worked.</p>
  <p>I tried the <a href="https://github.com/gmamaladze/globalmousekeyhook" rel="nofollow noreferrer"><code>MouseKeyHook</code></a> NuGet package, but it would never fire the event. I tried the <a href="https://github.com/factormystic/FMUtils.KeyboardHook#readme" rel="nofollow noreferrer"><code>FMUtils.KeyboardHook</code></a> package too, but the same thing happened, except it printed in the console that it shut down the hook right after starting it - and I have no idea why, even after looking at the source code.</p>
  <p>I tried to get this codeproject project <a href="http://www.codeproject.com/Articles/18638/Using-Window-Messages-to-Implement-Global-System-H" rel="nofollow noreferrer">http://www.codeproject.com/Articles/18638/Using-Window-Messages-to-Implement-Global-System-H</a> but I couldn't even run the demo, both the demos just threw weird errors that I couldn't trace.</p>
  <p>My question is, what is a known-to-work way of capturing keyboard presses in <strong>.NET 4.0</strong> that I can use to capture keyboard presses when my WinForms application isn't focused?</p>