Sign in to follow this  
Followers 0
marian001

Facebook Farmville automation

502 posts in this topic

anyone know how to Get messages like level up and friend requesting help from farms. and after the level up the publish window?

run a pixel checksum check for them

$levelupbox = checksum number

$var = PixelChecksum(x,y,x+number, y+number)

then do a simple if $var == $levelupbox do a certain mouseclick. .

heres a simple mouse coordinate script along with checksum

HotKeySet("z","jPos")

While 1
    Sleep(100)
WEnd

Func jPos()
    $jPos = MouseGetPos()
    $pSum = PixelChecksum($jPos[0],$jPos[1],$jPos[0]+15, $jPos[1]+53)
    MsgBox(0, "Mouse x,y:", $jPos[0] & "," & $jPos[1] & "Checksum" & $pSum) ; $jPos[0] is x co-ordinate and $jPos[1] is Y co-ordinate
    
EndFunc

run it, press z to find your mouse location and checksum.

Note that it probably won't work from one computer to another

Share this post


Link to post
Share on other sites



#42 ·  Posted (edited)

run a pixel checksum check for them

$levelupbox = checksum number

$var = PixelChecksum(x,y,x+number, y+number)

then do a simple if $var == $levelupbox do a certain mouseclick. .

heres a simple mouse coordinate script along with checksum

HotKeySet("z","jPos")

While 1
    Sleep(100)
WEnd

Func jPos()
    $jPos = MouseGetPos()
    $pSum = PixelChecksum($jPos[0],$jPos[1],$jPos[0]+15, $jPos[1]+53)
    MsgBox(0, "Mouse x,y:", $jPos[0] & "," & $jPos[1] & "Checksum" & $pSum) ; $jPos[0] is x co-ordinate and $jPos[1] is Y co-ordinate
    
EndFunc

run it, press z to find your mouse location and checksum.

Note that it probably won't work from one computer to another

well what i have been doing is just finding the coords of where it is to delete it and the facebook message

and just be like multitoolcoords_x - x, multitool_y +Y.

just need the first part where the thing gets the pixelchecksum

ill try to get a lvl today. gotta get how far away the cancel button is for levelup from the multitool is. so that itll check the position for the rectangle to click and maybe do a pixelgetcolor in there too?

just looked through reference, and maybe pixelsearch would do the job. ill take a screenshot so we have some area of reference :D

Edited by wetwlly

Share this post


Link to post
Share on other sites

anyone know how to get this working

MouseClick("primary", $crop, 1, $script_speed) ;soybeans

must I give it two seperate variables,(ie cropx and cropy)

or is there a way to do

$crop = 748,449

didnt work, gives a compile error

neither does

$crop = 748 & "," & 449

nor does

$crop = "748, 449"

am I limited to either using multiple variables, or an array? or am I missing something

why not make it easy for you and have 2 variables?

Share this post


Link to post
Share on other sites

why not make it easy for you and have 2 variables?

that doesn't really make it any easier. just bloats the code, and makes it difficult to read when you have 40 lines that all look alike.

Share this post


Link to post
Share on other sites

that doesn't really make it any easier. just bloats the code, and makes it difficult to read when you have 40 lines that all look alike.

it wont be 40 lines if you know what your doing

Share this post


Link to post
Share on other sites

it wont be 40 lines if you know what your doing

I don't :D I've never really completed any indepth code before. I've done a bunch of mIRC Scripting. some php. Tried java and pearl, but besides small simple stuff, I'm still an amateur.

Don't really need my program anymore since I reached the level I wanted. But I'll eventually finish it and post

Share this post


Link to post
Share on other sites

I didn't want to create a new thread for the same kind of program, so I figured that I would post my alternative take on a Facebook Farmville click script here.

All this program does is automate the clicking process, with variable speeds, columns, and rows, and has hotkeys to make it quicker. This script was really great before they nerfed the instant farm technique, but it's still a time saver for me to this day.

I guess I should also note that this is made to work with Farmville when it's fully zoomed out. Take it or leave it, I just felt like sharing.

My version of this bot below.. Handles lots of the pop up windows to allow you to leave it running all the time.

I've only tested with the small farm - 12x12 and SoyBeans. Should be able to be adapted to other farm sizes and crops. I also use my hair color for zooming out.. So you might consider making yourself male with a bright green mohawk.

This is pretty rough code and in need of much improvement. Ideally all the click positions should be calculated from the corner coordinates. These coordinates come from starting the script on the free gift page then clicking play and pressing insert. Doing it this way always gets me the corner of the farmville window since the messages and stuff above it tend to change.

Working towards a bot that I can leave run all day planting a short time frame crop.

Should work with any resolution that plants soybeans and uses a 12x12 farm and has a character with a bright green mohawk.

;*** 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

;TODO
;Close Ribbon Window
;Close Gift Window
;Verify My_Neighbor Page Visiting after ~10 min -- FIX THIS!
;Tool Check for Harvest
;Tool Check for Plow
;Tool Check for Planting
;Open and buy from Market for planting

; 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

;These can possibly be used to calibrate for other monitors?
;Current y offset to blue button color - 277
;Current x offset to blue button color - 372
;373, 318
; Includes
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

; Define (global) variables

$offset_x = 0
$offset_y = 0
$corner_x = 0
$corner_y = 0
$script_x = 449
$script_y = 609
$script_speed = 25
$script_size_columns = 12
$script_size_rows = 12
$script_running = 0
$accept_button_color = 0x94BC41
$accept_button_color_highlighted = 0x31C640
$level_up_x = 712
$level_up_y = 774
$go_to_farm_color = 0x4E9258
$go_to_farm_x = 695
$go_to_farm_y = 411
$publish_button_color = 0x3B5998
$publish_button_x = 985
$publish_button_y = 724
$publish_color_check_x = 907
$publish_color_check_y = 723
$go_home_x = 1033
$go_home_y = 733
$go_home_color = 0x13a89e
$neighbor_help_x = 609
$neighbor_help_y = 562
$character_screen_x = 939
$character_screen_y = 472
$character_screen_color = 0xC3463A
$market_open_x = 1062
$market_open_y = 409
$market_open_color = 0xC3463A
$my_neighbors_page_button_x = 696
$my_neighbors_page_button_y = 413
$my_neighbors_page_button_color = 0x4E9258
$my_neighbors_page_link_x = 487
$my_neighbors_page_link_y = 277
$my_neighbors_page_link_color = 0x6D84B4
$lotto_button_x = 707
$lotto_button_y = 729
$play_link_x = 464
$play_link_y = 281
$hair_check_x = 723
$hair_check_y = 509
$hair_check_color = 0x0ECB08
$harvest_x = 1004
$harvest_y = 609
$ready_to_harvest_color = 0x387229
$ready_to_plow_color = 0x8C731E
$ready_to_plant_color = 0x894317
$harvesting_color = 0x3F8236
$plowing_color = 0x71822F
$planting_color = 0x6F662B
$market_button_x = $corner_x + 675
$market_button_y = $corner_y + 597
$soy_buy_button_x = $corner_x + 572
$soy_buy_button_y = $corner_y + 388
$soy_buy_color_check_x = $corner_x + 588
$soy_buy_color_check_y = $corner_y + 282
$soy_buy_color = 0x486606
$soy_check_color = 0x699606
$safe_start_click_x = $corner_x + 318
$safe_start_click_y = $corner_y + 424

Func ConfigGlobals()
    ; [x to click, y to click, color to check for, (x to check at, y to check at)]
    Global $bluebox[2] = [0,0]
    Global $level_up_popup[3] = [$level_up_x,$level_up_y,$accept_button_color]
    Global $publish[5] = [$publish_button_x,$publish_button_y,$publish_button_color,$publish_color_check_x,$publish_color_check_y]
    Global $go_home_button[3] = [$go_home_x,$go_home_y,$go_home_color]
    Global $help_neighbor[3] = [$neighbor_help_x, $neighbor_help_y, $accept_button_color]
    Global $char_screen_open[3] = [$character_screen_x,$character_screen_y,$character_screen_color]
    Global $market_open[3] = [$market_open_x,$market_open_y,$market_open_color]
    Global $my_neighbors_page[3] = [$my_neighbors_page_button_x,$my_neighbors_page_button_y,$my_neighbors_page_button_color]
    Global $my_neighbors_link[3] = [$my_neighbors_page_link_x, $my_neighbors_page_link_y, $my_neighbors_page_link_color]
    Global $hair_check[3] = [$hair_check_x, $hair_check_y, $hair_check_color]
    Global $lotto_check[3] = [$lotto_button_x, $lotto_button_y, $accept_button_color]
EndFunc

;Try to keep track of what we're doing -- 0 for nothing, 1 for harvest, 2 for plow, 3 for planting, 4 for waiting to action to finish.
$action = 0

FindBlueButton()
FixCoords()
ConfigGlobals()


; 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, 77)
GUICtrlCreateLabel("X:", 20, 25, 50)
GUICtrlCreateLabel("Y:", 20, 40, 50)
GUICtrlCreateLabel("A:", 20, 55, 50)
$label_coordinate_x = GUICtrlCreateLabel($script_x, 40, 25, 30)
$label_coordinate_y = GUICtrlCreateLabel($script_y, 40, 40, 30)
$label_action_a = GUICtrlCreateLabel($action, 40, 55, 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
    local $i = 0
    sleep(1000) ;Lots of Lag and Loading - Try to slow down and wait for things
    If $script_running Then
        ; Seriously, why is this even necessary...?
        $script_size_columns = GUICtrlRead($input_size_columns)
        $script_size_rows = GUICtrlRead($input_size_rows)
        WhatToDo()
    while $action == 0 Or $action == 4
        WhatToDo()
        PopUpCheck()
        sleep(1000)
        $i = $i + 1
        if $i > 600 Then
            $time = @hour & ":" & @MIN
;           MsgBox(4096, "time", $time)
            MouseClick("primary", $my_neighbors_page_link_x, $my_neighbors_page_link_y, 1, $script_speed);Check My Neighbors Page
            $i = 0
        EndIf
    WEnd
        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
            
            ;Before we click we want to make sure nothing has popped up on the screen
            PopUpCheck()
            
            ;Check to make sure we have the right tool
            ToolCheck()
            
            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()

    ;Loop here until it is time to do an action

EndFunc

Func ToolCheck()
    if $action == 1 Then ;If Harvest get multitool
;       MouseClick("primary", 996, 751, 1, $script_speed)
    ElseIf $action == 2 Then ;If Plow get multitool
;       MouseClick("primary", 996, 751, 1, $script_speed)
    ElseIf $action == 3 Then ;If planting make sure we've got soybeans selected.  If not go get them
        $pos = MouseGetPos() ;Check to see if I have SoyBeans
        $waste = PixelSearch($pos[0],$pos[1],$pos[0]+50,$pos[1]+50,$soy_check_color)
        if @error = 0 Then
            ;We have them!
        Else ;Else get them!
            GetSoyBeans()
        EndIf
    EndIf
EndFunc

Func GetSoyBeans()  ;Open Market and Select Soybeans
    MouseClick("primary", $market_button_x, $market_button_y, 1, $script_speed)         ;Click Market
    sleep(5000)
    if pixelgetcolor($soy_buy_color_check_x,$soy_buy_color_check_y) = $soy_buy_color Then ;Are these SoyBeans?
        MouseClick("primary", $soy_buy_button_x, $soy_buy_button_y, 1, 25)          ;Click Buy
        sleep(5000) ;Wait for market to go away
    EndIf
EndFunc

Func WhatToDo()
    if pixelgetcolor($harvest_x,$harvest_y) = $ready_to_plow_color Then
        $action = 2 ;Plow
    ElseIf pixelgetcolor($harvest_x,$harvest_y) = $ready_to_plant_color Then    ;Need This Pixel Color
        $action = 3 ;Plant
    ElseIf pixelgetcolor($harvest_x,$harvest_y) = $ready_to_harvest_color Then  
        $action = 1 ;Harvest
    ElseIf PixelGetColor($harvest_x,$harvest_y) = $harvesting_color Then
        $action = 4 ;In process of Harvesting
    ElseIf PixelGetColor($harvest_x,$harvest_y) = $planting_color Then
        $action = 4 ;In process of Planting
    ElseIf PixelGetColor($harvest_x,$harvest_y) = $plowing_color Then
        $action = 4 ;In process of plowing
    Else
        $action = 0 ;Nothing to do
    EndIf
EndFunc

Func PopUpCheck()
    sleep(500)
    ;MouseClick("primary", , , 1, $script_speed)
    If PixelGetColor($level_up_popup[0], $level_up_popup[1]) = $level_up_popup[2] Then          ;Close Level Up Popup
        MouseClick("primary", $level_up_popup[0], $level_up_popup[1], 1, $script_speed)
    ElseIf PixelGetColor($publish[3],$publish[4]) = $publish[2] Then                            ;Close Option to Publish our greatness
        MouseClick("primary", $publish[0], $publish[1], 1, $script_speed)
    ElseIf PixelGetColor($lotto_check[0], $lotto_check[1]) = $lotto_check[2] Then               ;Check for daily lotto window
        MouseClick("primary", $lotto_check[0], $lotto_check[1], 1, $script_speed)
    ElseIf PixelGetColor($help_neighbor[0], $help_neighbor[1]) = $help_neighbor[2] Then         ;Click to help a neighbor popup
        MouseClick("primary", $help_neighbor[0], $help_neighbor[1], 1, $script_speed)
    ElseIf PixelGetColor($help_neighbor[0], $help_neighbor[1]) = $accept_button_color_highlighted Then          ;Click to help a neighbor popup
        MouseClick("primary", $help_neighbor[0], $help_neighbor[1], 1, $script_speed)
    ElseIf PixelGetColor($char_screen_open[0],$char_screen_open[1]) = $char_screen_open[2] Then ;Close the screen when you click on yourself
        MouseClick("primary", $char_screen_open[0], $char_screen_open[1], 1, $script_speed)
    ElseIf PixelGetColor($market_open[0], $market_open[1]) = $market_open[2] Then               ;Close the market screen
        MouseClick("primary", $market_open[0], $market_open[1], 1, $script_speed)
    ElseIf PixelGetColor($my_neighbors_link[0], $my_neighbors_link[1]) = $my_neighbors_link[2] Then ;If I'm on the my neighbors page - see if I can help.  If not then Play
        MyNeighborsPage()
    ElseIf PixelGetColor( $hair_check[0], $hair_check[1]) = $hair_check[2] Then    ;Check for Close Up of Hair And Zoom Out
        MouseClick("primary", $safe_start_click_x, $safe_start_click_y, 1, $script_speed)
        sleep(1000)
        MouseWheel("down", 5)
    ElseIf PixelGetColor( $go_home_button[0], $go_home_button[1] ) = $go_home_button[2] Then    ;Go Home from Neighbors Farm - Last Check
        MouseClick("primary", $go_home_button[0], $go_home_button[1], 1, $script_speed)
    EndIf
    
    
EndFunc

Func MyNeighborsPage()
    If PixelGetColor($my_neighbors_page_button_x,$my_neighbors_page_button_y) = $my_neighbors_page_button_color Then    ;See if we can help a neighbor
        MouseClick("primary", $my_neighbors_page_button_x, $my_neighbors_page_button_y, 1, $script_speed)
    Else
        MouseClick("primary", $play_link_x, $play_link_y, 1, $script_speed)         ;No Neighbor To Help - Click Play
    EndIf
EndFunc

Func FindBlueButton()
    $bluebox = PixelSearch(0,0,500,500,0x6D84B4)
    $offset_x = ($bluebox[0] - 373)
    $offset_y = ($bluebox[1] - 277)
    $corner_x = $bluebox[0]
    $corner_y = $bluebox[1]
EndFunc

Func FixCoords()
$script_x = $script_x + $offset_x
$script_y = $script_y + $offset_y
$level_up_x =$level_up_x+ $offset_x
$level_up_y =$level_up_y+ $offset_y
$go_to_farm_x =$go_to_farm_x + $offset_x
$go_to_farm_y =$go_to_farm_y+ $offset_y
$publish_button_x =$publish_button_x+ $offset_x
$publish_button_y =$publish_button_y+ $offset_y
$publish_color_check_x =$publish_color_check_x + $offset_x
$publish_color_check_y =$publish_color_check_y + $offset_y
$go_home_x =$go_home_x + $offset_x
$go_home_y =$go_home_y+ $offset_y
$neighbor_help_x =$neighbor_help_x+ $offset_x
$neighbor_help_y =$neighbor_help_y+ $offset_y
$character_screen_x =$character_screen_x+ $offset_x
$character_screen_y =$character_screen_y + $offset_y
$market_open_x =$market_open_x + $offset_x
$market_open_y =$market_open_y+ $offset_y
$my_neighbors_page_button_x =$my_neighbors_page_button_x + $offset_x
$my_neighbors_page_button_y =$my_neighbors_page_button_y+ $offset_y
$my_neighbors_page_link_x =$my_neighbors_page_link_x+ $offset_x
$my_neighbors_page_link_y =$my_neighbors_page_link_y+ $offset_y
$lotto_button_x =$lotto_button_x+ $offset_x
$lotto_button_y =$lotto_button_y+ $offset_y
$play_link_x =$play_link_x + $offset_x
$play_link_y =$play_link_y + $offset_y
$hair_check_x =$hair_check_x + $offset_x
$hair_check_y =$hair_check_y+ $offset_y
$harvest_x =$harvest_x+ $offset_x
$harvest_y =$harvest_y+ $offset_y
$market_button_x = $corner_x + 675
$market_button_y = $corner_y + 597
$soy_buy_button_x = $corner_x + 572
$soy_buy_button_y = $corner_y + 388
$soy_buy_color_check_x = $corner_x + 588
$soy_buy_color_check_y = $corner_y + 282
$safe_start_click_x = $corner_x + 318
$safe_start_click_y = $corner_y + 424
EndFunc

    ;MouseClick("primary", $current_x, $current_y, 1, $script_speed)
;   $color = PixelGetColor( $go_home_button[0], $go_home_button[1])
;   MsgBox(4096,"Home Button Color","Color is:" +$color+ ".")
;   MsgBox(0,"The hex color is", Hex($color, 6))
;   MsgBox(0,"Zero is:", $go_home_button[0])

Share this post


Link to post
Share on other sites

#48 ·  Posted (edited)

Script wont work

(372) : ==> Subscript used with non-Array variable.:

$offset_x = ($bluebox[0] - 373)

$offset_x = ($bluebox^ ERROR

>Exit code: 1 Time: 0.439

Dont know why Global $bluebox[2] = [0,0] isnt working

ok found the issue im having

You can't define a variable then redefine it as something else

Func FindBlueButton()
   $bluebox = PixelSearch(0,0,500,500,0x6D84B4)
    $offset_x = $bluebox[0] - 373
    $offset_y = $bluebox[1] - 277
    $corner_x = $bluebox[0]
    $corner_y = $bluebox[1]
EndFunc
Edited by Malakai

Share this post


Link to post
Share on other sites

#49 ·  Posted (edited)

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
Edited by Malakai

Share this post


Link to post
Share on other sites

Script wont work

Dont know why Global $bluebox[2] = [0,0] isnt working

ok found the issue im having

You can't define a variable then redefine it as something else

Func FindBlueButton()
   $bluebox = PixelSearch(0,0,500,500,0x6D84B4)
    $offset_x = $bluebox[0] - 373
    $offset_y = $bluebox[1] - 277
    $corner_x = $bluebox[0]
    $corner_y = $bluebox[1]
EndFunc

The script runs as it is above.. The problem is that it can't find the blue box (Free Gifts selected) when you start the program. You either need to move the editor to a second monitor (Which is what I have and why I didn't get the error at first) or resize the window so that it doesn't cover the Free Gifts link at the top. Also be sure you're on the Free Gifts page when you start the script.

Made some more progress on the script over the last couple of days.. Left it running today while I worked and actually gained a level.

Next up is for me to buy the biggest farm and make the script do Strawberries since that's the best XP for my level right now. Someone asked me to do Tomatoes.. I'll see about that once I hit level 20 :D

Share this post


Link to post
Share on other sites

The script runs as it is above.. The problem is that it can't find the blue box (Free Gifts selected) when you start the program. You either need to move the editor to a second monitor (Which is what I have and why I didn't get the error at first) or resize the window so that it doesn't cover the Free Gifts link at the top. Also be sure you're on the Free Gifts page when you start the script.

Made some more progress on the script over the last couple of days.. Left it running today while I worked and actually gained a level.

Next up is for me to buy the biggest farm and make the script do Strawberries since that's the best XP for my level right now. Someone asked me to do Tomatoes.. I'll see about that once I hit level 20 :D

TOP 10 :D

# Peas

# Asparagus

# Grapes

# Sugar Cane

# Tomatoes

# Sunflowers

# Onions

# Coffee/BlackBerries

# Carrots

# Raspberries


----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Share this post


Link to post
Share on other sites

TOP 10 :D

# Peas

# Asparagus

# Grapes

# Sugar Cane

# Tomatoes

# Sunflowers

# Onions

# Coffee/BlackBerries

# Carrots

# Raspberries

Is this post supposed to be a list of all the stuff I can't plant? :-p

Upgraded to the biggest farm - UGH! Not everything is on the screen at the same time when you zoom all the way out :-( Little unsure of how to deal with that effectively.

My plan is to work on making the big farm size work with soybeans first. Then move to strawberries since that will make me the most XP right now. Problem is I'm not sure when I'll have a chance to be at my computer every 4 hours for a bit to work on things..

Share this post


Link to post
Share on other sites

Is this post supposed to be a list of all the stuff I can't plant? :-p

Upgraded to the biggest farm - UGH! Not everything is on the screen at the same time when you zoom all the way out :-( Little unsure of how to deal with that effectively.

My plan is to work on making the big farm size work with soybeans first. Then move to strawberries since that will make me the most XP right now. Problem is I'm not sure when I'll have a chance to be at my computer every 4 hours for a bit to work on things..

Should have warned you that it you have to make the script on the big screen. Yes berries are the best for XP

Share this post


Link to post
Share on other sites

I must add mine too. :D I just find this posts and i am posting my script is not perfect is slow but it does the job.

Instructions: You can do: pick up strawberries, pumkins, you can plow dead plants, plow plain field (field after you pick up the crops), you can seed. You have to choose in script.

First you run the script. Then i suggest you zoom out and go on full screen. First you have to show the script where is your field. You can make that by going on the left-up corner and press enter, then right-down corner and press enter. You are making a squre where program will search for fields, so be cerfull you get in all the fields.

$number = 1
$text = 0
;Choose one of the options by removing ; sign:
;$color = 6697239 ; Strawberries
;$color = 14707461 ; Pumpkin
;$color = 8871456 ; dead plants
;$color = 8415251 ; plain field
;$color = 8731665 ; plowed field
HotKeySet("{esc}", "Exite")


Global $pos = 0;reset position indicator
HotKeySet("{ENTER}", "getPos");set ENTER hotkey
While $pos = 0;does the loop while the coordinates have not been set
 ToolTip("Move mouse to the up-left corner and press ENTER")
 Sleep(50)
WEnd
ToolTip("");remove the tooltip
HotKeySet("{ENTER}");turn off the hotkey

;MsgBox("", "Koordinate", 'X:'&$pos[0]&' Y:'&$pos[1])

$left = $pos[0]
$up = $pos[1]
;MsgBox("", "Koordinate", 'X:'&$left&' Y:'&$up)

Global $pos = 0;reset position indicator
HotKeySet("{ENTER}", "getPos");set ENTER hotkey
While $pos = 0;does the loop while the coordinates have not been set
 ToolTip("Move mouse to the down-right corner and press ENTER")
 Sleep(50)
WEnd
ToolTip("");remove the tooltip
HotKeySet("{ENTER}");turn off the hotkey

;MsgBox("", "Koordinate", 'X:'&$pos[0]&' Y:'&$pos[1])

$right = $pos[0]
$down = $pos[1]


Do
    
Do
$barva = PixelSearch ( $left, $up, $right, $down, $color )
    Sleep(10)
until $barva <> 1

Sleep (10)

MouseClick( "left", $barva[0], $barva[1], 1, 10)

$number = $number + 1

Until $number = 400




Func Exite()
    exit 0
EndFunc







Func getPos();get position function
 $pos = MouseGetPos();set $pos to escape the loop and give coordinates
EndFunc

Share this post


Link to post
Share on other sites

so whats the definitive script? the one with the best options? New to Facebook (old father just set up facebook and kids set up my farmville) now want to set up script and blow them away.....

Share this post


Link to post
Share on other sites

so whats the definitive script? the one with the best options? New to Facebook (old father just set up facebook and kids set up my farmville) now want to set up script and blow them away.....

There isn't one.. yet.

Share this post


Link to post
Share on other sites

the easiest one is

plant a square with soyabeans

use the AU3 Recorder to record the following

delete square

plow square

plant soyabean

stop recording (don't scroll the farmville screen)

edit the produced script and put a "sleep(1500)" after each mouse up statement

put the clicks after the window detection in a for loop

give it the amount of times do do it (divide your coins by 30)

and let it go.

I've hit level 20 in week using this method.

I have all but one square planted and when I get 20k of coins, I set the script to go and come back in an hour and bam, new level.

this method, each xp costs 10 coins. (15 for the plow sqaure and 15 for the soyabean)

Share this post


Link to post
Share on other sites

so has anyone perfected the auto run plow/plant/harvest of strawberries so I can just let it go on its own while Im sleeping and at work?

Share this post


Link to post
Share on other sites

i have my own scripts, i used to have one for overnight, but i haven't worked on it for awhile cause i just use soybean delete. still don't have the time to update it to find the boxes for gifts/ribbons/publish/level. but I'm pretty sure if I found some coding on pixel searching and actually felt like i needed to finish it, definitely will.

Share this post


Link to post
Share on other sites

My version of this bot below.. Handles lots of the pop up windows to allow you to leave it running all the time.

I've only tested with the small farm - 12x12 and SoyBeans. Should be able to be adapted to other farm sizes and crops. I also use my hair color for zooming out.. So you might consider making yourself male with a bright green mohawk.

This is pretty rough code and in need of much improvement. Ideally all the click positions should be calculated from the corner coordinates. These coordinates come from starting the script on the free gift page then clicking play and pressing insert. Doing it this way always gets me the corner of the farmville window since the messages and stuff above it tend to change.

Working towards a bot that I can leave run all day planting a short time frame crop.

Should work with any resolution that plants soybeans and uses a 12x12 farm and has a character with a bright green mohawk.

;*** 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

;TODO
;Close Ribbon Window
;Close Gift Window
;Verify My_Neighbor Page Visiting after ~10 min -- FIX THIS!
;Tool Check for Harvest
;Tool Check for Plow
;Tool Check for Planting
;Open and buy from Market for planting

; 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

;These can possibly be used to calibrate for other monitors?
;Current y offset to blue button color - 277
;Current x offset to blue button color - 372
;373, 318
; Includes
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

; Define (global) variables

$offset_x = 0
$offset_y = 0
$corner_x = 0
$corner_y = 0
$script_x = 449
$script_y = 609
$script_speed = 25
$script_size_columns = 12
$script_size_rows = 12
$script_running = 0
$accept_button_color = 0x94BC41
$accept_button_color_highlighted = 0x31C640
$level_up_x = 712
$level_up_y = 774
$go_to_farm_color = 0x4E9258
$go_to_farm_x = 695
$go_to_farm_y = 411
$publish_button_color = 0x3B5998
$publish_button_x = 985
$publish_button_y = 724
$publish_color_check_x = 907
$publish_color_check_y = 723
$go_home_x = 1033
$go_home_y = 733
$go_home_color = 0x13a89e
$neighbor_help_x = 609
$neighbor_help_y = 562
$character_screen_x = 939
$character_screen_y = 472
$character_screen_color = 0xC3463A
$market_open_x = 1062
$market_open_y = 409
$market_open_color = 0xC3463A
$my_neighbors_page_button_x = 696
$my_neighbors_page_button_y = 413
$my_neighbors_page_button_color = 0x4E9258
$my_neighbors_page_link_x = 487
$my_neighbors_page_link_y = 277
$my_neighbors_page_link_color = 0x6D84B4
$lotto_button_x = 707
$lotto_button_y = 729
$play_link_x = 464
$play_link_y = 281
$hair_check_x = 723
$hair_check_y = 509
$hair_check_color = 0x0ECB08
$harvest_x = 1004
$harvest_y = 609
$ready_to_harvest_color = 0x387229
$ready_to_plow_color = 0x8C731E
$ready_to_plant_color = 0x894317
$harvesting_color = 0x3F8236
$plowing_color = 0x71822F
$planting_color = 0x6F662B
$market_button_x = $corner_x + 675
$market_button_y = $corner_y + 597
$soy_buy_button_x = $corner_x + 572
$soy_buy_button_y = $corner_y + 388
$soy_buy_color_check_x = $corner_x + 588
$soy_buy_color_check_y = $corner_y + 282
$soy_buy_color = 0x486606
$soy_check_color = 0x699606
$safe_start_click_x = $corner_x + 318
$safe_start_click_y = $corner_y + 424

Func ConfigGlobals()
    ; [x to click, y to click, color to check for, (x to check at, y to check at)]
    Global $bluebox[2] = [0,0]
    Global $level_up_popup[3] = [$level_up_x,$level_up_y,$accept_button_color]
    Global $publish[5] = [$publish_button_x,$publish_button_y,$publish_button_color,$publish_color_check_x,$publish_color_check_y]
    Global $go_home_button[3] = [$go_home_x,$go_home_y,$go_home_color]
    Global $help_neighbor[3] = [$neighbor_help_x, $neighbor_help_y, $accept_button_color]
    Global $char_screen_open[3] = [$character_screen_x,$character_screen_y,$character_screen_color]
    Global $market_open[3] = [$market_open_x,$market_open_y,$market_open_color]
    Global $my_neighbors_page[3] = [$my_neighbors_page_button_x,$my_neighbors_page_button_y,$my_neighbors_page_button_color]
    Global $my_neighbors_link[3] = [$my_neighbors_page_link_x, $my_neighbors_page_link_y, $my_neighbors_page_link_color]
    Global $hair_check[3] = [$hair_check_x, $hair_check_y, $hair_check_color]
    Global $lotto_check[3] = [$lotto_button_x, $lotto_button_y, $accept_button_color]
EndFunc

;Try to keep track of what we're doing -- 0 for nothing, 1 for harvest, 2 for plow, 3 for planting, 4 for waiting to action to finish.
$action = 0

FindBlueButton()
FixCoords()
ConfigGlobals()


; 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, 77)
GUICtrlCreateLabel("X:", 20, 25, 50)
GUICtrlCreateLabel("Y:", 20, 40, 50)
GUICtrlCreateLabel("A:", 20, 55, 50)
$label_coordinate_x = GUICtrlCreateLabel($script_x, 40, 25, 30)
$label_coordinate_y = GUICtrlCreateLabel($script_y, 40, 40, 30)
$label_action_a = GUICtrlCreateLabel($action, 40, 55, 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
    local $i = 0
    sleep(1000) ;Lots of Lag and Loading - Try to slow down and wait for things
    If $script_running Then
        ; Seriously, why is this even necessary...?
        $script_size_columns = GUICtrlRead($input_size_columns)
        $script_size_rows = GUICtrlRead($input_size_rows)
        WhatToDo()
    while $action == 0 Or $action == 4
        WhatToDo()
        PopUpCheck()
        sleep(1000)
        $i = $i + 1
        if $i > 600 Then
            $time = @hour & ":" & @MIN
;           MsgBox(4096, "time", $time)
            MouseClick("primary", $my_neighbors_page_link_x, $my_neighbors_page_link_y, 1, $script_speed);Check My Neighbors Page
            $i = 0
        EndIf
    WEnd
        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
            
            ;Before we click we want to make sure nothing has popped up on the screen
            PopUpCheck()
            
            ;Check to make sure we have the right tool
            ToolCheck()
            
            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()

    ;Loop here until it is time to do an action

EndFunc

Func ToolCheck()
    if $action == 1 Then ;If Harvest get multitool
;       MouseClick("primary", 996, 751, 1, $script_speed)
    ElseIf $action == 2 Then ;If Plow get multitool
;       MouseClick("primary", 996, 751, 1, $script_speed)
    ElseIf $action == 3 Then ;If planting make sure we've got soybeans selected.  If not go get them
        $pos = MouseGetPos() ;Check to see if I have SoyBeans
        $waste = PixelSearch($pos[0],$pos[1],$pos[0]+50,$pos[1]+50,$soy_check_color)
        if @error = 0 Then
            ;We have them!
        Else ;Else get them!
            GetSoyBeans()
        EndIf
    EndIf
EndFunc

Func GetSoyBeans()  ;Open Market and Select Soybeans
    MouseClick("primary", $market_button_x, $market_button_y, 1, $script_speed)         ;Click Market
    sleep(5000)
    if pixelgetcolor($soy_buy_color_check_x,$soy_buy_color_check_y) = $soy_buy_color Then ;Are these SoyBeans?
        MouseClick("primary", $soy_buy_button_x, $soy_buy_button_y, 1, 25)          ;Click Buy
        sleep(5000) ;Wait for market to go away
    EndIf
EndFunc

Func WhatToDo()
    if pixelgetcolor($harvest_x,$harvest_y) = $ready_to_plow_color Then
        $action = 2 ;Plow
    ElseIf pixelgetcolor($harvest_x,$harvest_y) = $ready_to_plant_color Then    ;Need This Pixel Color
        $action = 3 ;Plant
    ElseIf pixelgetcolor($harvest_x,$harvest_y) = $ready_to_harvest_color Then  
        $action = 1 ;Harvest
    ElseIf PixelGetColor($harvest_x,$harvest_y) = $harvesting_color Then
        $action = 4 ;In process of Harvesting
    ElseIf PixelGetColor($harvest_x,$harvest_y) = $planting_color Then
        $action = 4 ;In process of Planting
    ElseIf PixelGetColor($harvest_x,$harvest_y) = $plowing_color Then
        $action = 4 ;In process of plowing
    Else
        $action = 0 ;Nothing to do
    EndIf
EndFunc

Func PopUpCheck()
    sleep(500)
    ;MouseClick("primary", , , 1, $script_speed)
    If PixelGetColor($level_up_popup[0], $level_up_popup[1]) = $level_up_popup[2] Then          ;Close Level Up Popup
        MouseClick("primary", $level_up_popup[0], $level_up_popup[1], 1, $script_speed)
    ElseIf PixelGetColor($publish[3],$publish[4]) = $publish[2] Then                            ;Close Option to Publish our greatness
        MouseClick("primary", $publish[0], $publish[1], 1, $script_speed)
    ElseIf PixelGetColor($lotto_check[0], $lotto_check[1]) = $lotto_check[2] Then               ;Check for daily lotto window
        MouseClick("primary", $lotto_check[0], $lotto_check[1], 1, $script_speed)
    ElseIf PixelGetColor($help_neighbor[0], $help_neighbor[1]) = $help_neighbor[2] Then         ;Click to help a neighbor popup
        MouseClick("primary", $help_neighbor[0], $help_neighbor[1], 1, $script_speed)
    ElseIf PixelGetColor($help_neighbor[0], $help_neighbor[1]) = $accept_button_color_highlighted Then          ;Click to help a neighbor popup
        MouseClick("primary", $help_neighbor[0], $help_neighbor[1], 1, $script_speed)
    ElseIf PixelGetColor($char_screen_open[0],$char_screen_open[1]) = $char_screen_open[2] Then ;Close the screen when you click on yourself
        MouseClick("primary", $char_screen_open[0], $char_screen_open[1], 1, $script_speed)
    ElseIf PixelGetColor($market_open[0], $market_open[1]) = $market_open[2] Then               ;Close the market screen
        MouseClick("primary", $market_open[0], $market_open[1], 1, $script_speed)
    ElseIf PixelGetColor($my_neighbors_link[0], $my_neighbors_link[1]) = $my_neighbors_link[2] Then ;If I'm on the my neighbors page - see if I can help.  If not then Play
        MyNeighborsPage()
    ElseIf PixelGetColor( $hair_check[0], $hair_check[1]) = $hair_check[2] Then    ;Check for Close Up of Hair And Zoom Out
        MouseClick("primary", $safe_start_click_x, $safe_start_click_y, 1, $script_speed)
        sleep(1000)
        MouseWheel("down", 5)
    ElseIf PixelGetColor( $go_home_button[0], $go_home_button[1] ) = $go_home_button[2] Then    ;Go Home from Neighbors Farm - Last Check
        MouseClick("primary", $go_home_button[0], $go_home_button[1], 1, $script_speed)
    EndIf
    
    
EndFunc

Func MyNeighborsPage()
    If PixelGetColor($my_neighbors_page_button_x,$my_neighbors_page_button_y) = $my_neighbors_page_button_color Then    ;See if we can help a neighbor
        MouseClick("primary", $my_neighbors_page_button_x, $my_neighbors_page_button_y, 1, $script_speed)
    Else
        MouseClick("primary", $play_link_x, $play_link_y, 1, $script_speed)         ;No Neighbor To Help - Click Play
    EndIf
EndFunc

Func FindBlueButton()
    $bluebox = PixelSearch(0,0,500,500,0x6D84B4)
    $offset_x = ($bluebox[0] - 373)
    $offset_y = ($bluebox[1] - 277)
    $corner_x = $bluebox[0]
    $corner_y = $bluebox[1]
EndFunc

Func FixCoords()
$script_x = $script_x + $offset_x
$script_y = $script_y + $offset_y
$level_up_x =$level_up_x+ $offset_x
$level_up_y =$level_up_y+ $offset_y
$go_to_farm_x =$go_to_farm_x + $offset_x
$go_to_farm_y =$go_to_farm_y+ $offset_y
$publish_button_x =$publish_button_x+ $offset_x
$publish_button_y =$publish_button_y+ $offset_y
$publish_color_check_x =$publish_color_check_x + $offset_x
$publish_color_check_y =$publish_color_check_y + $offset_y
$go_home_x =$go_home_x + $offset_x
$go_home_y =$go_home_y+ $offset_y
$neighbor_help_x =$neighbor_help_x+ $offset_x
$neighbor_help_y =$neighbor_help_y+ $offset_y
$character_screen_x =$character_screen_x+ $offset_x
$character_screen_y =$character_screen_y + $offset_y
$market_open_x =$market_open_x + $offset_x
$market_open_y =$market_open_y+ $offset_y
$my_neighbors_page_button_x =$my_neighbors_page_button_x + $offset_x
$my_neighbors_page_button_y =$my_neighbors_page_button_y+ $offset_y
$my_neighbors_page_link_x =$my_neighbors_page_link_x+ $offset_x
$my_neighbors_page_link_y =$my_neighbors_page_link_y+ $offset_y
$lotto_button_x =$lotto_button_x+ $offset_x
$lotto_button_y =$lotto_button_y+ $offset_y
$play_link_x =$play_link_x + $offset_x
$play_link_y =$play_link_y + $offset_y
$hair_check_x =$hair_check_x + $offset_x
$hair_check_y =$hair_check_y+ $offset_y
$harvest_x =$harvest_x+ $offset_x
$harvest_y =$harvest_y+ $offset_y
$market_button_x = $corner_x + 675
$market_button_y = $corner_y + 597
$soy_buy_button_x = $corner_x + 572
$soy_buy_button_y = $corner_y + 388
$soy_buy_color_check_x = $corner_x + 588
$soy_buy_color_check_y = $corner_y + 282
$safe_start_click_x = $corner_x + 318
$safe_start_click_y = $corner_y + 424
EndFunc

    ;MouseClick("primary", $current_x, $current_y, 1, $script_speed)
;   $color = PixelGetColor( $go_home_button[0], $go_home_button[1])
;   MsgBox(4096,"Home Button Color","Color is:" +$color+ ".")
;   MsgBox(0,"The hex color is", Hex($color, 6))
;   MsgBox(0,"Zero is:", $go_home_button[0])

how do u get ur script started.. sorry i'm new.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0