Bot For Web Browser Game
Hello all mpgh members. I wanted to contribute to community with something so here it goes. I was looking for a bot tutorials and as a beginner in scene is pretty hard to start but while i was looking for it i found one where some guy was looking for help with a game where he needed help he wanted to make a bot but no solid replies were given to him so i try'd code one my self -> link to idea.
P.s If someone can help me to improve code please reply with suggestions i'm not so good so i got my own ways how to do things ! ;]
The game what we are going to BOT is -> Cursor Game
It's simple .swf game where you have to click on circles as time iss running out and you can't see your cursor.
Ok my way how i managed to pull out this bot is simple lets start with a programm core lets make console project and put this is source:
next we add our variables..
next we add function so we can open up our url link with a game and variable for a value aka score what we need to set in this game
and we will use setcursorpos(),mouse_event(), for setting our cursor to start game button and then later on click on it
Next thing is going to be positioning on screen and getting color from pixel where our mouse pointer is.
Well this works for me only thing is you need to add -> libgdi32.a to a project
And my screen resolution was 1152x864 if you got different you need to rewrite
a) xpos = rand() % 600 + 200,ypos = rand() % 450 + 250; // with your screen coords
b) SetCursorPos(500,650); // for game start button coords
Please give good critic and advice to me how can i improve my code thanks.
P.s If someone can help me to improve code please reply with suggestions i'm not so good so i got my own ways how to do things ! ;]
The game what we are going to BOT is -> Cursor Game
It's simple .swf game where you have to click on circles as time iss running out and you can't see your cursor.
Ok my way how i managed to pull out this bot is simple lets start with a programm core lets make console project and put this is source:
Code:
#include <windows.h>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
return 0;
}
next we add our variables..
Code:
#include <windows.h>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int rez = 0, rez2 = 0;
int xpos; // possition of x axis
int ypos; // possition of y axis
int r,g,b; // red green blue color variables see later on why ;)
srand(time(NULL)); // for rand
return 0;
}
and we will use setcursorpos(),mouse_event(), for setting our cursor to start game button and then later on click on it
Code:
#include <windows.h>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int rez = 0, rez2 = 0;
int xpos;
int ypos;
int r,g,b;
srand(time(NULL));
cout << "Enter result what you want to score: ";
cin >> rez2; // asks for score
ShellExecute(NULL, "open", "http://dagobah.net/flash/Cursor_Invisible.swf",
NULL, NULL, SW_SHOWNORMAL); // opens up browser with our game
Sleep(5000); // little sleep func. for flash game to load up in a case we got slow internet..
SetCursorPos(500,650); // set cursor on start button
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // click start button
Sleep(3900); // waits for game to start it's 3 seconds but i put more in case of small flash lag
return 0;
}
Code:
#include <windows.h>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int rez = 0, rez2 = 0;
int xpos;
int ypos;
int r,g,b;
srand(time(NULL));
cout << "Enter result what you want to score: ";
cin >> rez2;
ShellExecute(NULL, "open", "http://dagobah.net/flash/Cursor_Invisible.swf",
NULL, NULL, SW_SHOWNORMAL);
Sleep(5000); // little sleep func. for flash game to load up in a case we got slow internet..
SetCursorPos(500,650); // set cursor on start button
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // click start button
Sleep(3900); // waits for game to start it's 3 seconds but i put more in case of small flash lag
do // we will loop this until rez < rez2 aka our wanted game score is == with our variable...
{
xpos = rand() % 600 + 200,ypos = rand() % 450 + 250;
/* randomize X,Y positions on screen it's for black box where all the action hapenns
we don't want to click out of that area right ? + i made it a n00b way but well it works for me lol /*
SetCursorPos(xpos,ypos); // set cursor @ random position on screen
// next 6 lines are for get pixel func. and rgb code.
HDC hdcScreen = GetDC(0);
COLORREF crPixel = GetPixel(hdcScreen,xpos,ypos); // getting color from pixel from our coordinates from rand(); my explanation's rock lol
ReleaseDC(0,hdcScreen);
r = GetRValue(crPixel); // getting r code next two lines the same only g,b ! RGB FTW!
g = GetGValue(crPixel);
b = GetBValue(crPixel);
DeleteDC(hdcScreen); // i dont know how to explain this
if(r == 240 && g == 240 && g == 240) // if our target color is grey [look in game the center of circles or outter lines then we click...
{
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // mouse click event
Sleep(500); // i put sleep after click becouse sometimes flash games make's glitches and my score dont count every hit
rez++; // if we click on circle +1 to our score ;]
}
}while(rez < rez2);
return 0;
}
And my screen resolution was 1152x864 if you got different you need to rewrite
a) xpos = rand() % 600 + 200,ypos = rand() % 450 + 250; // with your screen coords
b) SetCursorPos(500,650); // for game start button coords
Please give good critic and advice to me how can i improve my code thanks.


but isn't saving a snapshot then filter through it it will be a little bit longer ? Like i use getpixel() only for that random cursor position if it's ok then click of not ok other random position and again getpixel() if it's ok then click.. ! I would like to see some kind of example of your suggestion will try to look up if i'll can't find any wait for PM