QuestionProblem with Clickbot (c++)

Posts 1–2 of 2 · Page 1 of 1
Problem with Clickbot (c++)
Hey Community,
at first, I have to say, that I am new to c++. (I am learning c++ since 2 months tbh.)
The source code first:
Code:
#include <Windows.h>

using namespace std;


int main()
{
	HWND hWnd = FindWindow(0, L"OSU!");
	if (hWnd == 0)
	{
		MessageBox(0, L"Window.", L"Error", MB_OK | MB_ICONERROR);
	}
	else {
		DWORD proccess_ID;
		GetWindowThreadProcessId(hWnd, &proccess_ID);
		HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proccess_ID);
		if (!hProcess)
		{
			MessageBox(0, L"Process.", L"Error!", MB_OK | MB_ICONERROR);
		}
		else {
			while (1) {
				if(GetAsyncKeyState(0x53)) {
					INPUT ip;
					
					ip.type = INPUT_KEYBOARD;
					ip.ki.wScan = 0;
					ip.ki.time = 0;
					ip.ki.dwExtraInfo = 0;

					ip.ki.wVk = 0x65;
					ip.ki.dwFlags = 0;
					SendInput(1, &ip, sizeof(INPUT));
					
					Sleep(50);

					ip.ki.dwFlags = KEYEVENTF_KEYUP;
					SendInput(1, &ip, sizeof(INPUT));

				}
			}
			CloseHandle(hProcess);
		}
	}

    return 0;
}
My problem: when I click the S-Key in the main menu, It clicks really fast, but when I am ingame, it just clicks once, as long as I hold the s-key.
At first I thought I messed up with the if-loop or sth, but why does it work in the main menu?

Please keep in mind that I am new to this language ^^

Thanks for your help.

P.S. I am not planning to make a hack or sth, I just wanted to test the handle function and the SendInput function.
Quote Originally Posted by stoxmel View Post
Hey Community,
at first, I have to say, that I am new to c++. (I am learning c++ since 2 months tbh.)
The source code first:
Code:
#include <Windows.h>

using namespace std;


int main()
{
	HWND hWnd = FindWindow(0, L"OSU!");
	if (hWnd == 0)
	{
		MessageBox(0, L"Window.", L"Error", MB_OK | MB_ICONERROR);
	}
	else {
		DWORD proccess_ID;
		GetWindowThreadProcessId(hWnd, &proccess_ID);
		HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proccess_ID);
		if (!hProcess)
		{
			MessageBox(0, L"Process.", L"Error!", MB_OK | MB_ICONERROR);
		}
		else {
			while (1) {
				if(GetAsyncKeyState(0x53)) {
					INPUT ip;
					
					ip.type = INPUT_KEYBOARD;
					ip.ki.wScan = 0;
					ip.ki.time = 0;
					ip.ki.dwExtraInfo = 0;

					ip.ki.wVk = 0x65;
					ip.ki.dwFlags = 0;
					SendInput(1, &ip, sizeof(INPUT));
					
					Sleep(50);

					ip.ki.dwFlags = KEYEVENTF_KEYUP;
					SendInput(1, &ip, sizeof(INPUT));

				}
			}
			CloseHandle(hProcess);
		}
	}

    return 0;
}
My problem: when I click the S-Key in the main menu, It clicks really fast, but when I am ingame, it just clicks once, as long as I hold the s-key.
At first I thought I messed up with the if-loop or sth, but why does it work in the main menu?

Please keep in mind that I am new to this language ^^

Thanks for your help.

P.S. I am not planning to make a hack or sth, I just wanted to test the handle function and the SendInput function.
OK, I found out what the problem was: I had to set another Sleep function after the KEYUP.
Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us