BitByteBit Posted November 4, 2009 Posted November 4, 2009 (edited) I've set up a site for this program now, so for all future updates check out removedThis program doesn't rely on knowing the mouse co-ords (eg the size of your field). Instead it looks for the pixel colour and clicks it. You can teach it to harvest new crops, also you can record mouse clicks to an .ini file and play them back allowing you to buy and sell hay bales super fast.Enjoy guys, any comments will be greatly appreciated!!!I went the long way round a few times, it was the only way I knew.Enjoy.<code removed for violating the FarmVille Terms of Service> Edited February 27, 2010 by Valik Code removed.
BitByteBit Posted November 4, 2009 Author Posted November 4, 2009 (edited) Open the file FV.ini and paste this in. Sorry I forgot to mention that FV.ini should be in the root of C:\ [blueBerries] Colours=0x573734 [Pumpkins] Colours=0xF58F20 [Green Tea] Colors=0x3D651B [Coffee] Colors=0xA03118 [Raspberries] Colors=0x9B1725 [Rice] Colors=0x4A661F [Tomatoes] Colors=0xEF7B5F [unseeded Land] Colors=0x602806 [Plowable Land] Colors=0x474806 [Withered Crop] Colors=0x463715 [strawberries] Colors=0x663117 [Ghost Chilli] Colors=0x62270B [blackBerries] Colors=0x325125 [sunflower] Colors=0xD48212 [sugar Cane] Colors=0x4D1C02 Edited November 4, 2009 by BitByteBit
storme Posted November 4, 2009 Posted November 4, 2009 Looks good. I definately like your method! It's not forcing the farm to so what you want it's doing what is needed on the farm. Do you ever have any misses with the searches and it clicks on the wrong thing? 2 suggestions if I may. 1. Work out a method of automatically fullscreening the farm. So when a chore chosen it does the whole farm. 2. Set it to always on top so you don't have to alt-tab back and forth to your program and farmville. (Minimize it when you are doing something so it doesn't hide anything.) Oh one thing I just found....... I did a plow and it missed a line that had "red wheat" planted in front of it. Not a big problem but thought you should know. Well done Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
BitByteBit Posted November 4, 2009 Author Posted November 4, 2009 Thanks for taking the time to reply. No I don't have problems with it clicking the wrong thing. I've tried to be careful as to what pixel colour I program in. 1. I know how I would make it fullscreen, I would search for the plow tool colour, get the co-ords and minus a certain amount from them, thus moving the mouse a certain amount up and right, this would bring me to the fullscreen button I believe. However for some reason the functions run much slower if FV is fullscreen. I'm not sure why to be honest. Try it for yourself, make FV fullscreen and press Ctrl+Alt+P to plow, look at the speed, then press esc, it goes much faster when not fullscreened, I have no idea why, perhaps Adobe Flash Player when fullscreen is taking up more cpu cycles. 2. I'm aware of this problem, I need to change the pixel colour it searches for to one closer to the top of the top. Thank you for your input, its people like you that help improve my program. As for making it always on top, I'll think about it
KeithDawn Posted November 6, 2009 Posted November 6, 2009 This script is wonderful, I must say, but I have found a small issue with it. It seems unable to work on any fertilized crops, plus the above mentioning of spaces being blocked by other crops. Two quick questions though. 1 - Have you thought about doing an animal harvester with this code? Given they all have the pink diamond above their head, and the harvest option is always 3rd down on the list, would it be possible? (I as because I suck at coding, it's been to long for me.) 2 - Is there any way to pause the script / end it manually mid-run? I had an issue where it accidentally picked up a kitten twice, and just twitched back and forth across the screen for a minute until I closed firefox. Just wondering, but awesome script and good job!
BitByteBit Posted November 6, 2009 Author Posted November 6, 2009 This script is wonderful, I must say, but I have found a small issue with it. It seems unable to work on any fertilized crops, plus the above mentioning of spaces being blocked by other crops. Two quick questions though. 1 - Have you thought about doing an animal harvester with this code? Given they all have the pink diamond above their head, and the harvest option is always 3rd down on the list, would it be possible? (I as because I suck at coding, it's been to long for me.) 2 - Is there any way to pause the script / end it manually mid-run? I had an issue where it accidentally picked up a kitten twice, and just twitched back and forth across the screen for a minute until I closed firefox. Just wondering, but awesome script and good job! Ctrl+F1: Cancels the current action Alt+Escape: Exits the script Alt+R restarts the program expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=C:\Users\Tristan\Desktop\Animals.exe #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt("WinWaitDelay", 100) Opt("WinTitleMatchMode", 2) Opt("WinDetectHiddenText", 1) Opt("MouseCoordMode", 1) Opt("TrayIconDebug", 1) Opt("PixelCoordMode",1) HotKeySet("^{F1}", "Animals") HotKeySet("^{F2}", "Stop") Global $CoOrd[2] Global $CoOrd2[2] $Num = 0 $Searching = False ToolTip("Ctrl+F1 to start", "", "", "!", 1, 2) Sleep(2000) ToolTip("") ToolTip("Ctrl+F2 to stop","","", "!", 1, 2) Sleep(2000) ToolTip("") While 1 Sleep(10) wend Func Stop() While 1 Sleep(500) wend EndFunc Func Animals() $Searching = True while $Searching = True $CoOrd = PixelSearch(0,0,1024,768,0xD02875,20) ; 0xCF0867 0XFF409D Sorta works with shade variation of 10-20 ;$CoOrd = PixelSearch(0,0,1024,768,0xD02875,21) ;Deff working!!! ;$CoOrd3 = PixelSearch(0,0,1024,768,0XFF409D,15) ; Perhaps have several colous? if not @error then MouseClick("Left",$CoOrd[0],$CoOrd[1],1,0) ;MsgBox(0,"?","Click diamond?") $CoOrd2=MouseGetPos() $CoOrd2 [0] = $CoOrd[0] + 17 $CoOrd2 [1] = $CoOrd[1] + 47 Sleep(210) MouseClick("Left",$CoOrd2[0],$CoOrd2[1],1,0) ToolTip($Num, 0, 0, "!", 1, 2) Sleep(75) ToolTip("") $Num = $Num + 1 ;MsgBox(0,"?","Click probs??") Else MsgBox(0,"1","No animals??") $Searching = False EndIf WEnd EndFunc That is the code for animals. I've yet to build it into the main GUI cos I hate redesigning GUI's!!! That and the program is already pretty chunky!
KeithDawn Posted November 7, 2009 Posted November 7, 2009 Did I mention how much a love you and your scripts?!?! Cause I do, very much so. Thanks you for pointing out how to pause the script, just had the same issue with the kitten and it fixed things quite nicely. As for the animal script, love it, works great. Just my opinion, but if you were looking for something to cut from the main program to add in the animals, I say cut the profit calculator. I think people could survive without it. That's just my opinion though, but yeah, love your work!
storme Posted November 7, 2009 Posted November 7, 2009 Ctrl+F1: Cancels the current action Alt+Escape: Exits the script Alt+R restarts the program HotKeySet("^{F1}", "Animals") HotKeySet("^{F2}", "Stop") That is the code for animals. I've yet to build it into the main GUI cos I hate redesigning GUI's!!! That and the program is already pretty chunky! Works well except it's picking up animals that have already been clicked and clicking them again. This brings up an "Animal is busy" message. I added a 2 second delay and it's working slow but no more messages. May be you coudl tighten up the tollerence so it ignores the clicked animals but I'm not sure if this will miss some. Also it would be worth doing a check to see that what is being clicked on is "harvest/collect". The dairy menu is different and I think the "SELL" item is where the "harvest" is on animals. Wouldn't be good to sell things that you don't want to. :-) Thanks again John Morrison aka Storm-E Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
JohnOne Posted November 8, 2009 Posted November 8, 2009 I would not mind trying a automation script like this, I will get a facebook account to try it. Quick question, Do I need to know the game farmville, before trying this, or will it go from the start ? The last computer game I played was pac man. AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans.
KeithDawn Posted November 8, 2009 Posted November 8, 2009 (edited) With the dairy farms, it's the move which is third down, not sell, so no risk of selling there. I just harvest them first manually to prevent any errors.Works well except it's picking up animals that have already been clicked and clicking them again. This brings up an "Animal is busy" message. I added a 2 second delay and it's working slow but no more messages. May be you coudl tighten up the tollerence so it ignores the clicked animals but I'm not sure if this will miss some.Just wondering how to added the 2 second delay. FYI I suck at coding so I dare not try myself, but perhaps you could point me in the right direction.I would not mind trying a automation script like this, I will get a facebook account to try it.Quick question, Do I need to know the game farmville, before trying this, or will it go from the start ?The last computer game I played was pac man.Yes, you will need to know the game farmville before using this. In fact, this code would only become really useful once you get a few levels under your belt. But by that time, you'll understand the game. I like to think of it as a lite version of Harvest Moon.EDIT: Also just realized, with the animal script it may be possible to harvest cherry trees. I have a bunch and just realized when I run the script with them on the screen, it clicks on them as if they are a pink triangle. Only problem I see is it's trying to do this when they are not ready, and as such would probably create a loop within the program of just clicking on the same tree over and over. Edited November 9, 2009 by KeithDawn
BitByteBit Posted November 9, 2009 Author Posted November 9, 2009 (edited) John, Keith, thank you very much for your input so far.I will cut out the profit calculator and change it to Animals soon, I will post the new code when I do.This is the new Animals code. I haven't got round to fixing the Harvest/Move issue, maybe this week if I get time. So for now just harvest your dairy farms manually, sorry guys!This should resolve the issue of click an animal multiple times. Let me know how it works out!If you want to fiddle with the tolerance change the number 20 to a lower number here:$CoOrd = PixelSearch(0,0,1024,768,0xD02875,20)EDIT: Animal Code Fixedexpandcollapse popupOpt("WinWaitDelay", 100) Opt("WinTitleMatchMode", 2) Opt("WinDetectHiddenText", 1) Opt("MouseCoordMode", 1) Opt("TrayIconDebug", 1) Opt("PixelCoordMode",1) HotKeySet("^{F1}", "Animals") HotKeySet("^{F2}", "Stop") Global $CoOrd[2] Global $CoOrd2[2] Global $CoOrd3[2] $CoOrd3 [0] = 0 $CoOrd3 [0] = 0 $Num = 0 $Searching = False ToolTip("Ctrl+F1 to start", "", "", "!", 1, 2) Sleep(2000) ToolTip("") ToolTip("Ctrl+F2 to stop","","", "!", 1, 2) Sleep(2000) ToolTip("") While 1 Sleep(10) wend Func Stop() While 1 Sleep(500) wend EndFunc Func Animals() $Searching = True while $Searching = True $CoOrd = PixelSearch(0,0,1024,768,0xD02875,20) if not @error then IF $CoOrd[0] <> $CoOrd3[0] OR $CoOrd[1] <> $CoOrd3[1] then MouseClick("Left",$CoOrd[0],$CoOrd[1],1,0) ;MsgBox(0,"?","Click diamond?") $CoOrd2=MouseGetPos() $CoOrd3[0] = $Coord2[0] $CoOrd3[1] = $Coord2[1] $CoOrd2 [0] = $CoOrd[0] + 17 $CoOrd2 [1] = $CoOrd[1] + 47 Sleep(210) MouseClick("Left",$CoOrd2[0],$CoOrd2[1],1,0) ToolTip($Num, 0, 0, "!", 1, 2) Sleep(75) ToolTip("") $Num = $Num + 1 Else Sleep(1) EndIf Else ToolTip("Animals Done/No Animals") Sleep(1250) ToolTip("") $Searching = False EndIf WEnd EndFuncTree's is a whole other project, however it does use the same technique used for Animals and so shouldn't be hard at all.The only catch is I basically need to get a colour for each fully matured tree, a colour that only appears when they are done and not when they are growing. On top of this I have to find a colour which is viewable regardless of what(and where said item) is front of the tree, however I do not think this is a major issue.Once I have the colours; using the same method I can create a script to harvest Trees.Balls in your court guys. If you want to try to create your own script for trees with the animal code then save a copy of the animals file and:1. Open FarmVille.2. Take a print screen by pressing the PrtScn button.3. Open Paint.4. Press Ctrl+V5. Open AutoIt Window Info and click on the mouse tab (Installed with AutoIt)6. Back in paint, hover over the fully matured tree and press Ctrl+Alt+F7. In AutoIt Window Info double click "Color" , that colour code is now saved into your clipboard.8. Replace the 0xD02875 part of "$CoOrd = PixelSearch(0,0,1024,768,0xD02875) with $CoOrd = PixelSearch(0,0,1024,768,YOURCOLOURHERE)" with the colour you just got. 9. Test.10. Report back.If done correctly you will make a code to harvest one particular tree type ^__^, at which point you can call yourself a hobbyist programmer Send me a PM if you have issues/questions I don't have any the trees so I can't do this, if I get a few Tree colour codes I will happily make a script to harvest trees.. . .One more thing, I'm fully aware of the Plowing issue, in my next update it will be fixed. However for now, open the source code and find and replace(Ctrl+H):Find:$Coord2 = PixelSearch(30, 30, 1024, 768, 9731111)Replace with:$Coord2 = PixelSearch(30, 30, 1024, 768, 0x68540E)That will resolve the problem!!! Edited November 9, 2009 by BitByteBit
KeithDawn Posted November 10, 2009 Posted November 10, 2009 Thanks for the updates, things seem to be working well. I've been busy so I've not had much time to try creating the trees program, however seeing how nicely you laid out everything above I did give it a few tries. I think it's going to be harder than I thought, the few times I've tried I keep running into the same problem. Often the color of the fruit (which is what I use to tell it harvest-able tree from non-harvest-able) is either used elsewhere within the game screen or, even more annoying, within the Firefox logo. When I get some time I'll give it a few more gos and let you know what happens.
KeithDawn Posted November 20, 2009 Posted November 20, 2009 Three comments Bit: 1 - the source code you posted is out of format. I'm not sure if it's the new code or just the old code messed up. 2 - I like where you put the animals into the program, this new code removed the repeated clicking on the same animal problem. However it has introduced a new problem. About 50% of the time, after clicking animals, I get an array error and the entire program crashes. I'll post more info the next time I get it (I forgot to write it down earlier). 3 - On your website, you should add a comment section or point back to this forum in someway. That way, others can contribute their modification / comments. Also, I've had no luck with the trees. The colors are used too often within the browser I'm finding. That being said, I've found another program that utilized another pixel color identification method and am trying to test it on trees. If it works, perhaps the two could be combined.
BitByteBit Posted November 21, 2009 Author Posted November 21, 2009 1 - Old Code, will fix. 2 - Thanks I'll look into it. Try installing the version from the site, I don't think that has the same issue. 3 - I'm looking into an email function, I want to put up a testimonials page, could I get one from you. Keith, check your inbox.
Home Bunny Posted November 25, 2009 Posted November 25, 2009 Hi Bit, Love your program ! Could we do auto-harvesting after planting crops?, perhaps with adding a time table to the planted crops ... And of course then autoplowing and auto-seeding , ..., .... Keep up the good work. Jim
Jagraw Posted February 18, 2010 Posted February 18, 2010 Who wants the updated source code?Is it too late to still get the Source Code for Version 3?I'm very interested to see how you did the color recognition logic.I play farmville a lot and it saves me lots of time. Thanks.JAGRAW
BinaryCortex Posted February 21, 2010 Posted February 21, 2010 Who wants the updated source code?Me Me Me! Would it be possible to get the source code for version 3 or even the 3.1 that your working on? Also when I tried to harvest my aloe vera it tried clicking on the start where my level is located.Ian
tiggere Posted February 23, 2010 Posted February 23, 2010 Issue...when running this script and trying to save tree locations it keeps telling me that it needs to be in fullscreen...it is in fullscreen until I get the error message telling me that it needs to be in full screen...then clicking ok puts it in fullscreen and clicks the "zoom out" twice...but hovering over a tree and pressing "Alt + Space" gives me the error message again... I just planted my crops so have not been able to use anything else in the script...
NicholasMatthew Posted February 25, 2010 Posted February 25, 2010 Can I get the source code too please? Thanks alot.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now