我正在制作基本的点击器。它通常可以正常工作,但每当我打开它都不会再点击(无论是窗户还是全屏),btw rust是一款生存游戏,在制作时需要大量点击。
#include <iostream>
using namespace std;
#include <windows.h>
#include <winuser.h>
#include <winable.h>
#include <vector>
#include <time.h>
#include <ctype.h>
#include <fstream>
#include <string>
void LeftClick();
void mouseLeftClick();
std::string getFileContents(std::ifstream& File);
int main()
{
HWND target = GetForegroundWindow();
POINT pt;
RECT wrect;
//Stealth();
char i;
int ms = 0;
//int key = 70;
char cKey = 'F';
int key = toupper(cKey);
cout << "how long to wait before next click? (in Milliseconds)\n";
cout << "Delay: ";
cin >> ms;
cout << "Delay set to " << ms << "\n";
cout << "What key do you want to press to activate the clicking?\n";
cout << "Key: ";
cin >> cKey;
cout << "Key set to " << char(toupper(cKey)) << "\n";
cout << "ASCII: " << key;
while (1)
{
for (i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
{
int key_stroke = i;
if (key_stroke == toupper(cKey))
{
GetCursorPos(&pt);
GetClientRect(target, &wrect);
mouseLeftClick();
cout << char(toupper(key_stroke)) << endl;
Sleep(ms);
}
}
}
}
return 0;
}
void mouseLeftClick()
{
INPUT Input =
{ 0 };
// left down
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
::SendInput(1, &Input, sizeof(INPUT));
// left up
::ZeroMemory(&Input,sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
::SendInput(1, &Input, sizeof(INPUT));
}
感谢任何帮助:D