This is a very interesting small program developed by learning hook over the past few days to measure the distance between mouse movement and the number of mouse clicks.

Source: Internet
Author: User

Reference: hooks can monitor various event messages in the system or process, intercept and process messages sent to the target window. In this way, we can install custom hooks in the system to monitor the occurrence of specific events in the system and complete specific functions, such as intercepting keyboard and mouse input, and retrieving words on the screen, log monitoring. As you can see, hooks can be used to implement many special and useful functions. Therefore, it is necessary for senior programmers to master hook programming methods.


I have been learning for the past few days. Hook And then made a fun littleProgram, The main function is to count how many meters the mouse moves in a day, and how many times the keyboard hits, from this article Blog Start counting. Haha, I think it's quite fun.

About Hook Related information, there are a few good articles on the InternetArticleThese articles are valuable references. I suggest you reference them directly. If you are interested, you can study them:
MicrosoftHookTopics  ,
Using hooks from C # ,
Getting started with message Hook Functions ,
Global System hooks in. net ,
Keyboard hitting counter·. NetImplementationGlobal hook  ,
How: InVisual C #. netSet window hooks ,

In order to avoid closed doors, the program directly uses Georgi Of Useractivityhook Class, which is simple and suitable for my program. Of course, in the previous articles, you will find a class library with better functions. ^ 0 ^

AboutWh_keyboard_llLow-level hook andWh_mouse_llLow-level hook, Please refer to my previous study notes-hook (1)

My applet (statistics as of now ):

Main Interface of the program: Floating interface, which occupies a small amount of space and can be dragged

Program setting menu and program setting Interface

It should be noted that the display width refers to the physical width, which can be measured by the electronic ruler software.

Download the program and click here (to run the program, the system needs to install. Net framework1.1 or a later version)

For entertainment only, the source code is downloaded here !! You are welcome to give your valuable comments and are happy to modify the program to meet the needs of more people.

Questions raised by 81:

C # I also wrote a keyboard hook. At that time, I wanted to swap [and {to get the key value, but the swap always didn't work. I finally did it. I wonder whether the landlord can implement it?
There is no time to write this program for the moment, but you can first start with the idea, first judge the key value obtained from the hook keyboard event,
If it is a "{" key value, the keyboard event is simulated to send the "[" key value message, and vice versa}

About 16 MB of memory usage:
The reason is that the class array is used and the length is very large, so it is inevitable...
I will improve it if I have the opportunity.

 

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.