Posted these days learning hook get out of a pretty funny statistic the small program of the mouse moving distance and the number of keystrokes

Source: Internet
Author: User
Posted these days learning hook get out of a pretty funny statistic the small program of the mouse moving distance and the number of keystrokes

References: Hooks can monitor various event messages in the system or process, intercept messages destined for the target window, and process them. In this way, we can install a custom hook in the system, monitor the occurrence of specific events in the system, complete specific functions, such as the interception of keyboard, mouse input, screen Word, log monitoring and so on. It is obvious that using hooks can achieve many special and useful functions. Therefore, for senior programmers, it is necessary to master the hook programming method.


These days have been learning about the Hook of the relevant knowledge, and then they did a fun small program, the main function of statistics one day the mouse moved how many meters, as well as how many times the keyboard percussion, from the beginning of this blog count, hehe, I think it is very fun.

About the Hook, there are several good articles on the Internet, these articles are valuable reference materials, I still refer directly to the Address bar, interested can study:
Microsoft Hook topic,
Using Hooks from C #,
Message hook function Entry,
Global System Hooks in. NET,
Keyboard Percussion Counter · NET to implement the global Hook,
How to: Set Window hooks in Visual C #. NET,

In order to avoid behind closed doors, the program directly used the Georgi Useractivityhook class, simple and suitable for my program, of course, above in several articles, you will find more powerful and more perfect class library, that is something ^0^

For Wh_keyboard_lllow-level Hook and the Wh_mouse_lllow-level hook, see my previous study Note learning notes-hook hooks (1)

Screenshot of my applet (up to date statistics):

Program main interface: Floating interface, occupies a small space, can be dragged


Program settings menu and Program settings interface


The display width refers to the physical width, which can be measured by the electronic ruler software.

Program Download Click here (Run the program, the system needs to install. NET Framework1.1 or later)

For entertainment only, the source code is downloaded here. You are welcome to put forward your valuable opinions and will be happy to revise this procedure to meet the needs of more people.


Questions raised on 81:
C # keyboard Hook I also wrote, was to want to [and {Exchange, get key value no problem, but the exchange is always not, and finally do, I do not know whether the landlord can achieve.
There is no time to write this program, but you can first say the idea, first of all, to determine the key to the keyboard event to get the value,
If the "{" Key value simulates the keyboard event to send a message with the "[" key value, the other is sent}

About the memory 16M problem:
The reason is that the use of the array of classes, and the length is very large, so inevitably ...
I'll make it better with a chance.

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.