How to register a custom keyboard shortcut for a windows application

前端 未结 4 2414
-上瘾入骨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:32

    An option for doing that programatically when your application start is calling this Windows API:

    RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);
    

    And to unregister call this API:

    UnregisterHotKey(IntPtr hwnd, int id);
    

    Both exist in user32 APIs

    http://www.pinvoke.net/search.aspx?search=RegisterHotKey&namespace=[All]

提交回复
热议问题