Farmer Against Potatoes Idle

Farmer Against Potatoes Idle

92 ratings
Whack-A-Potato AutoHotKey Script
By Pix
Why use the games intended Auto Play feature when you can use an AutoHotKey Script
9
2
2
3
3
2
2
   
Award
Favorite
Favorited
Unfavorite
Installing AutoHotKey
If you don't know AutoHotKey, it's software that allows you to move your move, click and press keys automatically, analyse stuff that happens on your screen and loads more. Very nice.

This script only works on AutoHotKey V1.1 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.
It basically only works when left to do it's thing.
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, F11 will pause the script.
If the symbol on the taskbar is red its paused

if its green its running.


You can fully shut off a script by right clicking the symbol on the the taskbar and clicking exit.
Setup Script
Create a new Folder, right click and create a new file and call it "setup.ahk".
Right click and edit setup.ahk and copy this in:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ;create a txt file to store the coordinates in FileDelete, %A_WorkingDir%\coords.txt FileAppend, Coordinates for the Toilets are`n, %A_WorkingDir%\coords.txt ;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 ) click sleep, 50 ;Store the coordinates in the txt file, repeat this a bunch of times MouseGetPos, MouseX, MouseY FileAppend, %MouseX%`n, %A_WorkingDir%\coords.txt FileAppend, %MouseY%`n, %A_WorkingDir%\coords.txt MsgBox, ( Move the cursor to the Top of the black circle inside the Toilet Middle Row Second Toilet from the Left Press Enter if you did it ) click sleep, 50 MouseGetPos, MouseX, MouseY FileAppend, %MouseX%`n, %A_WorkingDir%\coords.txt FileAppend, %MouseY%`n, %A_WorkingDir%\coords.txt MsgBox, ( Move the cursor to the Top of the black circle inside the Toilet Bottom Row Middle Toilet Press Enter if you did it ) click sleep, 50 MouseGetPos, MouseX, MouseY FileAppend, %MouseX%`n, %A_WorkingDir%\coords.txt FileAppend, %MouseY%`n, %A_WorkingDir%\coords.txt MsgBox, ( Move the cursor to the Top of the black circle inside the Toilet Top Row Second Toilet from the Right Press Enter if you did it ) click sleep, 50 MouseGetPos, MouseX, MouseY FileAppend, %MouseX%`n, %A_WorkingDir%\coords.txt MsgBox, ( Move the cursor to the Top of the black circle inside the Toilet Top Row Far Right Toilet Press Enter if you did it ) click sleep, 50 MouseGetPos, MouseX, MouseY FileAppend, %MouseX%`n, %A_WorkingDir%\coords.txt Missedit: MsgBox, ( Move the Cursor over the white Part of the second "s" in "Press Start" Press Enter if you did it ) click sleep, 50 MouseGetPos, MouseX, MouseY PixelGetColor, color, MouseX, MouseY if (color != 0xFFFFFF) { goto, Missedit } FileAppend, %MouseX%`n, %A_WorkingDir%\coords.txt FileAppend, %MouseY%`n, %A_WorkingDir%\coords.txt MsgBox, ( Move the Cursor over the Start Button Press Enter if you did it ) MouseMove, 0, -200, 0, R sleep, 50 click sleep, 50 MouseMove, 0, 200, 0, R sleep, 50 MouseGetPos, MouseX, MouseY FileAppend, %MouseX%`n, %A_WorkingDir%\coords.txt FileAppend, %MouseY%`n, %A_WorkingDir%\coords.txt ExitApp ;Pause button F11:: Pause Suspend return

When you start the file 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 position it's asking for.
You can also drag the Messagebox out of the way.

Should anything break or go wrong F11 pauses the script.




First you will be asked to put your cursor on top of the black circles in the toilets, like you can see in the picture.
This will repeat 5 times, so we get all the toilet locations.
These locations will later be checked for potatoes.















After that you will be asked to put your cursor on the white part of the second s in the word "press", like in the picture.
It does this, so later on it will be able to tell when the 5 minute cooldown is over and it can restart the game.



Lastly you will have to move your cursor over the start button so it knows where the start button is.









And that is the setup done!
You only need to do this once as long as your games resolution stays the same.
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:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #IfWinActive ahk_exe Farmer Against Potatoes Idle.exe Pause Suspend ;Set Toilet coordinates from setup file FileReadLine, LineX1, %A_WorkingDir%\coords.txt, 2 FileReadLine, LineX2, %A_WorkingDir%\coords.txt, 4 FileReadLine, LineX3, %A_WorkingDir%\coords.txt, 6 FileReadLine, LineX4, %A_WorkingDir%\coords.txt, 8 FileReadLine, LineX5, %A_WorkingDir%\coords.txt, 9 FileReadLine, LineY1, %A_WorkingDir%\coords.txt, 3 FileReadLine, LineY2, %A_WorkingDir%\coords.txt, 5 FileReadLine, LineY3, %A_WorkingDir%\coords.txt, 7 FileReadLine, LinePressX, %A_WorkingDir%\coords.txt, 10 FileReadLine, LinePressY, %A_WorkingDir%\coords.txt, 11 FileReadLine, LineStartX, %A_WorkingDir%\coords.txt, 12 FileReadLine, LineStartY, %A_WorkingDir%\coords.txt, 13 coordsX := [LineX1,LineX2,LineX3,LineX4,LineX5] coordsY := [LineY1,LineY2,LineY3] ;Base Color to compare against and allowed tolerance targetColor=0xFDC118 tolerance := 100 ;split target color into rgb tr := format("{:d}","0x" . substr(targetColor,3,2)) tg := format("{:d}","0x" . substr(targetColor,5,2)) tb := format("{:d}","0x" . substr(targetColor,7,2)) ;the main Loop that runs loop { ;check if the game is the active window, if not pause if !WinActive("ahk_exe Farmer Against Potatoes Idle.exe") { Pause Suspend } ;Check if whack-game can be started PixelGetColor, color, LinePressX, LinePressY if (color = 0xFFFFFF) { MouseClick, left, LineStartX, LineStartY } ;outer loop to set Y coordinates loopcount := 1 loop 3 { ;inner loop to set X coordinates loop 5 { ;check pixel color at a toilet PixelGetColor, color, coordsX[a_index], coordsY[loopcount], Alt RGB ;split pixel color into rgb pr := format("{:d}","0x" . substr(color,3,2)) pg := format("{:d}","0x" . substr(color,5,2)) pb := format("{:d}","0x" . substr(color,7,2)) ;check distance between pixel and target color to get the tolerance distance := sqrt((tr-pr)**2+(tg-pg)**2+(pb-tb)**2) if(distance<tolerance) { ;Click the toilet if the tolerance is right MouseClick, left, coordsX[a_index], coordsY[loopcount] sleep, 10 } } loopcount++ } } ;Pause button F11:: Pause Suspend return

The Script will start paused.
Open the Whack-A-Potato minigame and press F11 to start it.

If you did everything right and you aren't on cooldown the game should now play itself.
To open the shop just press F11 to pause, buy whatever you want and then resume by pressing F11 once more.


If you tab out the script will pause automatically, you will have to manually unpause it by pressing F11.
Alternative Main Script - Results Vary
This is an alternative version which you can run instead of the main script above.

This script uses a diffrent method for finding where the potatoes are, but also requires the setup.
The method used here is called PixelSearch, where it will scan an area to find a color. This makes it a bit more unreliable and it will sometimes detect a wrong pixel and misslick. So I recommend having the Comboshield for this script.

Why do results vary:
This method uses more CPU resources than the normal script. Also depending on the resolution of your monitor it will have to scan diffrent amounts of pixels, therefore bigger resolution means it runs a lot slower.
Depending on your PC specifications this version can run faster or slower than the normal script, so I guess just try it out.


In the same folder create a file called "altscript.ahk".
Right click to edit and copy this code in.

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #IfWinActive ahk_exe Farmer Against Potatoes Idle.exe Pause Suspend ;Set Toilet coordinates from setup file FileReadLine, LineX1, %A_WorkingDir%\coords.txt, 2 FileReadLine, LineX5, %A_WorkingDir%\coords.txt, 9 FileReadLine, LineY1, %A_WorkingDir%\coords.txt, 3 FileReadLine, LineY3, %A_WorkingDir%\coords.txt, 7 FileReadLine, LinePressX, %A_WorkingDir%\coords.txt, 10 FileReadLine, LinePressY, %A_WorkingDir%\coords.txt, 11 FileReadLine, LineStartX, %A_WorkingDir%\coords.txt, 12 FileReadLine, LineStartY, %A_WorkingDir%\coords.txt, 13 ;the main Loop that runs loop { ;check if the game is the active window, if not pause if !WinActive("ahk_exe Farmer Against Potatoes Idle.exe") { Pause Suspend } ;Check if whack-game can be started PixelGetColor, color, LinePressX, LinePressY if (color = 0xFFFFFF) { MouseClick, left, LineStartX, LineStartY } ;search for brown potatoe PixelSearch, Px, Py, LineX1, LineY1, LineX5, LineY3, 0x4A96D1, 1, Fast if (!Errorlevel) { MouseClick, left, Px, Py ;sleep to prevent wrong clicking sleep, 100 } ;searh for golden potatoe PixelSearch, Px, Py, LineX1, LineY1, LineX5, LineY3, 0x08B6FA, 2, Fast if (!Errorlevel) { MouseClick, left, Px, Py ;sleep to prevent wrong clicking sleep, 100 } } F11:: Pause Suspend return

The Script will start paused.
Open the Whack-A-Potato minigame and press F11 to start it.

If you did everything right and you aren't on cooldown the game should now play itself.
To open the shop just press F11 to pause, buy whatever you want and then resume by pressing F11 once more.


If you tab out the script will pause automatically, you will have to manually unpause it by pressing F11.
Enjoy
Thats it, you are all setup, if you have questions about the code or something isn't working or maybe you even have improvements, feel free to comment.

Enjoy the automated whacking.
74 Comments
ExhaustedDog Mar 27 @ 3:47pm 
Nice directions, easy to follow; great little script.
Kinasin Feb 24 @ 5:46pm 
doesn't work
AlconburyBlues Dec 26, 2024 @ 4:01pm 
Also, strange thing happened after using it once and hitting F11 to pause it until the next run. The script quit and deleted itself. It wasn't my antivirus, because there was nothing in the quarantine. I even disabled the AV before running it, and it deleted itself again. Even marked the .ahk file as read-only and it deleted it a 3rd time! Very weird.

When the script is running it runs great. I just don't understand what is deleting the file after it's use, even when marked as read-only. That just baffles me.
AlconburyBlues Dec 26, 2024 @ 3:58pm 
Just an FYI, it doesn't work with AutoHotkey v2. You have to go to other versions and download the latest v1.1.
Shenoital Oct 3, 2024 @ 10:35am 
Doesnt work for me, the normal script just spam clic my windows start menu and the alt script dont do anything, tried multiple times, dont know how to make it work, I tried entering the coords manualy but it doesnt seem to help
Okimo Sep 14, 2024 @ 2:32pm 
For me personally the Alternative script works much better :) (Windowed - 1920x1080 screen)
Fastor Sep 14, 2024 @ 4:51am 
Thanks!
warrior3d Sep 9, 2024 @ 5:33pm 
God bless u!!!
rofl Apr 25, 2024 @ 11:02am 
ty for this guide!
Black Testicle Gamer Feb 26, 2024 @ 6:56pm 
very good job bro!