#include "ScanContents.h"
bool TakeScreenshot(std::string WindowsToFind, BITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot,
HBITMAP &hbitmapOld, HWND &hwnd);
void SetupBitmapInfo(BITMAPINFO &bmi, int bwidth, int bHeight, int bitsPerPixel);
bool CompareColour(RGBQUAD * pPixels, int height, int width, int x, int y);
void ScanBMP(ScanContents * scan);
bool Aim_Bot(HWND appWnd, std::string GameWindow);
bool Aim_BotThr(AimbotThr * aimthr);
MouseCoord CurrentMouseXY(0, 0);
int main()
{
std::string GameWindow = "Counter-Strike Source";
HWND appWnd = FindWindow(0, GameWindow.c_str());
while(!appWnd)
{
system("CLS");
appWnd = FindWindow(0, GameWindow.c_str());
std::cout << "Unable to find " << GameWindow.c_str() << std::endl;
Sleep(500);
}
POINT currentPos;
GetCursorPos(& currentPos);
CurrentMouseXY.X = currentPos.x;
CurrentMouseXY.Y = currentPos.y;
AimbotThr aimThr1(appWnd, GameWindow);
_beginthread((void(*)(void*))Aim_BotThr, 0, (void*)&aimThr1);
AimbotThr aimThr1(appWnd, GameWindow);
_beginthread((void(*)(void*))Aim_BotThr, 0, (void*)&aimThr1);
Aim_Bot(appWnd, GameWindow);
system("pause");
return 0;
}
bool TakeScreenshot(std::string WindowsToFind, BITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot,
HBITMAP &hbitmapOld, HWND &hwnd);
{
RECT rc;
GetWindowRect(hwnd, &rc);
hdcShot = CreateCompatibleDC(0);
hbmap = createcompatibleBitmap(GetDC(0), rc.right - rc.left, rc.bottom - rc.top);
SelectObject(hdcShot, hbmap);
BitBlt(hdcShot, 0, 0, rc.right - rc.left, rc.bottom - rc.top, GetDC(0), rc.left, rc.top, SRCCOPY);
if(!GetObject(hbmap, sizeof(BITMAP), (LPSTR)&bm))
return false;
int bitsPerPixel = bm.bmBitsPixel;
if(bitsPerPixel != 32 || bm.bmPlanes !=1)
return false;
SetupBitmapInfo(bmi, bm.bmWidth, bmHeight, bitsPerPixel);
return true;
}
bool Aim_BotThr(AimbotThr * aimthr)
{
RECT rcWindow;
GetWindowRect(aimthr->AppWnd, &rcWindow);
BITMAP bm;
HBITMAP hbmap;
HBITMAP hbmapOld;
BITMAPINFO bmi;
HDC hdcShot;
HDC hdcScreen;
RGBQUAD * pPixels;
int TimeTakenScreenAndScan;
while(true)
{
if(!GetAsyncKeyState('X'))
{
TimeTakenScreenAndScan = clock();
if(TakeScreenshot(aimthr->GameWindow, bm, hbmap, bmi, hdcShot, hbmapOld, aimthr->AppWnd))
break;
HBITMAP hbmapNew = CreateCompatibleBitmap(hdcShot, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top);
HDC hdcShotNew = CreateCompatibleDC(hdcShot);
HBITMAP OldBmp = (HBITMAP) SelectObject(hdcShotNew, hbmapNew);
BitBlt(hdcShotNew, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, hdcShot, 0, 0, SRCCOPY);
pPixels = new RGBQUAD[bm.bmWidth * bm.bmHeight];
if(!pPixels)return false;
SelectObject(hdcShotNew, OldBmp);
if(!GetDIBits(hdcShotNew, hbmapNew, 0, bm.bmHeight, pPixels, &bmi, DIB_RGB_COLORS))
{
ReleaseDC(aimthr->AppWnd, hdcShot);
delete[] pPixels;
return false;
}
ReleaseDC(aimthr->AppWnd, hdcShot);
ScanContents scanContentsMain(bm,rcWindow, pPixels);
ScanBMP(&scanContentsMain);
if(pPixels)
free(pPixels);
SelectObject(hdcShot, hbmapOld);
DeleteObject(hbmap);
DeleteDC(hdcShot);
DeleteObject(hbmapNew);
DeleteObject(OldBmp);
DeleteDC(hdcShotNew);
//std::cout << "out of scan, took" << clock() - TimeTakenScreenAndScan << "miliiseconds" << std::endl;
}
}
}
bool Aim_Bot(HWND appWnd, std::string GameWindow);
{
RECT rcWindow;
GetWindowRect(appWnd, &rcWindow);
BITMAP bm;
HBITMAP hbmap;
HBITMAP hbmapOld;
BITMAPINFO bmi;
HDC hdcShot;
HDC hdcScreen;
RGBQUAD * pPixels;
int TimeTakenScreenAndScan;
while(true)
{
if(!GetAsyncKeyState('X'))
{
TimeTakenScreenAndScan = clock();
if(TakeScreenshot(GameWindow, bm, hbmap, bmi, hdcShot, hbmapOld, appWnd))
break;
HBITMAP hbmapNew = CreateCompatibleBitmap(hdcShot, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top);
HDC hdcShotNew = CreateCompatibleDC(hdcShot);
HBITMAP OldBmp = (HBITMAP) SelectObject(hdcShotNew, hbmapNew);
BitBlt(hdcShotNew, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, hdcShot, 0, 0, SRCCOPY);
pPixels = new RGBQUAD[bm.bmWidth * bm.bmHeight];
if(!pPixels)return false;
SelectObject(hdcShotNew, OldBmp);
if(!GetDIBits(hdcShotNew, hbmapNew, 0, bm.bmHeight, pPixels, &bmi, DIB_RGB_COLORS))
{
ReleaseDC(appWnd, hdcShot);
delete[] pPixels;
return false;
}
ReleaseDC(appWnd, hdcShot);
ScanContents scanContentsMain(bm,rcWindow, pPixels);
ScanBMP(&scanContentsMain);
if(pPixels)
free(pPixels);
SelectObject(hdcShot, hbmapOld);
DeleteObject(hbmap);
DeleteDC(hdcShot);
DeleteObject(hbmapNew);
DeleteObject(OldBmp);
DeleteDC(hdcShotNew);
//std::cout << "out of scan, took" << clock() - TimeTakenScreenAndScan << "miliiseconds" << std::endl;
}
}
}
void SetupBitmapInfo(BITMAPINFO &bmi, int bwidth, int bHeight, int bitsPerPixel);
{
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = bWidth;
bmi.bmiHeader.biHeight = bHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = bitsPerPixel;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
}
void ShootBot(int x, int y)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}
void ScanBMP(ScanContents * scan)
{
for(int y = (scan->RcWindow.bottom - scan->RcWindow.top)/4;
y < ((scan->RcWindow.bottom - scan->RcWindow.top) - scan->RcWindow.bottom - scan->RcWindow.top)/3.5);
y++)
{
for(int x = (scan->RcWindow.right - scan->RcWindow.left)/4;
x < ((scan->RcWindow.right - scan->RcWindow.left) - scan->RcWindow.right - scan->RcWindow.left)/4);
x++)
{
if(CompareColour(scan->PPixels, scan->Bm.bmHeight, scan->Bm.bmWidth, x, y))
{
int z = x;
while (z <(int)((scan->RcWindow.right - scan->RcWindow.left)-(scan->RcWindow.right - scan->RcWindow.left)/4))
{
if(CompareColour(scan->PPixels, scan->Bm.bmHeight, scan->Bm.bmWidth, x, y))
{
break;
}
z++;
}
SetCursorPos(z - (z - x)/2)+scan->RcWindow.left, (y+4)+scan->RcWindow.top);
POINT currentPos;
GetCursorPos(¤tPos);
if(currentPos.x < CurrentMouseXY.Y + 4 && currentpos.x > CurrentMouseXY.X - 4)
//ShootBot(x+scan->RcWindow.left, y+scan->RcWindow.top); plus brackets remember
CurrentMouseXY.X = currentPos.x;
CurrentMouseXY.Y = currentPos.y;
return;
}
}
}
}
bool CompareColour(RGBQUAD * pPixels, int height, int width, int x, int y);
{
int p = (height-y-1)*width+x;
if((int)pPixels[p].rgbRed < 30 && (int)pPixels[p].rgbGreen < 30 && (int)pPixels[p].rgbBlue > 215)
{
return true;
}
if(GetAsyncKeyState(VK_ESCAPE))
{
exit(0);
}
return false;
}