1

I've build a WPF application and want to add global hotkey support. I want to be able to execute a method in my application from anywhere in windows, even when my application is minimized or running in tray. For example, execute the method with ctrl + alt + t.

Is this possible in WPF, and if so, how?

Sander
  • 85
  • 3
  • 10

1 Answers1

1

You need to take a look at RegisterHotKey in user32.dll. Here's a good example at pinvoke.net: http://www.pinvoke.net/default.aspx/user32/RegisterHotKey.html

JohnForDummies
  • 950
  • 4
  • 6
  • 1
    @user999999928 WPF doesn't natively support this. It needs to be done through p/Invoke, which can be called from WPF. – Bradley Uffner Nov 03 '16 at 19:54
  • 2
    Take a look at https://social.technet.microsoft.com/wiki/contents/articles/30568.wpf-implementing-global-hot-keys.aspx as well. I've found it really helpful. – mzf May 03 '17 at 15:37