Solved Color TriggerBot problem

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

HelpMe

Newbie
Full Member
Jan 17, 2016
23
98
1
So I just watched Fleeps tutorial of how to make a color triggerbot, I have copied the code to my liking and it is completely done. It finds the game window, I choose the color I want it to scan, and then it starts scanning in some case. What I mean by that is that it like, is scanning (and clicking) the program and is doing all that shiz, but when I go to the game window and start playing, it appears to stop scanning or something and does not shoot the desired black enemies. Here is a video so you can get a better understanding of what it is like and what game I am trying this on. https://www.dailymotion.com/video/x3pm1fa





Also, here is the full SOURCE CODE

C++:
#include "ScanContents.h"
#include <process.h>
std::string chosenColour;
void MainScan(ScanContents scan);
void CheckColour(COLORREF pixel, int x, int y);
bool ColourMatch(COLORREF pixel);
void ScanThread(ScanContents * scan);

int main()
{
    std::string gameWindow;
    std::cout << "Enter game window to triggerbot" << std::endl;
    //std::getline(std::cin, gameWindow);
    gameWindow = "Targex Anti-Cheat System";

    HWND appWnd = FindWindow(0, gameWindow.c_str());
    RECT rcClientPositioning;

    while(!appWnd)
    {
        system("CLS");
        appWnd = FindWindow(0, gameWindow.c_str());
        std::cout << "Looking for " << gameWindow << std::endl;
        Sleep(1000);
    }
    std::cout << "Found " << gameWindow << std::endl;

    while(atoi(chosenColour.c_str()) < 1 || atoi(chosenColour.c_str()) > 3)
    {
        system("CLS");
        std::cout << "Choose which color to trigger against\n" <<
        "1.Black\n2.Green\n3.Blue"
        << std::endl;
        std::getline(std::cin, chosenColour);
    }

    std::string color;
    if(chosenColour == "1")color = "Black";
    else if(chosenColour == "2")color = "Green";
    else if(chosenColour == "3")color = "Blue";
    system("CLS");

    std::cout << "Triggerbot ONLINE, hover over" << color << " to shoot..." << std::endl;

        GetWindowRect(appWnd, &rcClientPositioning);

    HDC hdcMain = GetDC(HWND_DESKTOP);
    HDC hdcThread1 = GetDC(HWND_DESKTOP);
    HDC hdcThread2 = GetDC(HWND_DESKTOP);
    HDC hdcThread3 = GetDC(HWND_DESKTOP);

    int startingX = rcClientPositioning.right - ((rcClientPositioning.right - rcClientPositioning.left)/2);
    int startingY = rcClientPositioning.bottom - ((rcClientPositioning.bottom - rcClientPositioning.top)/2);

    
    
    ScanContents scanContents1(startingX, startingY, hdcThread1, 0, 30, -20, 10, 1);
    ScanContents scanContents2(startingX, startingY, hdcThread1, 20, 5, 0, -20, 2);
    ScanContents scanContents3(startingX, startingY, hdcThread1, 20, 30, 0, 10, 3);
    ScanContents scan(startingX, startingY, hdcMain, 30, 40, -30, -30);
    
    
    _beginthread((void(*)(void*))ScanThread, 0, (void*)&scanContents1);
    _beginthread((void(*)(void*))ScanThread, 0, (void*)&scanContents2);
    _beginthread((void(*)(void*))ScanThread, 0, (void*)&scanContents3);
    
    
    MainScan(scan);



    system("PAUSE");
}


void ScanThread(ScanContents * scan)
{
    //int debugRuntime = clock();
    while(true)
    {
        for(int y = scan->StartY+scan->DeductY; y < scan->StartY+scan->CompareY; y+=3)

        {
            for(int x = scan->StartY+scan->DeductX; x < scan->StartX+scan->CompareX; x+=3)
            {
        //Sleep(100);
        //SetCursorPos(x, y);
            
                CheckColour(GetPixel(scan->Hdc, x, y), x, y);
                if(GetAsyncKeyState(VK_DELETE))
                {
                    exit(0);
                }
            }
        }
        //std::cout << "[THREAD " << scan->ThreadNum << "]Took " << clock() - debugRuntime << " milliseconds to scan whole area " << std::endl;
        //debugRuntime = clock();
    }


}





void MainScan(ScanContents scan)
{
    //int debugRuntime = clock();
    while(true)
    {
        for(int y = scan.StartY+scan.DeductY; y < scan.StartY+scan.CompareY; y+=3)

        {
            for(int x = scan.StartY+scan.DeductX; x < scan.StartX+scan.CompareX; x+=3)
            {
        //Sleep(100);
        //SetCursorPos(x, y);
            
                CheckColour(GetPixel(scan.Hdc, x, y), x, y);
                if(GetAsyncKeyState(VK_DELETE))
                {
                    exit(0);
                }
            }
        }
        //std::cout << "Took " << clock() - debugRuntime << " milliseconds to scan whole area " << std::endl;
        //debugRuntime = clock();
    }


}

void CheckColour(COLORREF pixel, int x, int y)
{
    if(ColourMatch(pixel))
    {
        mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);

    }
}


bool ColourMatch(COLORREF pixel)
{
    int r = GetRValue(pixel);
    int g = GetGValue(pixel);
    int b = GetBValue(pixel);
    //Black
     if(chosenColour == "1")
    {
        if(r == 0 && g == 0 && b == 0)
        {
            return true;
        }
    }
        //Green
    else if(chosenColour == "2")
    {
        if(r < 40 && g > 50 && b < 40)
        {
            return true;
        }
    }
        //Blue
    else if(chosenColour == "3")
    {
        if(r < 40 && g < 40 && b > 50)
        {
            return true;
        }
    }
    return false;

}





                         ScanContents.h


#include <Windows.h>
#include <iostream>
#include <ctime>
#include <string>



class ScanContents
{
public:
    int StartX;
    int StartY;
    int DeductX;
    int DeductY;
    int CompareX;
    int CompareY;
    int ThreadNum;
    HDC Hdc;

    ScanContents(
        int startX, int startY, HDC hdc, int compareX = 0,
        int compareY = 0, int deductX = 0, int deductY = 0, int threadNum = 0)

    {
        StartX = startX;
        StartY = startY;
        CompareX = compareX;
        CompareY = compareY;
        DeductX = deductX;
        DeductY = deductY;
        Hdc = hdc;
        ThreadNum = threadNum;


    }



};
 
Last edited by a moderator:

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,101
78,998
2,374
How do I define "hdcHere"?
GetPixel MSDN Documentation:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd144909(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/dd144871(v=vs.85).aspx
This Winapi function returns the handle to the device context of the windowHandle you pass into it
C++:
HDC GetDC(HWND hWnd);

Early in your application you do this:
C++:
HWND appWnd = FindWindow(0, gameWindow.c_str());
This returns the HWND that you can feed into GetDC above.

And also I notice earlier in your application you do this:
C++:
    HDC hdcMain = GetDC(HWND_DESKTOP);
    HDC hdcThread1 = GetDC(HWND_DESKTOP);
    HDC hdcThread2 = GetDC(HWND_DESKTOP);
    HDC hdcThread3 = GetDC(HWND_DESKTOP);
Instead of doing the whole desktop I think it might be wiser to do:
HDC hdcMain = GetDC(appWnd);
So you're only scanning the game window eh?

Anyone know, Do you need to get 4 handles or can you just get 1 handle and use it in the 4 _beginthread calls?
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
you need to use the CPP tags before i read that code dawg

edit: Cool beans. Does it destroy the first window ( chat room ) and create the next window ( game window ? ) . If so, then your original HWND wont work.

edit 2: Why do you scan in 4 threads? Just have one thread do all the scans you need, this doesnt seem very thread safe to me
 
Last edited:

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
you need to use the CPP tags before i read that code dawg

edit: Cool beans. Does it destroy the first window ( chat room ) and create the next window ( game window ? ) . If so, then your original HWND wont work.

edit 2: Why do you scan in 4 threads? Just have one thread do all the scans you need, this doesnt seem very thread safe to me
"So I just watched Fleeps tutorial of how to make a color triggerbot, I have copied the code to my liking and it is completely done."

This is probably a good portion the same as Fleep's, and knowing how Fleep did things, I'm not surprised :p
 

HelpMe

Newbie
Full Member
Jan 17, 2016
23
98
1
edit: Cool beans. Does it destroy the first window ( chat room ) and create the next window ( game window ? ) . If so, then your original HWND wont work.
Are you talking about the game window? (Targex Anti-Cheat System), because all I did was join a game. The program doesn't close out anything. And again the video is alot more descriptive.
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
I watched the video
Dont really feel like reading all the code but i skimmed it, why arent you getting the RGB value from the center of your cursor?
There's a gap in the middle that you can read fine.
 

HelpMe

Newbie
Full Member
Jan 17, 2016
23
98
1
why arent I getting the RGB value from my cursor? Theres a gap in the middle that I can read fine? what?
When I had the program start scanning for Black, as in the video, it was actually clicking the triggerbot program itself because it was black, but when I clicked the game window, it appeared to stop scanning or something and it would not click/shoot the black enemies in the game. but when I clicked the triggerbot program window, it appeared to start scanning again or something and auto clicked the black colored program. Heres a video of what it looks like when SetCursorPos isn't commented out(you can see it scanning and auto clicking the triggerbot program by itself, but not scanning the game window):
https://www.dailymotion.com/video/x3pm8qp
 

HelpMe

Newbie
Full Member
Jan 17, 2016
23
98
1
Ok, so its partially working, but it doesnt shoot at the black characters, it kinda just shoot randomly. is there a something I can add to the current code that will make it shoot so it only shoot when my cursor scans over the black?
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,101
78,998
2,374
Are you sure the black used in the game is RGB 0,0,0 ?
Also maybe a sleep inbetween mouse_event calls? Maybe it's releasing too fast for the game to detect
this seems interesting, I hope you figure it out I want to try it
 

HelpMe

Newbie
Full Member
Jan 17, 2016
23
98
1
The RBG is definitely 0, 0, 0. Also, the triggerbot is still partially working, it is now shooting automatically in game, but it doesn't matter whether I'm hovering over the black color or not.. it just shoots on its own randomly. I think I have an idea of what to do but i'm not too sure, so if someone knows what to do please share*:D (The code is still almost completely the same as above but with sleep in between the mouse.event calls). The game I am doing this on btw is "Stick Arena Dimensions", an online game. although I am using a downloadable Anti-Cheat version of the game. When/if this is finished I will totally release it :D
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
Like i said, get the pixel from underneath your cursor, not these random values im seeing, thats the only thing that matters, it doesnt matter if there's black on the screen if your cursor isn't pointed at it.
 

HelpMe

Newbie
Full Member
Jan 17, 2016
23
98
1
Like i said, get the pixel from underneath your cursor, not these random values im seeing, thats the only thing that matters, it doesnt matter if there's black on the screen if your cursor isn't pointed at it.
Sounds great, i just don't know how to do that
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
Sounds great, i just don't know how to do that
Then say that instead of basically ignoring it...

C++:
POINT point;
GetCursorPos( &point );
COLORREF PixelUnderCursor = GetPixel(hdcHere, point.x, point.y);
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
Rake;40050 said:
GetPixel MSDN Documentation:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd144909(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/dd144871(v=vs.85).aspx
This Winapi function returns the handle to the device context of the windowHandle you pass into it
C++:
HDC GetDC(HWND hWnd);

Early in your application you do this:
C++:
HWND appWnd = FindWindow(0, gameWindow.c_str());
This returns the HWND that you can feed into GetDC above.

And also I notice earlier in your application you do this:
C++:
    HDC hdcMain = GetDC(HWND_DESKTOP);
    HDC hdcThread1 = GetDC(HWND_DESKTOP);
    HDC hdcThread2 = GetDC(HWND_DESKTOP);
    HDC hdcThread3 = GetDC(HWND_DESKTOP);
Instead of doing the whole desktop I think it might be wiser to do:
HDC hdcMain = GetDC(appWnd);
So you're only scanning the game window eh?

Anyone know, Do you need to get 4 handles or can you just get 1 handle and use it in the 4 _beginthread calls?
Just one HDC is fine
 

HelpMe

Newbie
Full Member
Jan 17, 2016
23
98
1
So where do I put all this? I tried myself in the hopes I would figure it out and not have to ask more questions, but after trying and failing I have to ask for more help QQ. Where to put this stuff to put in the current code in the OP:
POINT point;
GetCursorPos( &point );
COLORREF PixelUnderCursor = GetPixel(hdcHere, point.x, point.y);






COLORREF GetPixel(
_In_ HDC hdc,
_In_ int nXPos,
_In_ int nYPos
);






HDC GetDC(
_In_ HWND hWnd
);
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,101
78,998
2,374
Where to put this stuff?
Reality check time! Stop "putting" stuff in your code and spend some time learning basic C++ so you understand how to use a function and how to use the MSDN documentation :)
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods