Winform simulate mouse buttons

Source: Internet
Author: User

Today, my friend said that he was disgusted by the company's learning website. After work, he asked him to read the learning materials. After reading the next page, he asked him how long he had to stay on the next page to click the next page, I couldn't even see it, so in the evening I had a whim to give him a program to simulate the mouse buttons, so that the mouse can be triggered at regular intervals, by the way, the program is minimized to the bottom right corner.

First, you need to reference the user32.dll file, which is found in the computer. C: \ Windows \ System32 is searched and copied to the debug directory.

The following is the solution code.

, CharSet = CharSet. auto, CallingConvention = mouse_event (dwFlags, dx, dy, cButtons, MOUSEEVENTF_MOVE =; MOUSEEVENTF_LEFTDOWN =; events =; MOUSEEVENTF_RIGHTDOWN =; events =; MOUSEEVENTF_ABSOLUTE =; timereffectick (| MOUSEEVENTF_LEFTUP, Cursor. position. x, Cursor. position. y, | MOUSEEVENTF_LEFTUP | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, Cursor. position. x, Cursor. position. Y ,,View Code

 

This is the design interface

Form1_Resize (. WindowState ===. ShowInTaskbar =;

Restore the form when double-clicking the minimize icon

          notifyIcon1_MouseDoubleClick( (!.ShowInTaskbar = .WindowState =

After completing the overall work, remember to give the policyicon control an icon. Run the program, start the button, and minimize the program. Then, the mouse clicks the program at intervals.
Extended: You can add the keyboard Button Function to simulate the keyboard button at a specified time. Whether the simulated mouse wheel can be added. If necessary, you can continue writing the code.

  

 

 

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.