meowbits Posted May 6, 2009 Share Posted May 6, 2009 Wondering if the variable $left, $top, $right, $bottom are being 'saved' and used after the person clicks "done" Can you tell? I dont really know, there are no errors, but the program isn't running after you set your dimensions. expandcollapse popupOpt("WinWaitDelay",3000) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) #include <IE.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Dim $pos = "", $CHex = "", $Cpos = "", $Count = 0, $data[11], $Label_[11], $Run, $Launcher, $cwait = 0 Dim $pause, $left = 0, $right = 0, $top = 0, $bottom = 0 Dim $Gloc = @ScriptDir & "\Games\", $Ginfo Opt("PixelCoordMode", 0) ;1=absolute, 0=relative, 2=client Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client HotKeySet("{ESC}", "Terminate") $Gamebot = GUICreate("Min. PRIOR to pressing F9", 260, 155, -1, -1, -1, $WS_EX_ACCEPTFILES) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_CHECKED) $Group_10 = GUICtrlCreateGroup("Pixel Search Area", 10, 5, 240, 95) $Label_11 = GUICtrlCreateLabel("Left Top Right Bottom", 20, 25, 350, 20) $Input_12 = GUICtrlCreateInput($left, 20, 45, 40, 20) $Input_13 = GUICtrlCreateInput($top, 80, 45, 40, 20) $Input_14 = GUICtrlCreateInput($right, 140, 45, 40, 20) $Input_15 = GUICtrlCreateInput($bottom, 200, 45, 40, 20) $Button_29 = GUICtrlCreateButton("Get Area", 86, 68, 90, 25) $Button_33 = GUICtrlCreateButton("Run FarmBot", 12, 115, 110, 30) $Button_34 = GUICtrlCreateButton("Exit FarmBot", 135, 115, 110, 30) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_34 ExitLoop Case $msg = $Button_29 Get_Area() Case $msg = $Button_33 Set_Run() ; pixel search $left = IniRead($Gloc & $Ginfo & ".ini", "Settings", "Left", "None") GUICtrlSetData($Input_12, $left) $top = IniRead($Gloc & $Ginfo & ".ini", "Settings", "Top", "None") GUICtrlSetData($Input_13, $top) $right = IniRead($Gloc & $Ginfo & ".ini", "Settings", "Right", "None") GUICtrlSetData($Input_14, $right) $bottom = IniRead($Gloc & $Ginfo & ".ini", "Settings", "Bottom", "None") GUICtrlSetData($Input_15, $bottom) $Vary = IniRead($Gloc & $Ginfo & ".ini", "Settings", "Vary", "5") EndSelect WEnd Func Get_Area() $Count = 0 If GUICtrlRead($Button_29) = "Get Area" Then HotKeySet("{F9}", "set_Area") ToolTip('Press "F9" to Get the Area under the Mouse Left-Top-Right-Bottom, Click "Done" when Finished', 0, 0) GUICtrlSetData($Button_29, "Done") Return Else HotKeySet("{F9}") ToolTip('') GUICtrlSetData($Button_29, "Get Area") $Count = 0 EndIf EndFunc;==>Get_Area Func set_Area() $Count = $Count + 1 $Mpos = MouseGetPos() If $Count = 1 Then GUICtrlSetData($Input_12, $Mpos[0]) If $Count = 2 Then GUICtrlSetData($Input_13, $Mpos[1]) If $Count = 3 Then GUICtrlSetData($Input_14, $Mpos[0]) If $Count = 4 Then GUICtrlSetData($Input_15, $Mpos[1]) If $Count >= 4 Then $Count = 0 EndFunc;==>set_Area Func Set_Run() If $Run = 1 Then Run(@ComSpec & " /c Start " & $Launcher, "", @SW_HIDE) $ON = True ElseIf $Run = 2 Then $Launched = FileGetShortName($Launcher) Run(@ComSpec & " /c Start " & $Launched, "", @SW_HIDE) $ON = True EndIf GUISetState(@SW_MINIMIZE, $Gamebot) ToolTip('Press F9 to Start Game', 0, 0) _ReduceMemory() HotKeySet("{F9}", "_start") EndFunc;==>Set_Run Func _start() $Colors = IniReadSection($Gloc & $Ginfo & ".ini", "Colors") For $i = 0 To $Colors[0][0] $data[$i] = IniRead($Gloc & $Ginfo & ".ini", "Colors", $i, "") If $i >= 10 Then ExitLoop Next $pause = Not $pause While $pause ToolTip('GameBot is "Running".. Press F9 to Quit', 0, 0) $t = 0 Do $t = $t + 1 If $t > 10 Then ExitLoop Sleep($cwait) Until Not @error If $t > 10 Then ContinueLoop MouseClick("left", $Cpos[0], $Cpos[1], 1, 0) ;MouseMove($left, $top) WEnd ToolTip('') GUISetState(@SW_RESTORE, $Gamebot) HotKeySet("{F9}") EndFunc;==>_start Func _ReduceMemory() Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) Return $ai_Return[0] EndFunc;==>_ReduceMemory Func Terminate() Exit EndFunc;==>Terminate ; declare variable color (use Eyedropper4.0 to find color, ; keep 0x and add your 6 digit number after it) ;Dim $left, $top, $right, $bottom Global $storeIconColor = 0xB0BD62 ; store icon color Global $hayBailColor = 0xF7A505 ; haybail color Global $grassColor = 0x3A7A02 ; grass color Global $bailsTobuy ; Number of haybails to buy/sell Global $storeCoords ; Coordinates of the store icon Global $otherCoords ; Coordinates of the 'other' tab Global $buyHayBailCoords ; Coordinates to buy haybail Global $placeHayBailCoords ; Coordinates to place haybail Global $sellHayBailCoords = $placeHayBailCoords Global $confirmSellCoords; Coordinates to sell haybail (final) Global $clickSellCoords ; Coordinates to click 'sell' Global $storeCoords[2] ; Coordinates of the store icon Global $otherCoords[2] ; Coordinates of the Global $buyHayBailCoords[2] ; Coordinates of the Global $placeHayBailCoords[2] ; Coordinates of the Global $ssellHayBailCoords[2] ; Coordinates of the Global $confirmCoords[2] ; Coordinates of the ; declare ON true(on) false(off) Global $ON ;If $bailsTobuy != Int Then ; dialog box to prompt for total bails to buy/sell - NEED HELP ; Amount of bails you can afford is ((Total Coins -50)/48)) round down ; if answer != integer stop or run a loop to ask again, not sure how to. ; answer = $baysToBuy ;If ($CmdLine[0] = 2) Then ;Exit 0 ;EndIf ;If ($CmdLine[0] = 1) Then If $ON = True Then ; Open url to play FarmTown _IECreate ("http://apps.facebook.com/farmtown/play/", 1, 1, 1, 1) ; Initial loop Dim $iCounter = 1 While $iCounter = 1 Sleep(500) if $ON = True Then ; click store icon $storeCoords[0] = Round(($right - $left)*(77.63/100), 0) + $left $storeCoords[1] = Round(($bottom - $top)*(91.37/100), 0) + $top MouseClick("left", $storeCoords[0], $storeCoords[1]) Sleep(300) ; save coords as 'otherCoords' $otherCoords[0] = Round(($right - $left)*(81.57/100), 0) + $left $otherCoords[1] = Round(($bottom - $top)*(15.51/100), 0) + $top MouseClick("left", $otherCoords[0], $otherCoords[1]) Sleep(300) ; save coords as 'buyHayBailCoords' $buyHayBailCoords[0] = Round(($right - $left)*(30.26/100), 0) + $left $buyHayBailCoords[1] = Round(($bottom - $top)*(32.75/100), 0) + $top MouseClick("left", $buyHayBailCoords[0], $buyHayBailCoords[1]) Sleep(300) ; click grass ; save coords as 'placeHayBailCoords' $placeHayBailCoords[0] = Round(($right - $left)*(38/100), 0) + $left $placeHayBailCoords[1] = Round(($bottom - $top)*(39/100), 0) + $top MouseClick("left", $placeHayBailCoords[0], $placeHayBailCoords[1]) Sleep(300) ; click haybail just placed (samespot) MouseClick("left", $sellHayBailCoords[0], $sellHayBailCoords[1]) Sleep(300) ; save coords as 'confirmSellCoords' $clickSellCoords[0] = Round(($right - $left)*(37.5/100), 0) + $left $clickSellCoords[1] = Round(($bottom - $top)*(42.25/100), 0) + $top MouseClick("left", $clickSellCoords[0], $clickSellCoords[1]) Sleep(300) ; save coords as 'clickSellCoords' $confirmSellCoords[0] = Round(($right - $left)*(42.1/100), 0) + $left $confirmSellCoords[1] = Round(($bottom - $top)*(53.44/100), 0) + $top MouseClick("left", $confirmSellCoords[0], $confirmSellCoords[1]) EndIf $iCounter +=1 WEnd Dim $bCounter = 1 ; Main loop While $bailsTobuy -1 >= $bCounter Sleep(5000) MouseClick("left", $storeCoords[0], $storeCoords[1]) Sleep(300) MouseClick("left", $buyHayBailCoords[0], $buyHayBailCoords[1]) Sleep(300) MouseClick("left", $placeHayBailCoords[0], $placeHayBailCoords[1]) Sleep(300) MouseClick("left", $sellHayBailCoords[0], $sellHayBailCoords[1]) Sleep(300) MouseClick("left", $clickSellCoords[0], $clickSellCoords[1]) Sleep(300) MouseClick("left", $confirmSellCoords[0], $storeCoords[1]) $bCounter +=1 WEnd EndIf Link to comment Share on other sites More sharing options...
meowbits Posted May 6, 2009 Author Share Posted May 6, 2009 Thanks! I am losing the data, how can I keep them? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now