How to register a custom keyboard shortcut for a windows application

前端 未结 4 2429
-上瘾入骨i
-上瘾入骨i 2021-02-15 17:56

I want to create a windows utility application, which can be called anytime from within any other application using a keyboard shortcut, e.g.:

Win + T<

4条回答
  •  隐瞒了意图╮
    2021-02-15 18:44

    If you need more advanced scenario to what the shell shortcut offer, you should start with reading Win32 Hooks and Hooks Overview.

    More specifically, you need to add a WH_KEYBOARD hook using the SetWindowsHookEx function. You also need to unhook through UnhookWindowsHookEx when you are done.

    There's an old article from Dino Esposito how to do Windows Hooks in .NET through some Win32 interop.

提交回复
热议问题