Eliran, on 31 August 2009 - 11:35 PM, said:
download autoit and compile it
Posted 01 September 2009 - 06:22 PM
Jackalo, on 30 August 2009 - 06:07 PM, said:
;*** Farmville Bot ; v2009-07-30 - Now has a GUI, a target button, and optional avoidance of spawning square. ; v2009-07-31 - Added a Mouse Speed variable, made the GUI look better ; v2009-08-23 - Reworked the entire script to use hotkeys and a variable harvest area ; v2009-08-24 - Finished the rewrite, cleaned and compacted the code, added Help button ; Just some things to remember... ; When zoomed all the way out, the below are true... ; Moving across columns, x+25, y-12 ; Moving down rows, x+25, y+12 ;*** Design Goals ; 1. Create a better looking interface ; Includes #include <GUIConstantsEx.au3> #include <EditConstants.au3> ; Define a few (global) variables $script_x = 0 $script_y = 0 $script_speed = 25 $script_size_columns = 4 $script_size_rows = 4 $script_running = 0 ; Hotkeys HotKeySet("{HOME}", "set_position") HotKeySet("{INSERT}", "start_script") HotKeySet("{DELETE}", "stop_script") ; Hotkey Functions Func set_position() $script_x = MouseGetPos(0) $script_y = MouseGetPos(1) GUICtrlSetData($label_coordinate_x, $script_x) GUICtrlSetData($label_coordinate_y, $script_y) EndFunc Func start_script() GUICtrlSetColor($graphic_background, "0x33FF33") ;~ GUICtrlSetBkColor($button_help, "0x33FF33") $script_running = 1 EndFunc Func stop_script() GUICtrlSetColor($graphic_background, "0xF0F0F0") ;~ GUICtrlSetBkColor($button_help, "0xF0F0F0") $script_running = 0 EndFunc $window_main = GUICreate("Farmville Bot", 200, 165) $graphic_background = GUICtrlCreateGraphic(0, 0, 200, 165) GUICtrlSetState($graphic_background, $GUI_DISABLE) GUICtrlCreateGroup("Coordinates", 5, 5, 75, 60) GUICtrlCreateLabel("X:", 20, 25, 50) GUICtrlCreateLabel("Y:", 20, 40, 50) $label_coordinate_x = GUICtrlCreateLabel($script_x, 40, 25, 30) $label_coordinate_y = GUICtrlCreateLabel($script_y, 40, 40, 30) $button_help = GUICtrlCreateButton("Help", 15, 95, 75, 45) GUICtrlCreateGroup("Size", 90, 5, 105, 61) GUICtrlCreateLabel("Columns:", 98, 20) $input_size_columns = GUICtrlCreateInput($script_size_columns, 145, 18, 40, 20) $updown_size_columns = GUICtrlCreateUpdown($input_size_columns) GUICtrlSetLimit($updown_size_columns, 20, 1) GUICtrlCreateLabel("Rows:", 98, 42) $input_size_rows = GUICtrlCreateInput($script_size_rows, 145, 40, 40, 20) $updown_size_rows = GUICtrlCreateUpdown($input_size_rows) GUICtrlSetLimit($updown_size_rows, 20, 1) GUICtrlCreateGroup("Mouse Speed", 110, 75, 85, 85) $input_speed = GUICtrlCreateInput($script_speed, 125, 95, 50, 20, $ES_CENTER) $updown_speed = GUICtrlCreateUpdown($input_speed) GUICtrlSetLimit($updown_speed, 50, 1) $button_speed_1 = GUICtrlCreateButton("1", 115, 120, 25, 15) $button_speed_5 = GUICtrlCreateButton("5", 140, 120, 25, 15) $button_speed_10 = GUICtrlCreateButton("10", 165, 120, 25, 15) $button_speed_15 = GUICtrlCreateButton("15", 115, 140, 25, 15) $button_speed_25 = GUICtrlCreateButton("25", 140, 140, 25, 15) $button_speed_50 = GUICtrlCreateButton("50", 165, 140, 25, 15) $window_help = GUICreate("Help", 170, 65, -1, -1, -1, 0, $window_main) GUICtrlCreateLabel("Home = Set starting coordinates", 10, 5) GUICtrlCreateLabel("Insert = Start the script", 10, 25) GUICtrlCreateLabel("Delete = Stop the script", 10, 45) GUISetState(@SW_SHOW, $window_main) While 1 If $script_running Then ; Seriously, why is this even necessary...? $script_size_columns = GUICtrlRead($input_size_columns) $script_size_rows = GUICtrlRead($input_size_rows) farm() EndIf $script_speed = GUICtrlRead($input_speed) $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] = $button_help GUISetState(@SW_SHOW, $window_help) Case $gui_msg[0] = $button_speed_1 GUICtrlSetData($input_speed, "1") Case $gui_msg[0] = $button_speed_5 GUICtrlSetData($input_speed, "5") Case $gui_msg[0] = $button_speed_10 GUICtrlSetData($input_speed, "10") Case $gui_msg[0] = $button_speed_15 GUICtrlSetData($input_speed, "15") Case $gui_msg[0] = $button_speed_25 GUICtrlSetData($input_speed, "25") Case $gui_msg[0] = $button_speed_50 GUICtrlSetData($input_speed, "50") EndSelect Sleep(25) WEnd Func farm() ; Some (local) variables $current_x = $script_x $current_y = $script_y For $current_row = 1 To $script_size_rows Step 1 For $current_column = 1 To $script_size_columns Step 1 MouseClick("primary", $current_x, $current_y, 1, $script_speed) $current_x = $current_x + 25 $current_y = $current_y - 12 If Not $script_running Then ExitLoop Next ; Reset to beginning of row $current_x = $current_x - (25 * $script_size_columns) $current_y = $current_y - (-12 * $script_size_columns) ; Advance to the next row $current_x = $current_x + 25 $current_y = $current_y + 12 If Not $script_running Then ExitLoop Next ; Stop running now stop_script() EndFunc
For $current_column = 1 To $script_size_columns Step 1 MouseClick("primary", $current_x, $current_y, 1, $script_speed) $current_x = $current_x + 25 $current_y = $current_y - 12 If $current_row = $script_size_rows/2 Then If $current_column = (($script_size_clumns/2)+1) Then $current_x = $current_x + 25 $current_y = $current_y - 12 EndIf EndIf If Not $script_running Then ExitLoop Next
This post has been edited by linder: 01 September 2009 - 06:35 PM
Posted 01 September 2009 - 11:59 PM
Valik, on 01 September 2009 - 11:31 PM, said:
This post has been edited by linder: 02 September 2009 - 12:03 AM
Posted 02 September 2009 - 01:07 AM
; This script require a 20x20 farm and a 1280 x 800 resolutin ; Includes #include <GUIConstantsEx.au3> #include <EditConstants.au3> ; Define a few (global) variables $script_speed = 30 $script_amount = 4 $script_running = 0 ; Hotkeys HotKeySet("{INSERT}", "start_script") HotKeySet("{DELETE}", "stop_script") ; Hotkey Functions Func start_script() GUICtrlSetColor($graphic_background, "0x33FF33") ;~ GUICtrlSetBkColor($button_help, "0x33FF33") $script_running = 1 EndFunc Func stop_script() GUICtrlSetColor($graphic_background, "0xF0F0F0") ;~ GUICtrlSetBkColor($button_help, "0xF0F0F0") $script_running = 0 EndFunc $window_main = GUICreate("Beanbot", 100, 145) $graphic_background = GUICtrlCreateGraphic(0, 0, 200, 165) GUICtrlSetState($graphic_background, $GUI_DISABLE) GUICtrlCreateGroup("Amount", 10, 5, 85, 40) $input_amount = GUICtrlCreateInput($script_amount, 12, 18, 80, 20, $ES_CENTER) $updown_amount = GUICtrlCreateUpdown($input_amount) GUICtrlSetLimit($updown_amount, 20, 1) GUICtrlCreateGroup("Mouse Speed", 10, 50, 85, 40) $input_speed = GUICtrlCreateInput($script_speed, 12, 63, 80, 20, $ES_CENTER) $updown_speed = GUICtrlCreateUpdown($input_speed) GUICtrlSetLimit($updown_speed, 50, 1) GUICtrlCreateLabel("Insert = Start", 10, 100) GUICtrlCreateLabel("Delete = Stop", 10, 120) GUISetState(@SW_SHOW, $window_main) While 1 If $script_running Then $script_amount = GUICtrlRead($input_amount) farm() EndIf $script_speed = GUICtrlRead($input_speed) $gui_msg = GUIGetMsg(1) Select Case $gui_msg[0] = $GUI_EVENT_CLOSE If $gui_msg[1] = $window_main Then ExitLoop EndIf EndSelect Sleep(25) WEnd Func farm() For $current_amount = 1 To $script_amount Step 1 MouseClick("primary", 948, 707, 1, $script_speed) ;plow1 MouseClick("primary", 945, 648, 1, $script_speed) ;plow2 MouseClick("primary", 1112, 414, 1, $script_speed) ;last square MouseClick("primary", 940, 768, 1, $script_speed) ;market MouseClick("primary", 498, 596, 1, $script_speed) ;soybeans MouseClick("primary", 1112, 414, 1, $script_speed) ;last square MouseClick("primary", 997, 707, 1, $script_speed) ;delete MouseClick("primary", 1112, 414, 1, $script_speed) ;last square If Not $script_running Then ExitLoop ;this is before delete accept just for safety MouseClick("primary", 569, 493, 1, $script_speed) ;delete accept Next ; Stop running now stop_script() EndFunc
;*** Farmville Bot ; v2009-07-30 - Now has a GUI, a target button, and optional avoidance of spawning square. ; v2009-07-31 - Added a Mouse Speed variable, made the GUI look better ; v2009-08-23 - Reworked the entire script to use hotkeys and a variable harvest area ; v2009-08-24 - Finished the rewrite, cleaned and compacted the code, added Help button ; Just some things to remember... ; When zoomed all the way out, the below are true... ; Moving across columns, x+25, y-12 ; Moving down rows, x+25, y+12 ;*** Design Goals ; 1. Create a better looking interface ; Includes #include <GUIConstantsEx.au3> #include <EditConstants.au3> ; Define a few (global) variables $script_x = 0 $script_y = 0 $script_speed = 25 $script_size_columns = 4 $script_size_rows = 4 $script_running = 0 ; Hotkeys HotKeySet("{HOME}", "set_position") HotKeySet("{INSERT}", "start_script") HotKeySet("{DELETE}", "stop_script") ; Hotkey Functions Func set_position() $script_x = MouseGetPos(0) $script_y = MouseGetPos(1) GUICtrlSetData($label_coordinate_x, $script_x) GUICtrlSetData($label_coordinate_y, $script_y) EndFunc Func start_script() GUICtrlSetColor($graphic_background, "0x33FF33") ;~ GUICtrlSetBkColor($button_help, "0x33FF33") $script_running = 1 EndFunc Func stop_script() GUICtrlSetColor($graphic_background, "0xF0F0F0") ;~ GUICtrlSetBkColor($button_help, "0xF0F0F0") $script_running = 0 EndFunc $window_main = GUICreate("Farmville Bot", 200, 165) $graphic_background = GUICtrlCreateGraphic(0, 0, 200, 165) GUICtrlSetState($graphic_background, $GUI_DISABLE) GUICtrlCreateGroup("Coordinates", 5, 5, 75, 60) GUICtrlCreateLabel("X:", 20, 25, 50) GUICtrlCreateLabel("Y:", 20, 40, 50) $label_coordinate_x = GUICtrlCreateLabel($script_x, 40, 25, 30) $label_coordinate_y = GUICtrlCreateLabel($script_y, 40, 40, 30) $button_help = GUICtrlCreateButton("Help", 15, 95, 75, 45) GUICtrlCreateGroup("Size", 90, 5, 105, 61) GUICtrlCreateLabel("Columns:", 98, 20) $input_size_columns = GUICtrlCreateInput($script_size_columns, 145, 18, 40, 20) $updown_size_columns = GUICtrlCreateUpdown($input_size_columns) GUICtrlSetLimit($updown_size_columns, 20, 1) GUICtrlCreateLabel("Rows:", 98, 42) $input_size_rows = GUICtrlCreateInput($script_size_rows, 145, 40, 40, 20) $updown_size_rows = GUICtrlCreateUpdown($input_size_rows) GUICtrlSetLimit($updown_size_rows, 20, 1) GUICtrlCreateGroup("Mouse Speed", 110, 75, 85, 85) $input_speed = GUICtrlCreateInput($script_speed, 125, 95, 50, 20, $ES_CENTER) $updown_speed = GUICtrlCreateUpdown($input_speed) GUICtrlSetLimit($updown_speed, 50, 1) $button_speed_1 = GUICtrlCreateButton("1", 115, 120, 25, 15) $button_speed_5 = GUICtrlCreateButton("5", 140, 120, 25, 15) $button_speed_10 = GUICtrlCreateButton("10", 165, 120, 25, 15) $button_speed_15 = GUICtrlCreateButton("15", 115, 140, 25, 15) $button_speed_25 = GUICtrlCreateButton("25", 140, 140, 25, 15) $button_speed_50 = GUICtrlCreateButton("50", 165, 140, 25, 15) $window_help = GUICreate("Help", 170, 65, -1, -1, -1, 0, $window_main) GUICtrlCreateLabel("Home = Set starting coordinates", 10, 5) GUICtrlCreateLabel("Insert = Start the script", 10, 25) GUICtrlCreateLabel("Delete = Stop the script", 10, 45) GUISetState(@SW_SHOW, $window_main) While 1 If $script_running Then ; Seriously, why is this even necessary...? $script_size_columns = GUICtrlRead($input_size_columns) $script_size_rows = GUICtrlRead($input_size_rows) farm() EndIf $script_speed = GUICtrlRead($input_speed) $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] = $button_help GUISetState(@SW_SHOW, $window_help) Case $gui_msg[0] = $button_speed_1 GUICtrlSetData($input_speed, "1") Case $gui_msg[0] = $button_speed_5 GUICtrlSetData($input_speed, "5") Case $gui_msg[0] = $button_speed_10 GUICtrlSetData($input_speed, "10") Case $gui_msg[0] = $button_speed_15 GUICtrlSetData($input_speed, "15") Case $gui_msg[0] = $button_speed_25 GUICtrlSetData($input_speed, "25") Case $gui_msg[0] = $button_speed_50 GUICtrlSetData($input_speed, "50") EndSelect Sleep(25) WEnd Func farm() ; Some (local) variables $current_x = $script_x $current_y = $script_y For $current_row = 1 To $script_size_rows Step 1 For $current_column = 1 To $script_size_columns Step 1 MouseClick("primary", $current_x, $current_y, 1, $script_speed) $current_x = $current_x + 25 $current_y = $current_y - 12 If $current_row = $script_size_rows / 2 Then If $current_column = $script_size_columns / 2 Then $current_x = $current_x + 25 $current_y = $current_y - 12 $current_column = $current_column + 1 EndIf EndIf If Not $script_running Then ExitLoop Next ; Reset to beginning of row $current_x = $current_x - (25 * $script_size_columns) $current_y = $current_y - (-12 * $script_size_columns) ; Advance to the next row $current_x = $current_x + 25 $current_y = $current_y + 12 If Not $script_running Then ExitLoop Next ; Stop running now stop_script() EndFunc
This post has been edited by linder: 02 September 2009 - 01:08 AM
Posted 02 September 2009 - 09:58 AM
;*** Farmville Bot ; v2009-07-30 - Now has a GUI, a target button, and optional avoidance of spawning square. ; v2009-07-31 - Added a Mouse Speed variable, made the GUI look better ; v2009-08-23 - Reworked the entire script to use hotkeys and a variable harvest area ; v2009-08-24 - Finished the rewrite, cleaned and compacted the code, added Help button ; Just some things to remember... ; When zoomed all the way out, the below are true... ; Moving across columns, x+25, y-12 ; Moving down rows, x+25, y+12 ;*** Design Goals ; 1. Create a better looking interface ; Includes #include <GUIConstantsEx.au3> #include <EditConstants.au3> ; Define a few (global) variables $script_x = 0 $script_y = 0 $script_speed = 0 $script_size_columns = 20 $script_size_rows = 4 $script_running = 0 $order = 0 ; Hotkeys HotKeySet("{1}", "set_position") HotKeySet("{2}", "start_script") HotKeySet("{3}", "stop_script") ; Hotkey Functions Func set_position() $script_x = MouseGetPos(0) $script_y = MouseGetPos(1) GUICtrlSetData($label_coordinate_x, $script_x) GUICtrlSetData($label_coordinate_y, $script_y) EndFunc Func start_script() GUICtrlSetColor($graphic_background, "0x33FF33") ;~ GUICtrlSetBkColor($button_help, "0x33FF33") $script_running = 1 EndFunc Func stop_script() GUICtrlSetColor($graphic_background, "0xF0F0F0") ;~ GUICtrlSetBkColor($button_help, "0xF0F0F0") $script_running = 0 EndFunc $window_main = GUICreate("Farmville Bot", 200, 165) $graphic_background = GUICtrlCreateGraphic(0, 0, 200, 165) GUICtrlSetState($graphic_background, $GUI_DISABLE) GUICtrlCreateGroup("Coordinates", 5, 5, 75, 60) GUICtrlCreateLabel("X:", 20, 25, 50) GUICtrlCreateLabel("Y:", 20, 40, 50) $label_coordinate_x = GUICtrlCreateLabel($script_x, 40, 25, 30) $label_coordinate_y = GUICtrlCreateLabel($script_y, 40, 40, 30) $button_help = GUICtrlCreateButton("Help", 15, 95, 75, 45) GUICtrlCreateGroup("Size", 90, 5, 105, 61) GUICtrlCreateLabel("Columns:", 98, 20) $input_size_columns = GUICtrlCreateInput($script_size_columns, 145, 18, 40, 20) $updown_size_columns = GUICtrlCreateUpdown($input_size_columns) GUICtrlSetLimit($updown_size_columns, 20, 1) GUICtrlCreateLabel("Rows:", 98, 42) $input_size_rows = GUICtrlCreateInput($script_size_rows, 145, 40, 40, 20) $updown_size_rows = GUICtrlCreateUpdown($input_size_rows) GUICtrlSetLimit($updown_size_rows, 20, 1) ;GUICtrlCreateGroup("Mouse Speed", 110, 75, 85, 85) ;$input_speed = GUICtrlCreateInput($script_speed, 125, 95, 50, 20, $ES_CENTER) ;$updown_speed = GUICtrlCreateUpdown($input_speed) ;GUICtrlSetLimit($updown_speed, 3000, 1) ;$button_speed_1 = GUICtrlCreateButton("1", 115, 120, 25, 15) ;$button_speed_5 = GUICtrlCreateButton("5", 140, 120, 25, 15) ;$button_speed_10 = GUICtrlCreateButton("10", 165, 120, 25, 15) ;$button_speed_15 = GUICtrlCreateButton("15", 115, 140, 25, 15) ;$button_speed_25 = GUICtrlCreateButton("25", 140, 140, 25, 15) ;$button_speed_50 = GUICtrlCreateButton("50", 165, 140, 25, 15) $window_help = GUICreate("Help", 170, 65, -1, -1, -1, 0, $window_main) GUICtrlCreateLabel("1 - Set starting coordinates", 10, 5) GUICtrlCreateLabel("2 - Start the script", 10, 25) GUICtrlCreateLabel("3 - Stop the script", 10, 45) GUISetState(@SW_SHOW, $window_main) While 1 If $script_running Then ; Seriously, why is this even necessary...? $script_size_columns = GUICtrlRead($input_size_columns) $script_size_rows = GUICtrlRead($input_size_rows) farm() EndIf ;$script_speed = GUICtrlRead($input_speed) $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] = $button_help ; GUISetState(@SW_SHOW, $window_help) ; Case $gui_msg[0] = $button_speed_1 ; GUICtrlSetData($input_speed, "1") ; Case $gui_msg[0] = $button_speed_5 ; GUICtrlSetData($input_speed, "5") ; Case $gui_msg[0] = $button_speed_10 ; GUICtrlSetData($input_speed, "10") ; Case $gui_msg[0] = $button_speed_15 ; GUICtrlSetData($input_speed, "15") ; Case $gui_msg[0] = $button_speed_25 ; GUICtrlSetData($input_speed, "25") ; Case $gui_msg[0] = $button_speed_50 ; GUICtrlSetData($input_speed, "50") EndSelect Sleep(25) WEnd Func farm() ; Some (local) variables $current_x = $script_x $current_y = $script_y For $current_row = 1 To $script_size_rows Step 1 For $current_column = 1 To $script_size_columns Step 1 MouseClick("primary", $current_x, $current_y, 1, $script_speed) If $order = 0 Then $current_x = $current_x + 25 $current_y = $current_y - 12 Else $current_x = $current_x - 25 $current_y = $current_y + 12 EndIf If Not $script_running Then ExitLoop Next If $order = 0 Then $order = 1 $current_x = $current_x - 25 $current_y = $current_y + 12 else $order = 0 $current_x = $current_x + 25 $current_y = $current_y - 12 EndIf ; Reset to beginning of row ;$current_x = $current_x - (25 * $script_size_columns) ;$current_y = $current_y - (-12 * $script_size_columns) ; Advance to the next row $current_x = $current_x + 25 $current_y = $current_y + 12 If Not $script_running Then ExitLoop Next ; Stop running now stop_script() $order = 0 EndFunc
Posted 03 September 2009 - 01:12 AM
Quote
Posted 03 September 2009 - 06:54 PM
wetwlly, on 02 September 2009 - 04:12 PM, said:
Posted 03 September 2009 - 07:39 PM
While 1 HotKeySet ("{pause}", "HarvestTree") HotKeySet ("{9}", "HarvestTreeOp") HotKeySet ("{esc}", "exitScript") WEnd Func exitScript() Exit EndFunc Func HarvestTree() $startPos = MouseGetPos() For $i = 30 to 1 Step -1 $pos = MouseGetPos() MouseMove($pos[0]-4,$pos[1]-2, 1) MouseClick("left") $pSum = PixelChecksum($pos[0],$pos[1],$pos[0]+15, $pos[1]+53) If $pSum = 1847393948 Then $tPos=MouseGetPos() MouseMove($tPos[0]+1,$tPos[1]+1) MouseClick("left",$pos[0]+15, $pos[1]+53) mousemove($startPos[0],$startPos[1]) HarvestTree() Sleep (4000) EndIf Next $pos = MouseGetPos() EndFunc Func HarvestTreeOp() $startPos = MouseGetPos() For $i = 30 to 1 Step -1 $pos = MouseGetPos() MouseMove($pos[0]+4,$pos[1]-2, 1) MouseClick("left") $pSum = PixelChecksum($pos[0],$pos[1],$pos[0]+15, $pos[1]+53) If $pSum = 1847393948 Then $tPos=MouseGetPos() MouseMove($tPos[0]+1,$tPos[1]+1) Mouseclick("left",$pos[0]+15, $pos[1]+53) mousemove($startPos[0],$startPos[1]) HarvestTreeOp() Sleep (4000) EndIf Next $pos = MouseGetPos() EndFunc
Posted 04 September 2009 - 02:23 AM
linder, on 02 September 2009 - 01:07 AM, said:
; This script require a 20x20 farm and a 1280 x 800 resolutin ; Includes #include <GUIConstantsEx.au3> #include <EditConstants.au3> ; Define a few (global) variables $script_speed = 30 $script_amount = 4 $script_running = 0 ; Hotkeys HotKeySet("{INSERT}", "start_script") HotKeySet("{DELETE}", "stop_script") ; Hotkey Functions Func start_script() GUICtrlSetColor($graphic_background, "0x33FF33") ;~ GUICtrlSetBkColor($button_help, "0x33FF33") $script_running = 1 EndFunc Func stop_script() GUICtrlSetColor($graphic_background, "0xF0F0F0") ;~ GUICtrlSetBkColor($button_help, "0xF0F0F0") $script_running = 0 EndFunc $window_main = GUICreate("Beanbot", 100, 145) $graphic_background = GUICtrlCreateGraphic(0, 0, 200, 165) GUICtrlSetState($graphic_background, $GUI_DISABLE) GUICtrlCreateGroup("Amount", 10, 5, 85, 40) $input_amount = GUICtrlCreateInput($script_amount, 12, 18, 80, 20, $ES_CENTER) $updown_amount = GUICtrlCreateUpdown($input_amount) GUICtrlSetLimit($updown_amount, 20, 1) GUICtrlCreateGroup("Mouse Speed", 10, 50, 85, 40) $input_speed = GUICtrlCreateInput($script_speed, 12, 63, 80, 20, $ES_CENTER) $updown_speed = GUICtrlCreateUpdown($input_speed) GUICtrlSetLimit($updown_speed, 50, 1) GUICtrlCreateLabel("Insert = Start", 10, 100) GUICtrlCreateLabel("Delete = Stop", 10, 120) GUISetState(@SW_SHOW, $window_main) While 1 If $script_running Then $script_amount = GUICtrlRead($input_amount) farm() EndIf $script_speed = GUICtrlRead($input_speed) $gui_msg = GUIGetMsg(1) Select Case $gui_msg[0] = $GUI_EVENT_CLOSE If $gui_msg[1] = $window_main Then ExitLoop EndIf EndSelect Sleep(25) WEnd Func farm() For $current_amount = 1 To $script_amount Step 1 MouseClick("primary", 948, 707, 1, $script_speed) ;plow1 MouseClick("primary", 945, 648, 1, $script_speed) ;plow2 MouseClick("primary", 1112, 414, 1, $script_speed) ;last square ; MouseClick("primary", 1087, 402, 1, $script_speed) ;2nd square ; MouseClick("primary", 1087, 426, 1, $script_speed) ;3rd square MouseClick("primary", 940, 768, 1, $script_speed) ;market MouseClick("primary", 846, 452, 1, $script_speed) ;soybeans MouseClick("primary", 1112, 414, 1, $script_speed) ;1st square ; MouseClick("primary", 1087, 402, 1, $script_speed) ;2nd square ; MouseClick("primary", 1087, 426, 1, $script_speed) ;3rd square MouseClick("primary", 997, 707, 1, $script_speed) ;delete MouseClick("primary", 1112, 414, 1, $script_speed) ;lst square If Not $script_running Then ExitLoop ;this is before delete accept just for safety MouseClick("primary", 569, 493, 1, $script_speed) ;delete accept ; MouseClick("primary", 1087, 402, 1, $script_speed) ;2nd square ; MouseClick("primary", 569, 493, 1, $script_speed) ;delete accept ; MouseClick("primary", 1087, 426, 1, $script_speed) ;3rd square ; MouseClick("primary", 569, 493, 1, $script_speed) ;delete accept Next ; Stop running now stop_script() EndFunc
This post has been edited by linder: 04 September 2009 - 02:44 AM
Posted 04 September 2009 - 02:56 AM
Global Const $curHarvest[2][3] = [[27,18,0x13A89E], [19,31,0xD1D2D4]] Global Const $curMarket[3][3] = [[10,10,0xC49A6C], [16,32,0xEF4036], [25,28,0xFCB040]] Global Const $curHoe[3][3] = [[26,17,0x39B54A], [19,28,0xD1D2D4], [12,38,0xC9CACC]] Global Const $curShovel[3][3] = [[29,14,0xEF4036], [20,29,0xD1D2D4],[16,28,0x939598]] Global $WorkingArea[4] = [162,223,162+760,223+612] Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("MouseCoordMode",0) Opt("PixelCoordMode",0) HotKeySet("{Esc}", "captureEsc") If WinWait("FarmVille on Facebook - Mozilla Firefox","", 5) = 0 Then ShellExecute("http://apps.facebook.com/onthefarm/index.php?ref=tab") EndIf WinWait("FarmVille on Facebook - Mozilla Firefox","", 30) $hWnd = WinGetHandle("FarmVille on Facebook - Mozilla Firefox","") If Not WinActive("FarmVille on Facebook - Mozilla Firefox","") Then WinActivate("FarmVille on Facebook - Mozilla Firefox","") WinWaitActive("FarmVille on Facebook - Mozilla Firefox","") While 1 If WinWait("FarmVille on Facebook - Mozilla Firefox","", 30) = 0 Then ShellExecute("http://apps.facebook.com/onthefarm/index.php?ref=tab") ContinueLoop EndIf $hWnd = WinGetHandle("FarmVille on Facebook - Mozilla Firefox","") If Not WinActive("FarmVille on Facebook - Mozilla Firefox","") Then WinActivate("FarmVille on Facebook - Mozilla Firefox","") WinWaitActive("FarmVille on Facebook - Mozilla Firefox","") ;## Zoom to max Sleep(15000) MouseClick("primary",835,709,4,0) For $i = 1 to 3 HarvestSearch() HarvestSearch() HarvestSearch() PlowSearch() PlowSearch() AnimalSearch() AnimalSearch() MarketSearch() MarketSearch() Sleep(10000) Next WinClose("FarmVille on Facebook - Mozilla Firefox","") $Wait = Random(1800000, 7200000, 1) LogEvent("Waiting for " & $Wait / 1000 / 60 & " minutes for next cycle.") Sleep($Wait) WEnd ;## TODO: Function currently only assumes you planted tomatos Func HarvestSearch($hWnd = Default) Local Const $PlotColor = 0xD03212; <-- Red part of Tomatoes Local $Coord Local $x = 0 Local $y = 0 Local $SearchArea LogEvent("Searching for plots that need harvested.") ;## Multi Tool MouseClick("primary",808,753,2,1) For $y = $WorkingArea[1] To $WorkingArea[3] For $x = $WorkingArea[0] To $WorkingArea[2] $Coord = PixelSearch($x,$y,$WorkingArea[2],$y,$PlotColor,5,1,$hWnd) If @error Then ExitLoop MouseMove($Coord[0], $Coord[1], 1) Sleep(300) If CheckPixelPattern($Coord, $curHarvest) Then LogEvent("+> Plot ready for harvest!") ;## Click Plot MouseClick("primary", $Coord[0], $Coord[1],1,2) ;## Multi Tool MouseClick("primary",808,753,2,2) EndIf $x = $Coord[0] + 1 Next Next EndFunc Func PlowSearch($hWnd = Default) Local Const $PlotColor = 0x7A6311 Local $Coord Local $x = 0 Local $y = 0 Local $SearchArea LogEvent("Searching for plots that need plowed.") ;## Multi Tool MouseClick("primary",808,753,2,1) For $y = $WorkingArea[1] To $WorkingArea[3] For $x = $WorkingArea[0] To $WorkingArea[2] $Coord = PixelSearch($x,$y,$WorkingArea[2],$y,$PlotColor,5,5,$hWnd) If @error Then ExitLoop MouseMove($Coord[0], $Coord[1], 1) Sleep(300) If CheckPixelPattern($Coord, $curHoe) Then LogEvent("+> Plot ready for plowing!") ;## Click Plot MouseClick("primary", $Coord[0], $Coord[1],1,2) ;## Multi Tool MouseClick("primary",808,753,2,2) EndIf $x = $Coord[0] + 1 Next Next EndFunc Func MarketSearch($hWnd = Default) Local Const $PlotColor = 0x843b10 Local $Coord Local $x = 0 Local $y = 0 Local $SearchArea $SearchArea = $WorkingArea LogEvent("Searching for plots that need planted.") MouseClick("primary",808,753,2,1) For $y = $WorkingArea[1] To $WorkingArea[3] For $x = $WorkingArea[0] To $WorkingArea[2] $Coord = PixelSearch($x,$y,$WorkingArea[2],$y,$PlotColor,0,1,$hWnd) If @error Then ExitLoop MouseMove($Coord[0], $Coord[1], 1) Sleep(300) If CheckPixelPattern($Coord, $curMarket) Then LogEvent("+> Plot ready for Planting!") ;## Click Plot MouseClick("primary", $Coord[0], $Coord[1],1,1) Sleep(500) ;## Select Tomatoes MouseClick("primary",838,582,1,30) Sleep(200) MouseClick("primary",838,582,1,2) Sleep(500) MouseClick("primary",546,740,1,5) ;;## Select Strawberries ; MouseClick("primary",402,587,1,20) ; Sleep(250) ;## Multi Tool MouseClick("primary",808,753,2,0) Sleep(1000) EndIf $x = $Coord[0] + 1 Next Next EndFunc Func AnimalSearch($hWnd = Default) Const $AnimalGlow = 0xFFCFF0 Local $x = $WorkingArea[0], $y = $WorkingArea[1] Local $Coord LogEvent("Searching for animals that need collected/harvested.") While 1 $Coord = PixelSearch($x, $y, $WorkingArea[2], $WorkingArea[3], $AnimalGlow, 0, 1, $hWnd) If @error Then Return MouseMove($Coord[0], $Coord[1] + 2, 1) Sleep(300) If CheckPixelPattern($Coord, $curHarvest) Then LogEvent("+> Animal ready for harvest!") MouseClick("primary", $Coord[0], $Coord[1] + 2,1, 1) MouseClick("primary", $Coord[0] + 16, $Coord[1] + 54,1, 10) Else ;LogEvent($Coord[0] & " " & $Coord[1] & " !! Not Harvestable!!") ;Sleep(5000) EndIf $y = $Coord[1] + 1 WEnd EndFunc Func CheckPixelPattern($Coord, $Pattern, $hWnd = Default) Local $i For $i = 0 To UBound($Pattern, 1) - 1 If PixelGetColor($Coord[0] + $Pattern[$i][0], $Coord[1] + $Pattern[$i][1], $hWnd) <> $Pattern[$i][2] Then LogEvent("Failed: " & $i & " - 0x" & Hex(PixelGetColor($Coord[0] + $Pattern[$i][0], $Coord[1] + $Pattern[$i][1], $hWnd),6)) Return False EndIf Next Return True EndFunc Func LogEvent($Message) ConsoleWrite("+> " & @YEAR & @MON & @MDAY & @HOUR & @SEC & "." & @MSEC & @TAB & $Message & @CRLF) EndFunc
This post has been edited by Zinthose: 04 September 2009 - 03:07 AM
Posted 05 September 2009 - 02:56 AM
Posted 05 September 2009 - 04:49 AM
While $i < $loop ; all defined in the beginning If $script_running Then $script_size_columns = GUICtrlRead($input_size_columns) $script_size_rows = GUICtrlRead($input_size_rows) farm() Sleep(60000) ;waits 60000, for finishing harvesting/plowing farm() Sleep(60000) harvest() ;clicks harvest button Sleep(1000) arrow() ;clicks arrow, add more if needed Sleep(1000) selectcrop() ;selects ur crop Sleep(1000) farm() $i = $i + 1 Sleep($script_seedtime) WEnd
This post has been edited by wetwlly: 05 September 2009 - 04:58 AM
Posted 05 September 2009 - 07:29 AM
;*** Farmville Bot ; v2009-09-05 - !revised so you dont have to use a million hotkeys, now just set on first plot/multitool and the crop you want on the second page(add more arrows if more pages) ; v2009-09-05 - added multitool in so it can continue on replanting (does both clicks! on the button and then on the tool and not the tractors!) ; v2009-09-04 - Work in Progress: added more hotkeys to make it farm completed crops, then plow, clicks harvest button (set by key 1), ; clicks arrow (key 2) if you want, or just take it off with all the other things for arrow, select crop (set by key 3!) ; not fully completed though. ; v2009-07-30 - Now has a GUI, a target button, and optional avoidance of spawning square. ; v2009-07-31 - Added a Mouse Speed variable, made the GUI look better ; v2009-08-23 - Reworked the entire script to use hotkeys and a variable harvest area ; v2009-08-24 - Finished the rewrite, cleaned and compacted the code, added Help button ; Just some things to remember... ; When zoomed all the way out, the below are true... ; Moving across columns, x+25, y-12 ; Moving down rows, x+25, y+12 ;*** Design Goals ; 1. Create a better looking interface ; press "1" is for harvest button ; press "2" is the crop you want ;Credit : Jackalo (whole script), me*wetwlly*(just modding and copypasta) ; Includes #include <GUIConstantsEx.au3> #include <EditConstants.au3> ; Define a few (global) variables $loop = 5 ;$loop is a loop, how many times you want to loop the script! example loop = 10 $i = 1 $script_x = 0 $script_y = 0 $script_x3 = 0 $script_y3 = 0 $script_x6 = 0 $script_y6 = 0 $script_speed = 5 ;seedtime is whatever the crop is in milliseconds and then also add 60000, to add 10 minutes so all ur crops are ready ;but for now since this is a test its set to 1 second. $script_seedtime = 1500000 $script_size_columns = 20 $script_size_rows = 12 $script_running = 0 ; Hotkeys HotKeySet("{1}", "set_multitool") HotKeySet("{2}", "set_crop") HotKeySet("{HOME}", "set_position") HotKeySet("{INSERT}", "start_script") HotKeySet("{DELETE}", "stop_script") ; Hotkey Functions Func set_multitool() $script_x6 = MouseGetPos(0) $script_y6 = MouseGetPos(1) EndFunc Func set_crop() $script_x3 = MouseGetPos(0) $script_y3 = MouseGetPos(1) EndFunc Func set_position() $script_x = MouseGetPos(0) $script_y = MouseGetPos(1) GUICtrlSetData($label_coordinate_x, $script_x) GUICtrlSetData($label_coordinate_y, $script_y) EndFunc Func start_script() GUICtrlSetColor($graphic_background, "0x33FF33") ;~ GUICtrlSetBkColor($button_help, "0x33FF33") $script_running = 1 EndFunc Func stop_script() GUICtrlSetColor($graphic_background, "0xF0F0F0") ;~ GUICtrlSetBkColor($button_help, "0xF0F0F0") $script_running = 0 EndFunc $window_main = GUICreate("Farmville Bot", 200, 165) $graphic_background = GUICtrlCreateGraphic(0, 0, 200, 165) GUICtrlSetState($graphic_background, $GUI_DISABLE) GUICtrlCreateGroup("Coordinates", 5, 5, 75, 60) GUICtrlCreateLabel("X:", 20, 25, 50) GUICtrlCreateLabel("Y:", 20, 40, 50) $label_coordinate_x = GUICtrlCreateLabel($script_x, 40, 25, 30) $label_coordinate_y = GUICtrlCreateLabel($script_y, 40, 40, 30) $button_help = GUICtrlCreateButton("Help", 15, 95, 75, 45) GUICtrlCreateGroup("Size", 90, 5, 105, 61) GUICtrlCreateLabel("Columns:", 98, 20) $input_size_columns = GUICtrlCreateInput($script_size_columns, 145, 18, 40, 20) $updown_size_columns = GUICtrlCreateUpdown($input_size_columns) GUICtrlSetLimit($updown_size_columns, 20, 1) GUICtrlCreateLabel("Rows:", 98, 42) $input_size_rows = GUICtrlCreateInput($script_size_rows, 145, 40, 40, 20) $updown_size_rows = GUICtrlCreateUpdown($input_size_rows) GUICtrlSetLimit($updown_size_rows, 20, 1) $window_help = GUICreate("Help", 170, 85, -1, -1, -1, 0, $window_main) GUICtrlCreateLabel("Home = Set starting coordinates", 10, 5) GUICtrlCreateLabel("Insert = Start the script", 10, 25) GUICtrlCreateLabel("Delete = Stop the script", 10, 45) GUICtrlCreateLabel("1/2/3 = harvstbuton/arrow/crop", 10, 65) GUISetState(@SW_SHOW, $window_main) While $i < $loop If $script_running Then $script_size_columns = 20 $script_size_rows = 12 harvest() Sleep(1000) arrow() Sleep(1000) selectcrop() Sleep(1000) farm() $i = $i + 1 Sleep($script_seedtime) friend() Sleep(1000) multitool() Sleep(1000) farm() Sleep(60000) farm() Sleep(60000) EndIf WEnd Func harvest() $current_x4 = $script_x6 + 47 $current_y4 = $script_y6 + 54 MouseClick("primary", $current_x4, $current_y4, 1, 100) EndFunc Func friend() $current_x5 = $script_x6 - 226 $current_y5 = $script_y6 - 436 MouseClick("primary", $current_x5, $current_y5, 1, 100) MouseClick("primary", $current_x5, $current_y5, 1, 100) MouseClick("primary", $current_x5, $current_y5, 1, 100) MouseClick("primary", $current_x5, $current_y5, 1, 100) EndFunc Func selectcrop() MouseClick("primary", $script_x3, $script_y3, 1, 100) EndFunc Func arrow() $current_x3 = $script_x6 + 65 $current_y3 = $script_y6 - 143 MouseClick("primary", $current_x3, $current_y3, 1, 100) EndFunc Func multitool() $current_x6 = $script_x6 $current_y6 = $script_y6 - 70 MouseClick("primary", $script_x6, $script_y6, 1, 100) MouseClick("primary", $current_x6, $current_y6, 1, 100) EndFunc Func farm() ; Some (local) variables $current_x = $script_x $current_y = $script_y For $current_row = 1 To $script_size_rows Step 1 For $current_column = 1 To $script_size_columns Step 1 MouseClick("primary", $current_x, $current_y, 1, $script_speed) $current_x = $current_x + 25 $current_y = $current_y - 12 If Not $script_running Then ExitLoop Next ; Reset to beginning of row $current_x = $current_x - (25 * $script_size_columns) $current_y = $current_y - (-12 * $script_size_columns) ; Advance to the next row $current_x = $current_x + 25 $current_y = $current_y + 12 If Not $script_running Then ExitLoop Next EndFunc ; Stop running now stop_script()
This post has been edited by wetwlly: 05 September 2009 - 02:56 PM
Posted 06 September 2009 - 02:32 AM
This post has been edited by Malakai: 06 September 2009 - 02:35 AM