C # Implementation of mouse keyboard monitoring and shielding

Source: Internet
Author: User

The running interface is as follows:

Two notes:

Implementation of this function in C + + is very simple, there are many classic examples can be achieved, in C # There are many problems will occur.

For the hook is not familiar with the knowledge can refer to another article I reproduced: http://www.cnblogs.com/hocylan/articles/1033895.html[Microsoft Hook Technical Topic]

Three approximate steps

The main thing is to call the Windows API

Step One: Install hooks: SetWindowsHookEx (wh_codes idhook, HookProc lpfn,intptr pinstance, int threadId);

Step two: Callback and processing CallNextHookEx (IntPtr phookhandle, int ncode,int32 wParam, IntPtr lParam);

Step three: Complete the ordinary business process other processes

Apply the encapsulated hooks to the system ....

private void start_Click(object sender, EventArgs e)
    {hook_Main.InstallHook("1");}
    private void stop_Click(object sender, EventArgs e)
    {this.hook_Main.UnInstallHook();}
    private void stopkeyboard_Click(object sender, EventArgs e)
    { hook_Main.InstallHook("2"); }

Fourth step: Remove Hook UnhookWindowsHookEx (IntPtr phookhandle);

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.