Keyboard Hook API function parameter description

Source: Internet
Author: User

Source: https://www.cnblogs.com/grenet/archive/2010/12/07/1898840.html

1, KEYBOARD hook function is divided into two kinds, wh_keyboard_ll and wh_keyboard. We generally use the first, global keyboard hooks, which can intercept all the keyboard keys of the message.

2, online Some people say that the global hook to be placed in a separate DLL in order to use. I tried, do not put in a separate DLL, under XP+VS2005, debugging and operation are no problem, in xp+vs2008, debugging will be error, but can run after compiling, under win7+vs2010, debugging will be error, compile can run. This aspect has the research netizen, hoped the generous enlighten.

3, Wh_keyboard_ll and Wh_keyboard, this is two different hooks, although the last is the Keyboardhookproc function to deal with the interception of the message, but the specific meaning of each parameter is completely different.

    Wh_keyboard Hooks. Each parameter of the KEYBOARDHOOKPROC function has the following meanings:

Types of NCode messages, sub-hc_action and Hc_noremove

Virtual key code for WParam keys

LParam key parameter information, including the repetition time, the state of the key (press or bounce), etc.

    wh_keyboard_ll Hooks. Each parameter of the KEYBOARDHOOKPROC function has the following meanings:

NCode type of message, with Hc_action

WParam the state of the button (pressed or bounced) wm_keydown, Wm_keyup, Wm_syskeydown, Wm_syskeyup

The LParam pointer to the KEYBOARDHOOKSTRUCT structure that contains the details of the key.

As can be seen, the parameters of the two hooks are defined in a completely different way. In the previous code: Dim mykeyboardhookstruct as Keyboardhookstruct = DirectCast (Marshal.PtrToStructure (LParam, GetType ( keyboardhookstruct), keyboardhookstruct) is the copy that the pointer points to in the specified structure.

Keyboard Hook API function parameter description

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.