当前位置:网站首页>Yys mouse connector
Yys mouse connector
2022-07-27 16:21:00 【Smile Hun】
Call the acquisition and Simulation of the mouse
#include<Windows.h>
void WINAPI mouse_event(
/* quote Windows Library's own functions , Operate the simulated mouse */
DWORD dwFlags,
DWORD dx,
DWORD dy,
DWORD dwData,
ULONG_PTR dwExtraInfo
);
GetCursorPos(&mouse1); // Get mouse position
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); // Simulate left mouse button press
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // Simulate the left mouse button lifting
Setting of delay function
#include<time.h>
srand(t); // Take time as the seed to select random numbers P.S. Call in advance <time.h>
Sleep(rand() % 20); // Random delay 0-20ms
mouse_Row = rand() % mouseShift_Row + mouse1.x;; // stay mouse1.x To mouse2.x Determine a abscissa randomly
/* call rand Expression of function :rand()% Offset + minimum value ; It's calling rand Function time , You need to get an offset range , Then random offset is carried out on the basis of the minimum value .*/
The stop of the program
#include <conio.h>
if (_kbhit() && _getch() == 0x1b) // When the keyboard reads esc Key to exit the program
return 0;
Complete code
#include <stdio.h>
#include<Windows.h>
#include<time.h>
#include <conio.h>
void WINAPI mouse_event(
/* quote Windows Library's own functions , Operate the simulated mouse */
DWORD dwFlags,
DWORD dx,
DWORD dy,
DWORD dwData,
ULONG_PTR dwExtraInfo
);
int main() {
POINT mouse1,mouse2, mouse3, mouse4; // Used to store the mouse x y coordinate ( The essence is the structure ) point Defined a 2 Dimensional coordinates (x,y), in other words point x=(1,2); Is established
time_t t = time(NULL);
long STOP,i=0 ;
printf(" Please enter the connecting time ( Company : Hours ):");
scanf_s("%d" , &STOP);
STOP = STOP * 2400;
Sleep(2000);
printf(" Please place the mouse over “ Challenge ” The left border of the icon , Move to the right border after the mouse position is displayed , Similarly, complete the upper boundary 、 Setting of the lower boundary \n");
srand(t);
Sleep(2000);
GetCursorPos(&mouse1); // call GetCursorPos Function to get the coordinate value of the left boundary of the icon
printf(" Left mouse threshold (%d,%d)\n", mouse1.x, mouse1.y);
Sleep(2000); // Time delay 2000ms namely , Wait two seconds
GetCursorPos(&mouse2); // call GetCursorPos Function to get the coordinate value of the right boundary of the icon
printf(" Right mouse threshold (%d,%d)\n", mouse2.x, mouse2.y);
Sleep(2000);
GetCursorPos(&mouse3); // call GetCursorPos Function to get the boundary coordinate value on the icon
printf(" Mouse, threshold (%d,%d)\n", mouse3.x, mouse3.y);
Sleep(2000);
GetCursorPos(&mouse4); // call GetCursorPos Function to obtain the coordinate value of the lower boundary of the icon
printf(" Under mouse threshold (%d,%d)\n", mouse4.x, mouse4.y);
Sleep(2000);
int mouseShift_Row,mouseShift_Column,mouse_Row,mouse_Column;
mouseShift_Row = mouse2.x - mouse1.x; // Set the horizontal offset of the virtual mouse
mouseShift_Column = mouse3.y - mouse4.y; // Set the vertical offset of the virtual mouse
while (i<=STOP) {
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); // Simulate left mouse button press
Sleep(rand() % 20); // Random delay 0-20ms
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // Simulate left mouse button release
mouse_Row = rand() % mouseShift_Row + mouse1.x;; // stay mouse1.x To mouse2.x Determine a abscissa randomly
mouse_Column = rand() % mouseShift_Column + mouse4.y;;// stay mouse3.y To mouse4.y Determine a vertical coordinate randomly
SetCursorPos(mouse_Row, mouse_Column); // Set the determined coordinates as the mouse position , Start next cycle
Sleep(rand() % 1500);
if (_kbhit() && _getch() == 0x1b)
return 0;
}
return 0;
}
Code packaging
- Set the... In the debugging state Debug Change it to Release

- Click on “ project ” The last item in the drop-down menu “ attribute ”
.
- In the code generation interface Runtime Select multithreading from the drop-down list of options

- Finally, choose to regenerate the solution , Then you can find the extension under the project file .exe The executable of

shortcoming
You must press on the execution page of the program esc Can terminate the program , Unable to monitor the dynamics of the keyboard in the global state .
边栏推荐
- firefox旧版本
- Your password does not satisfy the current policy requirements (modify MySQL password policy setting simple password)
- A powerful web vulnerability scanning and verification tool (vulmap)
- scrapy爬虫框架
- busybox login: can't execute '/bin/bash': No such file or directory 解决方法
- Enable shallow and deep copies+
- Flask connects to existing tables in MySQL database
- 2.2 basic elements of JMeter
- Determine the exact type of data
- Coding technique - Global log switch
猜你喜欢
随机推荐
Redis简介与使用
企业运维安全就用行云管家堡垒机!
时间序列——使用tsfresh进行分类任务
Common tool classes under JUC package
JSP基础
Addition, deletion, query and modification of MySQL table data
Chuanyin holdings disclosed that it was prosecuted by Huawei: a case has been filed, involving an amount of 20million yuan
Short video mall system, system prompt box, confirmation box, click blank to close the pop-up box
Openwrt compilation driver module (write code at any position outside the openwrt source code, and compile independently in a modular manner.Ko)
第一章 马克思主义哲学是科学的世界观和方法论
Pycharm导入已有的Project
vant-ui toast和dialog使用
Servlet basic knowledge points
百度图片复制图片地址
Reduce program ROM ram, GCC -ffunction sections -fdata sections -wl, – detailed explanation of GC sections parameters
Mapreduce实例(三):数据去重
To meet risc-v challenges? ARM CPU introduces custom instruction function!
文本截取图片(哪吒之魔童降世壁纸)
makefile 中指定程序运行时加载的库文件路径
Example of the task submitted by the Flink packer







