Are you prepared to generate millions of cookies?

Easily create game bots with AutoIt

Step 1 — Install AutoIt

Download the full AutoIt package from the official website: https://www.autoitscript.com/site/autoit/downloads/

AutoIt logo
The AutoIt logo

Step 2 — Learn basics in SciTE editor

First, you should now have a program ‘SciTE Script Editor’. Open it.

SciTE editor sending a positive message
SciTE editor sending a positive message
; Create a browser window and navigate to a website,
; wait 5 seconds and navigate to another
; wait 5 seconds and navigate to another
#include <IE.au3>Local $oIE = _IECreate("www.autoitscript.com")
Sleep(5000)
_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?")
Sleep(5000)
_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?showforum=9")
#include <IE.au3>Local $oIE = _IECreate("https://orteil.dashnet.org/cookieclicker/")
#include <IE.au3>Local $oIE = _IECreate("https://orteil.dashnet.org/cookieclicker/")
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
#include <IE.au3>Func gotoCookieClicker()
Local $url = "https://orteil.dashnet.org/cookieclicker/"
Local $oIE = _IECreate($url)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
EndFunc
gotoCookieClicker()

Step 3 — Learn to click on cookies

If you don’t know the game, it’s simple. You get points for clicking on the large cookie on the left, and you can purchase upgrades on the right.

Image of in game cookie
Where should I click???
; Double click at the x, y position of 0, 500.
MouseClick($MOUSE_CLICK_LEFT, 0, 500, 2)
Image of Mouse Section in the AutoIt Window Info Tool
Image of Mouse Section in AutoIt Window Info Tool
Image of Finder Tool in AutoIt Window Info Tool
Image of Finder Tool in AutoIt Window Info Tool
#include <IE.au3>Func gotoCookieClicker()
Local $url = "https://orteil.dashnet.org/cookieclicker/"
Local $oIE = _IECreate($url)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
EndFuncgotoCookieClicker()MouseClick($MOUSE_CLICK_LEFT, 275, 475)
#include <IE.au3>Func gotoCookieClicker()
Local $url = "https://orteil.dashnet.org/cookieclicker/"
Local $oIE = _IECreate($url)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
EndFuncgotoCookieClicker()MouseClick($MOUSE_CLICK_LEFT, 275, 475)
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
For $i = 1 to 10
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
EndFunc
Image of in game cookie counter
With great cookie power comes great cookie responsibility…
#include <IE.au3>Func gotoCookieClicker()
Local $url = "https://orteil.dashnet.org/cookieclicker/"
Local $oIE = _IECreate($url)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
EndFunc
gotoCookieClicker()For $i = 1 to 10
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
sleep(100)
Next
HotKeySet("{F1}", "myExit")Func myExit()
exit
EndFunc
HotKeySet("{F1}", "myExit")
#include <IE.au3>
Func gotoCookieClicker()
Local $url = "https://orteil.dashnet.org/cookieclicker/"
Local $oIE = _IECreate($url)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
EndFunc
gotoCookieClicker()While 1
For $i = 1 to 10
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
sleep(100)
Next
WEnd
Func myExit()
exit
EndFunc

Step 4 — Cookie Clicking Automaton

In order to improve the performance of the bot, we will have it spend the generated points in the in game store.

Image of in game grandmas
Grandmas bake the best cookies
HotKeySet("{F1}", "myExit")
#include <IE.au3>
Func gotoCookieClicker()
Local $url = "https://orteil.dashnet.org/cookieclicker/"
Local $oIE = _IECreate($url)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
EndFuncgotoCookieClicker()While 1
For $i = 1 to 100
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
sleep(100)
Next
spendCookies()
WEnd
Func spendCookies()
MouseClick($MOUSE_CLICK_LEFT, 1630, 515) ; Click on cheapest item in store
sleep(100)
MouseClick($MOUSE_CLICK_LEFT, 1750, 620) ; Buy Cursor
sleep(100)
MouseClick($MOUSE_CLICK_LEFT, 1750, 680) ; Buy Grandma
sleep(100)
MouseClick($MOUSE_CLICK_LEFT, 1750, 745) ; Buy Farm
sleep(100)
MouseClick($MOUSE_CLICK_LEFT, 1750, 810) ; Buy Mine
sleep(100)
MouseClick($MOUSE_CLICK_LEFT, 1750, 870) ; Buy Factory
sleep(100)
EndFunc
Func myExit()
exit
EndFunc
Who are the people buying all these cookies???
HotKeySet("{F1}", "myExit")
#include <IE.au3>
Opt("MouseClickDelay", 100) ;100 milliseconds
Func gotoCookieClicker()
Local $url = "https://orteil.dashnet.org/cookieclicker/"
Local $oIE = _IECreate($url)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($oIE, "visible")
_IELoadWait($oIE)
EndFunc
Func generateCookies()
For $i = 1 to 100
MouseClick($MOUSE_CLICK_LEFT, 275, 475)
Next
EndFunc
Func spendCookies()
MouseClick($MOUSE_CLICK_LEFT, 1630, 515) ; Click on cheapest item in store
MouseClick($MOUSE_CLICK_LEFT, 1750, 620) ; Buy Cursor
MouseClick($MOUSE_CLICK_LEFT, 1750, 680) ; Buy Grandma
MouseClick($MOUSE_CLICK_LEFT, 1750, 745) ; Buy Farm
MouseClick($MOUSE_CLICK_LEFT, 1750, 810) ; Buy Mine
MouseClick($MOUSE_CLICK_LEFT, 1750, 870) ; Buy Factory
EndFunc
Func runBot()
gotoCookieClicker()
While 1
generateCookies()
spendCookies()
WEnd
EndFunc
Func myExit()
exit
EndFunc
runBot()
  • We added two new functions, generateCookies() and runBot().
  • The bots code gets executed at that last line, runBot()
  • The Opt(“MouseClickDelay”, 100) line allowed us to get rid of many sleep calls

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store