C # mouse Keyboard monitor

Source: Internet
Author: User

/*********************************************************************************** * C # Mouse Keyboard Monitor * Description: * Recently want to use C # to do a mouse, keyboard simulator, so found a bit of data simulation. * 2016-7-10 Shenzhen Nanshan Ping Shan village Zengjianfeng *********************************************** ***********************************/First, reference documents:1. How C # uses buttons to implement the mouse wheel operation http://blog.csdn.net/jglie/article/details/6872333    2. C # mouse_event Analog mouse Click event Absolute position http://blog.sina.com.cn/s/blog_71d894bd01013goa.html    3. C # Win32API simulates mouse movement and click event http://www.cnblogs.com/08shiyan/archive/2011/07/18/2109086.html    4. How To:simulate Mouse and Keyboard EventsinchCode https://msdn.microsoft.com/en-us/library/ms171548.aspx    5. SendKeys Class https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx    6. virtual-Key Codes https://msdn.microsoft.com/zh-cn/library/dd375731 (v=vs.85). aspx    7. C # Converts the letter/character to the keyboard's key/key value/keycode http://www.crifan.com/convert_char_letter_to_key_keycode_in_csharp/    8. Vkkeyscan function https://msdn.microsoft.com/en-us/library/ms646329 (vs.85). aspxSecond, KeyBoardusingSystem; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Runtime.InteropServices; usingSystem.Windows.Forms; namespaceMOUSEMONITORW {classKeyBoard {[DllImport ("user32.dll")]            Static extern voidKeybd_event (byteBVK,byteBscan,UINTDwFlags,intdwExtraInfo); [DllImport ("user32.dll")]             Public Static externKeys Vkkeyscan (Charch);  Public Static voidSendkey (Charkey) {keybd_event (byte) Vkkeyscan (Key),0,0,0); Keybd_event ((byte) Vkkeyscan (Key),0,2,0); }}} III, Mouse:usingSystem; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Runtime.InteropServices; namespaceMOUSEMONITORW {classMouse {Private Const intMouseeventf_move =0x0001;//Move Mouse            Private Const intMouseeventf_leftdown =0x0002;//simulate the left mouse button press            Private Const intMouseeventf_leftup =0x0004;//simulate the left mouse button to lift up            Private Const intMouseeventf_rightdown =0x0008;//simulate the right mouse button press            Private Const intMouseeventf_rightup =0x0010;//Simulate right mouse button lift            Private Const intMouseeventf_wheel =0x0800;//Simulating mouse wheel            Private Const intMouseeventf_middledown =0x0020;//simulate the middle mouse button press            Private Const intMouseeventf_middleup =0x0040;//Simulate mouse middle button lift            Private Const intMouseeventf_absolute =0x8000;//indicate if absolute coordinates are used[DllImport ("User32")]            Private Static extern intMouse_event (intDwFlags,intDxintDyintCbuttons,intdwExtraInfo);  Public Static voidMoveintDxintdy) {mouse_event (mouseeventf_move, dx, DY,0,0); }             Public Static voidAbsmove (intXinty) {mouse_event (Mouseeventf_absolute| Mouseeventf_move, -, -,0,0); }             Public Static voidWheelintRoll ) {mouse_event (Mouseeventf_wheel,0,0, Roll,0); }             Public Static voidLeftsingle () {mouse_event (Mouseeventf_leftdown| Mouseeventf_leftup,0,0,0,0); }             Public Static voidleftdouble () {mouse_event (Mouseeventf_leftdown| Mouseeventf_leftup,0,0,0,0); Mouse_event (Mouseeventf_leftdown| Mouseeventf_leftup,0,0,0,0); }             Public Static voidRight () {mouse_event (Mouseeventf_rightdown| Mouseeventf_rightup,0,0,0,0); }             Public Static voidMiddle () {mouse_event (Mouseeventf_middleup| Mouseeventf_middledown,0,0,0,0); }        }    }

C # mouse Keyboard monitor

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.