Jump to content

Malakai

Members
  • Posts

    8
  • Joined

  • Last visited

Malakai's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. 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
  2. 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
  3. I don't 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
  4. 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.
  5. 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
  6. ^ I'm trying to reduce the ammount of variables for cleaner/easier to manage code. String() didnt work either in various forms, same with isString()
  7. 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
  8. anybody feel like adding ini file support for the above scripts. Being able to save where our plots are negates the need for resolution matched scripts. Currently looking to do that but don't have the free time to learn ini writing/reading today
×
×
  • Create New...