Farmer Against Potatoes Idle: hack-A-Potato AutoHotKey v2 Script 2024

Are you looking to streamline your potato-whacking experience in ‘Farmer Against Potatoes Idle’? Look no further! This comprehensive guide will walk you through setting up DragoonX‘s Whack-A-Potato AutoHotKey v2 Script, enhancing your gameplay with minimal effort.

 

Introduction to the Guide

This guide is an updated version of the original work by Pix, offering a refined approach to automating the potato-whacking minigame. With the AutoHotKey v2 upgrade and easy-to-use tweak variables, you’re in for a treat.

 

Getting Started with AutoHotKey

Before diving into the script, ensure you have AutoHotKey installed on your Windows system. AutoHotKey is a versatile, open-source scripting language that simplifies the creation of scripts for tasks like auto-clicking and macros.

If at any point anything goes wrong, press your Pause Key or F11 to stop the script.
If the symbol on the taskbar shows two parallel bars it paused
If it shows a Green ‘H’ it’s running.

 

Create Helper Script

On the AutoHotkey Dash Application, click “New 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

Double-click the script to start it. Once open, a messagebox will pop up telling you where to put your cursor and then press enter. This is done so the script knows where the toilets are, because on different resolutions they may be in different locations.

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 the same folder where the “setup.ahk” file is you will now also see a coords.txt, this is where the positions from the setup are saved.

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

Open the Whack-A-Potato minigame.
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 ***

Leave a Comment