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 Fixed
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
]
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
EndFunc
Tree'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+V
5. 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+F
7. 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 :huggles:
Send me a PM if you have issues/questions :D
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!!!
This post has been edited by BitByteBit: 09 November 2009 - 04:48 AM