“Looking for an updated AutoHotKey script for the Farmer Against Potatoes Idle game? Look no further! Get ready to dominate the Whack-A-Potato mini game with this v2 script. Follow along for step-by-step instructions on how to use this powerful tool to boost your gameplay.”
About the Guide
https://steamcommunity.com/id/ElPix
- Upgraded to AutoHotKey v2
- Minor tweeks to script (due to lazy programming on my part)
- Added easy tweek variables at top of “script.ahk” file for quick user edits
Getting Started
AutoHotkey is a free, open-source scripting language for Windows that allows users to easily create small to complex scripts for all kinds of tasks such as: form fillers, auto-clicking, macros, etc.
This script only works on AutoHotKey V2 so please get that here:
https://www.autohotkey.com/download/
First thing about AutoHotKey Scripts
This script will only work with the game as the active window, fully visible and with the cursor free to move.
You can pause and unpause it whenever you want, so for example, you let it play the minigame, pause it, do your own thing and after 5 minutes manually unpause it to play the minigame again and repeat.
If at any point anything goes wrong, press your Pause Key or F11 to stop the script.
If the symbol on the taskbar is shows two parallel bars its paused
If it shows a Green ‘H’ its running.
You can fully shut off a script by right clicking the symbol on the the taskbar and clicking exit.
Create Helper Script
Call the file “setup.ahk”, save it to wherever you wish, ensure Empty is selected and press the “Create” Button.
Navigate to the folder, Right click “setup.ahk” file, and select edit script
Copy and Paste the following into the script file, then save and close the script file:
#Requires AutoHotkey v2.0
; Initial Setup
SendMode “Input”
; Declare ease of use variables
CoordFileLoc := A_WorkingDir “\coords.txt”
ApplicationName := “Farmer Against Potatoes Idle.exe”
MouseX := 0
MouseY := 0
; create a txt file to store the coordinates in and check if it fails for debugging
if (FileExist(CoordFileLoc))
{
try
{
FileDelete CoordFileLoc
}
catch as Err
{
MsgBox “Can’t Open ‘” CoordFileLoc “‘ .”
. “‘n’n” Type(Err) “: ” Err.Message
Exit
}
}
; Gain Focus for main game window
if not WinActive(“ahk_exe” ApplicationName)
if WinExist(“ahk_exe” ApplicationName)
WinActivate
; setup where we move the mouse in the right places and save the Positions
MsgBox “
(
Move the cursor to the Top of the black circle inside the Toilet
Top Row Far Left Toilet
Press Enter if you did it
)”,, 4096
click
sleep 50
; Store the coordinates in the txt file, repeat this a bunch of times
MouseGetPos &MouseX, &MouseY
; attempt to create the new coord file and check if falure for debugging
try
{
FileAppend MouseX “`n”, CoordFileLoc
}
catch as Err
{
MsgBox “Can’t Open ‘” CoordFileLoc “‘ .”
. “‘n’n” Type(Err) “: ” Err.Message
Exit
}
FileAppend MouseY “`n”, CoordFileLoc
MsgBox “
(
Move the cursor to the Top of the black circle inside the Toilet
Bottom Row Far Right Toilet
Press Enter if you did it
)”,, 4096
click
sleep 50
MouseGetPos &MouseX, &MouseY
FileAppend MouseX “`n”, CoordFileLoc
FileAppend MouseY “`n”, CoordFileLoc
; Pixel Finding goto point
Missedit:
MsgBox “
(
At the top of the screen, move the cursor over the white Part of the second “T” in “Press Start”
Press Enter if you did it
)”,, 4096
click
sleep 50
MouseGetPos &MouseX, &MouseY
Color := PixelGetColor(MouseX, MouseY)
if (Color != 0xFFFFFF)
{
; You done missed or bad color value, try again
Goto Missedit
}
FileAppend MouseX “`n”, CoordFileLoc
FileAppend MouseY “`n”, CoordFileLoc
MsgBox “
(
At the bottom of your screen, move the cursor over the Start Button
Press Enter if you did it
)”,, 4096
click
sleep 50
MouseGetPos &MouseX, &MouseY
FileAppend MouseX “`n”, CoordFileLoc
FileAppend MouseY “`n”, CoordFileLoc
ExitApp
Helper Script Setup + Notes
If pressing Enter doesn’t do anything, click into the messagebox and then move the cursor back into the requested position.
You can also drag the Messagebox out of the way if necessary.
Next we need to specify where the potatoes will be.
First, place your cursor on top of the black circle in the top left toilet, like you can see in the picture and press enter.
Second, would be the bottom right toilet (follow the message prompts).
*After you will need to specify the location to check if the game is ready to be played. Place your cursor on the white part of the second ‘T’ in the word “press Start”.
**Lastly you will have to move your cursor over to the start button and press Enter so it knows where the start button is.
***And that is the setup done!
*Honestly any whitespace past the ‘O’ in “Are you?” will work*
** Note that due to lazy coding, if your minigame is not on cooldown this step will activate the minigame wasting an attempt, sorry. **
*** If you resize your game window (change resolution), you will need to re-run the setup script ***
Main Script
In this folder create a new file called “script.ahk”.
Right click to edit and copy in this code, then save and exit the script file:
#Requires AutoHotkey v2.0
SendMode “Input”
; Declare helper variables
FileName := A_WorkingDir “\coords.txt”
ApplicationName := “Farmer Against Potatoes Idle.exe”
Px := 0
Py := 0
ClickDelay := 150 ; I’ve had good luck with 150 (my default) feel free to test out other speeds
NormTateTolerance := 1
GoldTateTolerance := 1
HotIfWinActive “ahk_exe” ApplicationName
Hotkey “F11”, MyPause
MyPause(ThisHotkey)
{
pause -1
}
try
{
FileObj := FileOpen(FileName, “r”)
; Set Toilet coordinates from setup file
LineX1 := FileObj.ReadLine()
LineY1 := FileObj.ReadLine()
LineX2 := FileObj.ReadLine()
LineY2 := FileObj.ReadLine()
LinePressX := FileObj.ReadLine()
LinePressY := FileObj.ReadLine()
LineStartX := FileObj.ReadLine()
LineStartY := FileObj.ReadLine()
FileObj.Close()
}
catch as Err
{
MsgBox “Can’t Open ‘” FileName “‘ .”
. “‘n’n” Type(Err) “: ” Err.Message
Exit
}
if not WinActive(“ahk_exe” ApplicationName)
if WinExist(“ahk_exe” ApplicationName)
WinActivate
; Search For Potatoes Loop
Loop
{
; Check if Main Game is active window, otherwise search start minigame when available
if not WinActive(“ahk_exe” ApplicationName)
{
if WinExist(“ahk_exe” ApplicationName)
WinActivate
}
else
{
; Check if whack-game can be started
Color := PixelGetColor(LinePressX, LinePressY)
if (Color = 0xFFFFFF)
{
MouseClick “left”, LineStartX, LineStartY
Sleep ClickDelay
}
; search for brown potatoe
if PixelSearch(&Px, &Py, LineX1, LineY1, LineX2, LineY2, 0xD1964A, NormTateTolerance)
{
MouseClick “left”, Px, Py
; sleep to prevent miss-clicking
Sleep ClickDelay
}
; searh for golden potatoe
if PixelSearch(&Px, &Py, LineX1, LineY1, LineX2, LineY2, 0xFEC51D, GoldTateTolerance)
{
MouseClick “left”, Px, Py
; sleep to prevent miss-clicking
Sleep ClickDelay
}
}
}
Pause::Pause -1
Final Setup Steps
Double click the “script.ahk”. The Script should start immediately.
If you did everything right and you aren’t on cooldown the game should now play itself.
To do other activities like open the shop, just press F11 or Pause Key to pause the script, buy whatever you want and then return to the minigame and resume by pressing the key again.
*** While the script is running you will not be able to tabout or change to other windows ***
Enjoy
Also feel free to modify the script to fit your PC, specifically the timing delay between potato clicks.
Enjoy the automated whacking!
And that wraps up our share on Farmer Against Potatoes Idle: Whack-A-Potato AutoHotKey v2 Script. If you have any additional insights or tips to contribute, don’t hesitate to drop a comment below. For a more in-depth read, you can refer to the original article here by DragoonX, who deserves all the credit. Happy gaming!