Low level keyboard input from Windows

后端 未结 5 1323
时光取名叫无心
时光取名叫无心 2021-01-06 01:19

What win32 calls can be used to detect key press events globally (not just for 1 window, I\'d like to get a message EVERY time a key is pressed), from a windows service?

5条回答
  •  没有蜡笔的小新
    2021-01-06 01:59

    Take a look at the hooks you can set with SetWindowHookEx:

    http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx

    However, unless you are running an "interactive" service, you won't have access to the desktop (and you shouldn't be running an interactive service because it won't work right in newer versions of Windows). You will have to look into the session and desktop management APIs in order to access the desktop/console.

提交回复
热议问题