Remote control of mouse, button simulation

Source: Internet
Author: User

For remote control related software (telecommuting, distance education, Remote Assistance, etc.), mouse, key simulation is essential. In the Windows environment, the Windows API provides two ways to complete the mouse and key simulation easily: Mouse_event, keybd_event. When simulating the mouse button click, first calculate the mouse position x, y (using ClientToScreen), and move the controlled end mouse position to the x, y position, that is, the mouse move event (Setcursorpos), and then use mouse_event to simulate the need to perform the mouse behavior, Mainly for pressing, bouncing up. The key of the simulation is mainly the button press and bounce up.

Mouse Simulation:

1 //Mouseeventf_leftdown = $0002;//left button pressed2 //mouseeventf_leftup = $0004;//left button bouncing3 //Mouseeventf_rightdown = $0008;//Right-click4 //mouseeventf_rightup = $0010;//Right-click Bounce5 //Mouseeventf_middledown = $0020;//middle Key Press6 //mouseeventf_middleup = $0040;//middle key bouncing up7 8 //set the mouse position (analog mouse must first set the correct position)9 Setcursorpos (X, Y)Ten  One //left-click (right and Middle keys are similar) AMouse_event (Mouseeventf_leftdown, x, Y,0,0) -Mouse_event (Mouseeventf_leftup, x, Y,0,0) - //left-click Combo notation theMouse_event (Mouseeventf_leftdownorMouseeventf_leftup, X, Y,0,0) -  - //left Double-click (right, middle key similar to this) -Mouse_event (Mouseeventf_leftdown, x, Y,0,0) +Mouse_event (Mouseeventf_leftup, x, Y,0,0) -Mouse_event (Mouseeventf_leftdown, x, Y,0,0) +Mouse_event (Mouseeventf_leftup, x, Y,0,0) A //left-click Combo notation atMouse_event (Mouseeventf_leftdownorMouseeventf_leftup, X, Y,0,0) -Mouse_event (Mouseeventf_leftdownorMouseeventf_leftup, X, Y,0,0)
MouseEvent

Keyboard emulation:

1 //Press the A key ord (' a ') to take the ASCII value of the key2Keybd_event (Ord ('A'),0,0,0);3 //release the A key (a keystroke on the keyboard performs a press and release of the corresponding key)4Keybd_event (Ord ('A'),0, Keyeventf_keyup,0);5 6 //Key combinations: Ctrl + A7Keybd_event (Vk_control,0,0,0);8Keybd_event (Ord ('A'),0,0,0);9Keybd_event (Ord ('A'),0, Keyeventf_keyup,0);TenKeybd_event (Vk_control,0, Keyeventf_keyup,0);

Remote control of mouse, button simulation

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.