Haim Bender
Haim Bender

Reputation: 8187

How can I listen in on shortcuts when the app is the task bar in C#

An example of an app that does this is Enso, it pops up when you press the caps lock.

Upvotes: 2

Views: 353

Answers (2)

Lars Truijens
Lars Truijens

Reputation: 43595

You can act on global hotkeys by calling the winapi function RegisterHotKey. Also see https://www.codeproject.com/Articles/4345/NET-system-wide-hotkey-component and https://www.codeproject.com/Articles/3055/System-Hotkey-Component for example. You can not use all key combination as hotkeys. For those that don't work you might try a global keyboard hook (SetWindowsHookEx)

Upvotes: 3

Maximilian
Maximilian

Reputation: 4828

You need to install a hook in user32.dll. Lookup the Win32-API call SetWindowsHookEx. You can call it from C# via the stuff in System.Runtime.InteropServices.

This article discusses the topic nicely.

Edit: Lars Truijens answer looks like a nicer approach actually.

Upvotes: 0

Related Questions