Mouse Input Not Working :(

Posts 1–2 of 2 · Page 1 of 1
Mouse Input Not Working :(
Hello so im totally new to C++ but i have already coded in C# for a long time so im not totally new to coding

So i wanted to make a trigger bot for Paladins as i tried the program called Chimpeon and it worked as it should there so i thought how hard can it be to make a trigger bot using pixel scan!

Everything is working besides the Sendinput
I have tried everything not even joking... I have been stuck at the same place for over 3 hours now... I only need to make it should when it detects the right color.

Im not hooking anything into the game as that would get people banned and i think it should work without a hook as Chimpeon is a simple key presser program so why shouldn`t it work with just the normal SendInput ?


Code:
// PaladinsTriggerBot.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include "Windows.h"
#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
 
 
 
LPCSTR gameWindow = "Paladins (32-bit, DX11)";
HWND hwnd;
 
 
void Shoot() {
	std::cout << "HEY!"<< std::endl;
	
 
}
 
void Detect() {
	
	COLORREF colorPixel;
 
	DWORD foundTarget = 4210942;
 
	POINT p;
	HDC hDC = GetDC(0);
	int x, y;
 
	while (!GetAsyncKeyState(VK_INSERT))
	{
 
		x = 1920;
		y = 1080;
 
		//x = 3840;
		//y = 2160;
		
		colorPixel = GetPixel(hDC, x, y);
	    std::cout << x << " " << y << " " << GetPixel(hDC, x, y) << std::endl;
		std::cout << colorPixel << std::endl;
		if (colorPixel == foundTarget) {
 
 
			//mouse_event(MOUSEEVENTF_LEFTDOWN , 0, 0, 0, 0);
			//PostMessage(hwnd, WM_LBUTTONDOWN, 0, MAKELPARAM(1920, 1080));
 
			//PostMessage((HWND)hwnd, WM_LBUTTONDBLCLK, MK_LBUTTON, 0);
			/*
			INPUT    Input = { 0 };													// Create our input.
 
			Input.type = INPUT_MOUSE;									// Let input know we are using the mouse.
			Input.mi.dwFlags = VK_LBUTTON;							// We are setting left mouse button down.
			SendInput(1, &Input, sizeof(INPUT));								// Send the input.
 
			ZeroMemory(&Input, sizeof(INPUT));									// Fills a block of memory with zeros.
			Input.type = INPUT_MOUSE;									// Let input know we are using the mouse.
			Input.mi.dwFlags = WM_LBUTTONDOWN;								// We are setting left mouse button up.
			SendInput(1, &Input, sizeof(INPUT));								// Send the input.
 
			*/
 
		}
		Sleep(150);
	}
	ReleaseDC(0, hDC);
}
 
 
int main()
{
	hwnd = FindWindowA(NULL, gameWindow);
	std::cout << "Welcome to XXXXXX triggerbot for Paladins!" << std::endl;
	std::cout << "Please hold on while we get the triggerbot ready for you!" << std::endl;
	Sleep(200);
	while (!GetAsyncKeyState(VK_INSERT))
	{
 
		Detect();
	}
 
	return 0;
}

I know my code is a mess but i have tried my best for one of my first C++ programs/consoles.

If someone knows how i can fix this send mouse input please tell me as im gonna go insane in a few hours if this keep on fucking with me

Thanks for reading!
This code is truly a mess. Professional programmers call code like this a "BFM", short for big fucking mess.

Anyways, you spend 3 hours trying to figure out why it's not working and you haven't looked at the SendInput documentation?
You need to use MOUSEEVENTF_RIGHTDOWN for the flags.. Also next time call GetLastError and look at the list of System error codes, that will tell you why it's not working.
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us