当前位置:网站首页>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 .
边栏推荐
- Text capture picture (Wallpaper of Nezha's demon child coming to the world)
- 项目优化个人感悟
- Install MySQL using CentOS yum
- mysql设置密码时报错 Your password does not satisfy the current policy requirements(修改·mysql密码策略设置简单密码)
- 解决openwrt package目录下多个文件夹重名编译警告(call subdir 函数)
- Pycharm导入已有的Project
- 解决MT7620不断循环uboot(LZMA ERROR 1 - must RESET board to recover)
- Coturn service installation in webrtc
- Time series ARIMA model
- 借5G东风,联发科欲再战高端市场?
猜你喜欢

Determine the exact type of data

使用transform:translate()出现内容模糊问题

openwrt 增加RTC(MCP7940 I2C总线)驱动详解

Understand │ what is cross domain? How to solve cross domain problems?

Mapreduce实例(二):求平均值

时间序列——使用tsfresh进行分类任务

The difference and use between get request and post request

DEX and AMMS of DFI security

Embedded development: tips and techniques -- seven techniques to meet the real-time deadline

Openwrt增加对 sd card 支持
随机推荐
Short video mall system, system prompt box, confirmation box, click blank to close the pop-up box
Paper_ Book
Chapter I Marxist philosophy is a scientific world outlook and methodology
C语言程序设计(第三版)
The difference and use between get request and post request
Single machine high concurrency model design
Reduce program ROM ram, GCC -ffunction sections -fdata sections -wl, – detailed explanation of GC sections parameters
Firefox old version
IO stream introduction
First acquaintance with MySQL database
Scratch crawler framework
Mapreduce实例(三):数据去重
centos上mysql5.7主从热备设置
Nacos
无线网络分析有关的安全软件(aircrack-ng)
The 4.3 billion euro cash acquisition of OSRAM failed! AMS said it would continue to acquire
2.2 JMeter基本元件
ARIMA模型选择与残差
webRTC中的coturn服务安装
DRF learning notes (II): Data deserialization