loading
Picture of How to create simple bots for flash games
If you have ever played flash games, especially the free ones, they are often monotonous. Their repetitiveness is due to the fact that while making the game the author realized that the game may be too easy due to a lack of content so they add repetitive tasks.  For example if you have ever played games similar to dating sims when you are required to "sleep" to gain energy and etc.

This is as simple as writing a script to tell the computer to move the mouse to certain coordinates and click and wait and etc. and for most flash games this will be as advanced as you need it to be.
 
Remove these adsRemove these ads by Signing Up

Step 1: What we will use...

Picture of What we will use...
For this script tutorial we will be using AutoHotKey which is freeware and extremely powerful.

One thing to remember during this tutorial is THE AHK HELP FILE IS YOUR BEST FRIEND! It can pretty much tell you how to script anything you may need scripted.

Step 2: Script commands...


Here are some of the basic commands we will be using, how they are worded, and their functions.

Click x,y   --- This command tells the computer to click at the desired point designated by
                        the coordinates in the "x" and "y" spots. This command can also be used 
                        without the coordinates which will make it click wherever the mouse currently
                        is.
            Example.) Click 138,345

Sleep, xxxx   ---- This command tells the computer to wait the designated amount of time
                               before continuing to the next command. This is measured in  
                               milliseconds so 1000=1sec
              Example.) Sleep, 2500

Loop, xxx    ---- This tells the computer to repeat the script within the brackets the
                           designated amount of times before moving to the next command
                  Example.) Loop, 15
                                    {    
                                   commands
                                    }    




.

Step 3: Finding Window Coordinates...

Picture of Finding Window Coordinates...
2010-09-01_224840.png
Finding window coordinates for use with the Click and various other commands is simple using the tool that comes packaged with the software called AutoIt3 Window Spy.

How this tool works is simple...

First start it up, this will appear as a small rectangular window that will be blank at first. basically what this will do is stay on top but will not stay the current window...

Second click on the window that contains your game and hover your mouse over the spot you want the coordinates for and look in the small window.

You are looking for the line that says "In Active Window" and write down the coordinates.

Step 4: Planning your script...

This could possibly be the most tedious part of this whole endeavor..

When planning your script there are many things to consider...

1.) The first is what i call the "Common start point". This is the position your window is in when you get the coordinates and when you start the script... if this varies at all, the script will be off and may not click the positions you want it too. For browser flash games i usually make the browser full screen (F11) and then scroll all the way to the top. REMEMBER TO ALWAYS HAVE IT IN THIS POSITION!

2.) What do you want your bot to do? maybe Attack Heal and repeat? This is very important as this determines the commands used, the information needed, and the ultimate order of the script.

Step 5: Stringing it togeather...


The three basic commands I outlined in the second step can be used to create almost any script you may need for flash games or otherwise.

The next step is to string the commands together in a fashion in which the program can interpret and send the commands.

Here is a example of a script I created for a flash game...

Loop, 25                 <----- This tells the script how many times to repeat the entire script
{
   Click 473,450   <----- This tells the script to click at the position 473,450 on the screen
   Sleep, 1200                        <---- This says to wait 1.2 seconds before continuing
   Click 343,488
   Sleep, 200
   Loop, 10                  <---- This tells it to repeat the sub script in the next 4 lines 10 times
   {
      Click 673,360
      Sleep, 200
      Click 343,488
      Sleep, 200
     }
}

Step 6: Hotkeying

After making the script you will need to assign it to a hotkey so you can activate it without having to click on the icon.

It is very easy just create a shortcut of the script and right click it to select properies. find the option that says shortcut key and enter your key. by default it is ctrl+alt+the keys you choose.

Step 7: Finally...

Picture of Finally...

On a final note, Obviously i cannot go over the seemingly infinite amount of commands at your disposal because this would be one long tutorial but there is something that can.... THE HELP FILE! remember me mentioning that in the intro??? thats why. There is pretty much a command for whatever you may want it to do for you.

Everyone's script will be different depending on the needs they want covered.

There is also a neat tool included called .AHK to .EXE converter. this will do just what it says, it will make you script a executable file and let you pick your own icon and all. Very cool especially if you want to post your new script on the internet for others to download and use.

In your tutorial there are instructions for situations when you need to use your mouse in your script. What about when you need a keyboard key to be pressed ?

(by the way the tutorial is very helpfull and sorry for my english)

jf78 (author)  ΌνομαΕ1 month ago

In the help documentation within autohotkey there is a search feature. Type in key or keypress and it will give you all the information and examples you need, much clearer than I can provide.

JonathanL87 months ago

check this out. This is the guide i used to build my bot

http://code.tutsplus.com/tutorials/how-to-build-a-...

benr19 months ago

Help plz... not sure whats going wrong. essentially i copied your sample and built on it. this is the first time I have done this sort of thing so advice would be amazing. Script i have follows:

Loop, 2 <----- This tells the script how many times to repeat the entire script
{
Sleep, 5000
Click 724,397 <----- This tells the script to click at the position 473,450 on the screen
Sleep, 1200 <---- This says to wait 1.2 seconds before continuing
Click 640,876
Sleep, 1200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 634,855
Sleep, 200
Click 461,842
Sleep, 200
Click 461,842
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 1004,854
Sleep, 200
Click 826,842
Sleep, 300
Click 657,471
Sleep, 31000
Click 724,397
Sleep, 40000
Click 646,611
Sleep, 3000
Click 493,870
Sleep, 1000
Click 755,730
Sleep, 500
Click 557,725
Sleep, 50000
}

errorrr.png
jf78 (author)  benr19 months ago

From the debugger it appears as though there is an error at line 16 in your code. They line in question seems to occur before the loop counter so im not seeing it in the code sample you provided. Try to remove any header in the file and clean up any stuff outside the loop.

sdean72 years ago
m new hea .... i rili like dis site ... lots of info to my interest ... kip up da good wrk guys .... :)
GASSYPOOTS3 years ago
can i use sharpkeys?
jdavies103 years ago
Love your tutorials, this helped me make a very simple keylogger.

Im know addicted to AutoHotKey :D