Ok heres my tree/chicken harvester
Works well for me, doesn't use any pixel checks since they caused issues. Just make sure to stop it when its done with a row
Don't know why input boxes dont truly work, I've tried messing with the variables(which is why theres a function that defines the default values instead of just defining them properly before) But I can't seem to get it working, so the tweak area isnt working.
;*** Tree \ Chicken Farmer
; v2009-09-10 - Gui Work Redone, Added Ability to reverse script, Has some bloat but works
; v2009-09-13 - Added Ability to pause/restart script with space bar.
;TODO
; -Complete Pause feature, currently if you pause, then press a
; direction button the script wont work/unpause untill you hit space
; -Fix gui elements for tweaking offsets
; -Add ability to change hotkeys?
; -Add check to see if off page?
; -Help text
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$harvest = 140
$delay = 2
$script_running = 0
$pause = 0
$offset1x = 0
$offset1y = 0
$offset2x = 0
$offset2y = 0
$direction = 0
HotKeySet ("z", "RunIt")
HotKeySet ("x", "ReverseIT")
HotKeySet ("{esc}", "exitScript")
HotKeySet ("{space}", "pauseScript")
func defaultvalues()
$offset1x = 15
$offset1y = 53
$offset2x = 4
$offset2y = 2
EndFunc
defaultvalues()
$window_main = GUICreate("Farmville Tree \ Animal Harvester",160, 153) ; defines default window size
$graphic_background = GUICtrlCreateGraphic(0, 0, 300, 300)
GUICtrlSetState($graphic_background, $GUI_DISABLE)
GUICtrlCreateGroup("Tweak", 7, 3, 145, 120) ; defines offset, Tweak these if you constantly miss trees/chickens
GUICtrlCreateLabel("Offset 1 X:", 15, 19)
GUICtrlCreateLabel("Offset 1 Y:", 15, 39)
GUICtrlCreateLabel("Offset 2 X:", 15, 59)
GUICtrlCreateLabel("Offset 2 Y:", 15, 79)
GUICtrlCreateLabel("Change in small increments", 15, 100)
$offset1xu = GUICtrlCreateInput($offset1x, 70, 15, 70, 20, $ES_CENTER)
$updown_speedx1 = GUICtrlCreateUpdown($offset1xu)
$offset1yu = GUICtrlCreateInput($offset1y, 70, 35, 70, 20, $ES_CENTER)
$updown_speedy1 = GUICtrlCreateUpdown($offset1yu)
$offset2xu = GUICtrlCreateInput($offset2x, 70, 55, 70, 20, $ES_CENTER)
$updown_speedx2 = GUICtrlCreateUpdown($offset2xu)
$offset2yu = GUICtrlCreateInput($offset2y, 70, 75, 70, 20, $ES_CENTER)
$updown_speedy2 = GUICtrlCreateUpdown($offset2yu)
$helpbutton = GUICtrlCreateButton("Help", 40, 125, 75, 25)
$window_help = GUICreate("Help", 260, 65, -1, -1, -1, 0, $window_main)
GUICtrlCreateLabel("Z = Harvest from right bottom to top left", 10, 5)
GUICtrlCreateLabel("X = Harvest from left bottom to top right", 10, 25)
GUICtrlCreateLabel("Space = Pause the script", 10, 45)
GUISetState(@SW_SHOW, $window_main)
While 1
If $script_running Then
$script_amount = GUICtrlRead($input_amount)
EndIf
$gui_msg = GUIGetMsg(1)
Select
Case $gui_msg[0] = $GUI_EVENT_CLOSE
If $gui_msg[1] = $window_main Then
ExitLoop
ElseIf $gui_msg[1] = $window_help Then
GUISetState(@SW_HIDE, $window_help)
EndIf
Case $gui_msg[0] = $helpbutton
GUISetState(@SW_SHOW, $window_help)
Case $gui_msg[0] = $GUI_EVENT_CLOSE
If $gui_msg[1] = $window_main Then
ExitLoop
EndIf
Case $gui_msg[0] = $helpbutton
GUISetState(@SW_SHOW, $window_help)
EndSelect
Sleep(15)
WEnd
Func pauseScript()
if $pause = 1 then
$pause = 0
$harvest = 140
Harvest()
else
$pause = 1
$harvest = 0
endif
EndFunc
Func exitScript()
Exit
EndFunc
Func RunIt()
$direction = 0
;$pause = 0
Harvest()
EndFunc
Func ReverseIt()
$direction = 1
;$pause = 0
Harvest()
EndFunc
Func Harvest()
$i = 0
$startPos = MouseGetPos()
if $pause = 1 Then
$harvest = 0
endif
While $i < $harvest
$i = $i + 1
$startPos = MouseGetPos()
$pos = MouseGetPos()
MouseClick("left")
if $direction = 0 Then
MouseClick("left",$pos[0]+$offset1x, $pos[1]+$offset1y, 1, 2)
Mousemove($startPos[0],$startPos[1], 1)
MouseMove($pos[0]-$offset2x,$pos[1]-$offset2y, 1)
Elseif $direction = 1 Then
MouseClick("left",$pos[0]+$offset1x, $pos[1]+$offset1y, 1, 2)
Mousemove($startPos[0],$startPos[1], 1)
MouseMove($pos[0]+$offset2x,$pos[1]-$offset2y, 1)
endif
wend
EndFunc