Simulate mouse operations with a keyboard

Source: Internet
Author: User

Using a keyboard to simulate mouse operations, text, cold air, or the technical weight of keyboard programming also requires a book, but it is not clear to me in a few words, and the ability is not enough. But I still do my best to use it for future review. The program can use the wm_keydown message to receive key messages. It usually calls case wm_keydown: Switch (wparam) {Case vk_up: getcursorpos (& pt); setcursorpos (pt. x, PT. y-10); break; Case vk_down: getcursorpos (& pt); setcursorpos (pt. x, PT. Y + 10); break; Case vk_space: mouse_event (mouseeventf_leftdown, 0, 0, 0); mouse_event (mouseeventf_leftup, 0, 0, 0); break ;}

The code above indicates that when you press the "upper mouse key", the cursor moves up. When you press the "lower mouse key", the cursor moves down. When you press the Space key, the mouse clicks are simulated. A wm_keydown message is a message action triggered when a user presses a key. Then, a switch statement is used to determine the key to be pressed. Wparam represents the virtual key code of each key on the keyboard. For example, vk_up is the cursor key, vk_down is the cursor key, and vk_space is the Space key. The following is the operation code. The PT in the above program is in the piont structure. It is also relatively simple to simulate the mouse action. Well, that's it. After learning it, I will write it again...

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.