Red faceBot For Web Browser Game

Posts 1–12 of 12 · Page 1 of 1
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:

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;
}
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

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;
}
Next thing is going to be positioning on screen and getting color from pixel where our mouse pointer is.

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;
}
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.
Quote Originally Posted by DarkHackerSociety View Post
who test this ??

please i need your feedback!
I can make video if you need compiling -> testing

here is DL link with compiled version..
Compiled version

But remember: This was tested on XP SP2, adn screen resolution was 1152x864 if your screen rez will be different you wount get this to work you have to edit few
lines in code.
"if(r == 240 && g == 240 && g == 240)"

checking g twice

Also
Code:
if(GetPixel(hdcScreen,xpos,ypos) == RGB(240, 240, 240))
{
...
}
would've been less work
Quote Originally Posted by Hell_Demon View Post
"if(r == 240 && g == 240 && g == 240)"

checking g twice

Also
Code:
if(GetPixel(hdcScreen,xpos,ypos) == RGB(240, 240, 240))
{
...
}
would've been less work
Thanks didn't notice r g g's mistake and that for shure makes code more compact & readable :]
have you noticed you can use tab to select the circle and just press spacebar?
code a tab, spacebar bot.

here is a sample I made for this game in autoit.

Code:
#include <misc.au3>

global $x = 0

while 1
	if _IsPressed(56) Then
		Send("{TAB}")
		Sleep(20)
		_go()
	EndIf
WEnd

func _go()
	While $x<100
		$x = $x+1
		Send("{TAB}")
		Sleep(100)
		Send("{SPACE}")
	WEnd
	Exit
EndFunc
Quote Originally Posted by GokuVoelKop View Post
have you noticed you can use tab to select the circle and just press spacebar?
code a tab, spacebar bot.

here is a sample I made for this game in autoit.

Code:
#include <misc.au3>

global $x = 0

while 1
	if _IsPressed(56) Then
		Send("{TAB}")
		Sleep(20)
		_go()
	EndIf
WEnd

func _go()
	While $x<100
		$x = $x+1
		Send("{TAB}")
		Sleep(100)
		Send("{SPACE}")
	WEnd
	Exit
EndFunc
haha didn't notice that this could save up some lines for shure
GetPixel() is a horrible function to use to check as many pixels as this. Good job for coding it, but you will come to notice that it has many draw backs. If you want really fast pixel searching, save a snapshot then filter through the pixels.

Good job bro.
Quote Originally Posted by 258456 View Post
GetPixel() is a horrible function to use to check as many pixels as this. Good job for coding it, but you will come to notice that it has many draw backs. If you want really fast pixel searching, save a snapshot then filter through the pixels.

Good job bro.
Thanks in advice 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
Quote Originally Posted by ket_ View Post
Thanks in advice 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
I will try to see if i still have that code. I made it like a year ago.
very nice
Hello, does anyone know what x, y axis you'd have to add for it to work on 1366x768 resolution? I've been playing around with it but don't quite understand, I can get it to click the start button but then it starts moving the mouse indefinitely not really clicking anything and the only way to get out of the program is to Ctrl+C and terminate the process (Shift+F5) in Visual Studio.
Posts 1–12 of 12 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?