hahaha :D die dinger gehen hin und wieder im arsch, ich hab vor die rote message als indikator zu verwendend um neu auszuwerfen. Das ganze ist natürlich kein problem in autoit, aber weil es mir kein mehrwert bringt wenn ich es einfach in autoit schreibe tue ich es in C++
#include"ScanContent.h"
bool TakeScreenshot(std::string WindowToFind, BITMAP &bm, HBITMAP &hbmap, BITMAPINFO &bmi, HDC &hdcShot,
HBITMAP &hbitmapOld, HWND &hwnd);
void SetupBitmapInfo(BITMAPINFO &bmi, int bWith, int bHeight, int bitsPerPixel);
bool CompareColor(RGBQUAD* pPixels, int height, int with, int x, int y);
void ScanBMP(ScanContent* scan);
bool Aim_Bot(HWND appWnd, std::string GameWindow);
MouseCoord CurrentMouseXY(0, 0);
int main() {
std::string GameWindow = "KalOnline";
HWND appWnd = FindWindow(0, GameWindow.c_str());
while (true)
{
system("CLS");
std::cout << "Unable to find " << GameWindow.c_str() << std::endl;
Sleep(500);
}
POINT currentPos;
GetCursorPos(¤tPos);
CurrentMouseXY.X = currentPos.x;
CurrentMouseXY.Y = currentPos.y;
Aim_Bot(appWnd, GameWindow);
system("pause");
return 0;
}
bool TakeScreenshot(std::string WindowToFind, BITMAP &bm, HBITMAP &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,
hdcShot, 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, bm.bmHeight, bitsPerPixel);
return true;
}
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;
}
ScanContent scanContentMain(bm, rcWindow, pPixels);
ScanBMP(&scanContentMain);
if (pPixels)
free(pPixels);
SelectObject(hdcShot, hbmapOld);
DeleteObject(hbmap);
DeleteObject(hbmapNew);
DeleteObject(OldBmp);
DeleteDC(hdcShotNew);
//std::cout << "out of scan, took " << clock() - TimeTakenScreenAndScan << "milliseconds " << std::endl;
}
}
}