OldSchoolHack

Registrieren / Anmelden Deutsch

Jamlegend bot: Brauche Hilfe


icon Jamlegend bot: Brauche Hilfe #1

Anmeldungsdatum: Aug 2009

Beiträge: 62

Will einen Jamlegend.com bot machen Source habe ich bloß was muss ich jetzt machen?  wie setzt mann den zusammen? könnte das einer bitte machen?  oder gibt es bessere bots für jamlegend?? hier mal die source hoffe mir hilft einer:


// JamBot is a bot especially for http://www.jamlegend.com
// it uses simple color detection for actions

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <utility>

#define VK_1 0x31
#define VK_2 0x32
#define VK_3 0x33
#define VK_4 0x34
#define VK_5 0x35

struct Vector2D
{
   Vector2D() {}
   Vector2D(float x, float y)
   {
       this->x = x;
       this->y = y;
   }
   float x, y;
};

struct Vector3D
{
   Vector3D() {}
   Vector3D(float x, float y, float z)
   {
       this->x = x;
       this->y = y;
       this->z = z;
   }
   float x, y, z;
};

struct Button
{
   Button(COLORREF c, COLORREF hc, Vector2D p, Vector2D hp, int k)
   {
       color = c;
       holdColor = hc;
       pos = p;
       holdPos = hp;
       locktime = 0;
       down = false;
       key = k;
   }

   COLORREF color;
   COLORREF holdColor;

   Vector2D pos;
   Vector2D holdPos;
   unsigned long locktime;
   bool down;
   int key;
};

class Window
{
public:
   Window()
   {
       hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
       hWnd = FindWindow("OperaWindowClass", NULL);
       Init();
       Run();
   }

   ~Window()
   {
       DeleteDC(hDC);
   }
private:
   COLORREF GetColor(Vector2D pos, int rows , int cols)
   {
       Vector3D rgb;
       int counter = 0;

       if (rows == 0 || cols == 0)
       {
           return GetPixel(hDC, (int)pos.x, (int)pos.y);
       }

       // row oder col == 1 -> -1, 0, 1, == 2 -> -2, -1, 0, 1, 2
       for (int y = -cols; y <= cols; y++)
       {
           for (int x = -rows; x <= rows; x++)
           {
               COLORREF color = GetPixel(hDC, (int)pos.x + x, (int)pos.y + y);

               rgb.x += GetRValue(color);
               rgb.y += GetGValue(color);
               rgb.z += GetBValue(color);

               counter++;
           }
       }

       rgb.x /= counter;
       rgb.y /= counter;
       rgb.z /= counter;
       
       return RGB(rgb.x, rgb.y, rgb.z);
   }

   void Init()
   {
       buttons.push_back(Button(RGB(255, 236, 136), RGB(255, 247, 51),  Vector2D(549, 480), Vector2D(552, 465), VK_1)); // gelb
       buttons.push_back(Button(RGB(236, 148, 255), RGB(246, 96, 254),  Vector2D(589, 480), Vector2D(592, 465), VK_2)); // lila
       buttons.push_back(Button(RGB(198, 255, 130), RGB(201, 255, 50),  Vector2D(629, 480), Vector2D(632, 465), VK_3)); // grün
       buttons.push_back(Button(RGB(255, 146, 134), RGB(255, 97, 100),  Vector2D(669, 480), Vector2D(672, 465), VK_4)); // rot
       buttons.push_back(Button(RGB(151, 211, 247), RGB(146, 246, 255), Vector2D(711, 480), Vector2D(712, 465), VK_5)); // blau
   }

   bool IsColorSimilar(COLORREF c1, COLORREF c2, int maxDistance)
   {
       byte r1 = GetRValue(c1);
       byte r2 = GetRValue(c2);

       byte g1 = GetGValue(c1);
       byte g2 = GetGValue(c2);

       byte b1 = GetBValue(c1);
       byte b2 = GetBValue(c2);

       // größer dem kleineren und kleiner dem größeren
       if (r1 <= Clamp(r2 + maxDistance, 0, 255) &&
           r1 >= Clamp(r2 - maxDistance, 0, 255) &&

           g1 <= Clamp(g2 + maxDistance, 0, 255) &&
           g1 >= Clamp(g2 - maxDistance, 0, 255) &&

           b1 <= Clamp(b2 + maxDistance, 0, 255) &&
           b1 >= Clamp(b2 - maxDistance, 0, 255))
       {
           return true;
       }
       return false;
   }

   bool HasToHold(Button &b)
   {
       COLORREF lineColor = GetColor(b.holdPos, 0, 0);

       if (IsColorSimilar(lineColor, b.holdColor, 60))
       {
           return true;
       }

       return false;
   }

   void Run()
   {
       // better sleep
       timeBeginPeriod(1);

       while (true)
       {
           for(size_t i = 0; i < buttons.size(); i++)
           {
               Button &b = buttons;

               COLORREF targetColor = GetColor(b.pos, 2, 1);

               bool isSimilar = IsColorSimilar(targetColor, b.color, 30);

               if (isSimilar && !b.down/* && (b.locktime + 90) < timeGetTime() */)
               {
                   keybd_event(b.key, 0, 0, 0);
                   // press enter at the same time
                   //keybd_event(0xD, 0, 0, 0);
                   b.down = true;
                   b.locktime = timeGetTime();
               }
               else if(!isSimilar && b.down && /*(b.locktime + 50) < timeGetTime() && */!HasToHold(b))
               {
                   //keybd_event(0xD, 0, KEYEVENTF_KEYUP, 0);
                   keybd_event(b.key, 0, KEYEVENTF_KEYUP, 0);                    
                   b.down = false;
               }
           }

           Sleep(10);
       }
   }

   int Clamp(int val, int min, int max)
   {
       return max(min, min(val, max));
   }

   HDC hDC;
   HWND hWnd;
   std::vector<Button> buttons;
};


int _tmain(int argc, _TCHAR* argv[])
{
   Window wnd;
   return 0;
}


__________________

F1 - the first a
nd only