AutoHotkey Community

It is currently May 26th, 2012, 8:37 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 142 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 10  Next
Author Message
 Post subject: Hey
PostPosted: August 23rd, 2009, 1:38 pm 
I've been trying to optimize this script to follow a more efficient pattern (going right on the first row, then left, rinse and repeat, that way your little dude doesn't have to walk all the way back every time.)

Unfortunately I seem to be rubbish at this.

My problem seems to be that I can't figure out where in the script the input for row size is. If I have a row of 15, how do I tell it to go down and left after it's done 15 squares? After that it's just a matter of looping I guess.

Thanks in advance for any tips.


Report this post
Top
  
Reply with quote  
 Post subject: bam
PostPosted: August 23rd, 2009, 2:39 pm 
Ok I figured it out, still can't manage to divide the Y variable by 2 by itself, so if you just enter half of it it'll work, as long as you have an even number of rows. Enjoy the more efficient macro that I made :D :D : D:D :D :D

Code:
!^c::
GoSub GetFarmSq
GoSub Getfirstsq

i=1

Click %startx%,%starty%
newx=%startx%
newy=%starty%


Loop, %farmy%
{

Loop, %farmx%
{
Click %newx%,%newy%
newx+=25
newy-=12
Click %newx%,%newy%
sleep 200
i++
}

newx+=25
newy+=12
Click %newx%,%newy%

Loop, %farmx%
{
newx-=25
newy+=12
Click %newx%,%newy%
sleep 200
i++
}

newx+=25
newy+=12

startx+=25
starty+=12
sleep 200
}

return


GoSub Getfirstsq

GetFarmsq:
Inputbox, farmx, Hey There, Enter the number of squares in your top row, ,100,150
Inputbox, farmy, Hey There, Enter half the number of squares in long, ,100,150
;msgbox, you said your farm was %farmx% x %farmy%
farmx--
return

Getfirstsq:
Msgbox, Click the middle of the top left square
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return

!^x::reload
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2009, 8:42 pm 
I cheat and just trap my little dude with bails of hay, been messing about with getting it in full screen a little, when it stays, works like a dream, but farmville seems to throw a paddy sometime going to full screen


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2009, 2:36 am 
me wrote:
I cheat and just trap my little dude with bails of hay, been messing about with getting it in full screen a little, when it stays, works like a dream, but farmville seems to throw a paddy sometime going to full screen


I did leave out some key points, you must zoom all the way out to use it... and I just figured out this trapping the farmer trick... I've got my farmer trapped in the bottom right corner by 3 hay bales.... he doesn't wander the farm to do anything now.

As far as going down and then left, I chose the pattern I did because it was easiest to code, not for efficiency. If you always go right left, than you need to do more math... not my strong point, and divide by two so you know whether to go left at the bottom or right at the bottom... in my head anyway.

the loop is nested, so the first loop handles the vertical.... and the inside loop is the horizontal... hopefully that helps. if you still can't figure it out, I might have time tomorrow to play some more. the hardest part was figuring out the size of the plots.

I want to work it out so that it checks the color of the plot and makes sure it's plant-able...

Here's the current code... added a default size to your plot size so that you only have to hit enter unless it changes, or you need to do something custom.


Code:
!^c::
GoSub GetFarmSq
GoSub Getfirstsq

i=1

Loop, %farmy%
{
Click %startx%,%starty%
newx=%startx%
newy=%starty%
Loop, %farmx%
{
newx+=25
newy-=12
Click %newx%,%newy%
i++
}
startx+=25
starty+=12
}

return


GoSub Getfirstsq

GetFarmsq:
Inputbox, farmx, Hey There, Enter the number of squares in your top row,,100,150,,,,,14
if ErrorLevel
   GoSub Esc
Inputbox, farmy, Hey There, Enter the number of squares in long,,100,150,,,,,14
if ErrorLevel
   GoSub Esc
;msgbox, you said your farm was %farmx% x %farmy%
farmx--
return

Getfirstsq:
Msgbox, Click the middle of the top left square
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return

Esc:
!^x::reload
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2009, 2:42 am 
Offline

Joined: April 20th, 2006, 4:08 pm
Posts: 25
Location: Baltimore, MD
Image

You can see my little dude on the far right, and his status of plowing.


I just found this.... SetMouseDelay, 0

Add that to the top of the script, takes much less time.. I can't wait to use it on all 16 rows. :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2009, 11:14 am 
oh, I zoom out all the way, it's just that my plot is too big to all be seen, sorted now, I just have it click to go into full screen before going to the home square to start, 20x20 done in double quick time :)


Report this post
Top
  
Reply with quote  
 Post subject: Re: Hey
PostPosted: August 24th, 2009, 4:39 pm 
Offline

Joined: August 24th, 2009, 3:50 pm
Posts: 1
Bearclaw wrote:
I've been trying to optimize this script to follow a more efficient pattern (going right on the first row, then left, rinse and repeat, that way your little dude doesn't have to walk all the way back every time.)


Although I have annihilated this script for my own purposes to entertain a basic pattern I have learnt enough to help you with this. If you have an odd number of Y fields it will probably attempt to do an extra line. I am unsure how to stop that from happening, but this will do as you asked.

Left to right..... next line
Right to left.... next line
left to right... etc

Code:
!^c::
GoSub GetFarmSq
GoSub Getfirstsq

i=1

cycle := farmy/2
newx=%startx%
newy=%starty%
loop, %cycle%
{
Click %newx%,%newy%
Loop, %farmx%
{
newx+=25
newy-=12
Click %newx%,%newy%
}
newx+=25
newy+=12
Click %newx%,%newy%
Loop, %farmx%
{
newx-=25
newy+=12
Click %newx%,%newy%
}
newx+=25
newy+=12
}

return


GoSub Getfirstsq

GetFarmsq:
Inputbox, farmx, Hey There, Enter the number of squares in your top row,,100,150,,,,,14
if ErrorLevel
   GoSub Esc
Inputbox, farmy, Hey There, Enter the number of squares in long,,100,150,,,,,14
if ErrorLevel
   GoSub Esc
;msgbox, you said your farm was %farmx% x %farmy%
farmx--
return

Getfirstsq:
Msgbox, Click the middle of the top left square
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return

Esc:
!^x::reload
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject: About fullscreen
PostPosted: August 24th, 2009, 4:42 pm 
Just do this:

add this line to the script anywhere.

pause::Pause

now Run the script, when you now need to click on your first location, just press pause|break on the keyboard to pause the script. Go ahead and toggle fullscreen on farmville. zoom out twice, then press pause,break on keyboard and select your first location.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 24th, 2009, 10:57 pm 
nice idea lordzer0... all changing for me now the superberries have gone, none the less, a 20x20 takes a long time ahk or not, ready to change my farm a bit so that snippet will come in use...


Report this post
Top
  
Reply with quote  
 Post subject: Soybean-delete method?
PostPosted: August 27th, 2009, 9:53 pm 
very nice script(s). thank you.

anyone tried to do one for the Soybean-delete method?


Report this post
Top
  
Reply with quote  
PostPosted: August 31st, 2009, 5:32 pm 
first delete+big okay button:P
this script wait and klikk on okay its only an idea depends on pc where will it appear:P
Code:
!^Lbutton::
MouseGetPos, KezdoDestroyX, KezdoDestroyY
click KezdoDestroyX, KezdoDestroyY
;Msgbox, kérem a várakozási idot az okéig (nagyban függ a gépsebességtol, netkapcsolattól)
;inputbox, WT,WT,wait time (WT), ,50,150
;sleep %WT%
sleep 800
click 472,503
MouseMove KezdoDestroyX, KezdoDestroyY

;autoharvestklikk állatokon, fákon, használata: egy klikk és harvestol loopba rakva autoharvestálhat is:) 232,384 261,444
This script working, if u use this hotkey control+rightclick, dont need to click on harvest in pop-up menu working after 10th level (sell func). working on animals and trees.
Code:
^Rbutton::
MouseGetPos, HarvestLocX, HarvestLocY
click HarvestLocX, HarvestLocY
x1 := HarvestLocX + 48
y1 := HarvestLocY + 53
sleep 50
click %x1%,%y1%
sleep 10
MouseMove HarvestLocX, HarvestLocY


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 1st, 2009, 9:31 pm 
Or simply just zoom out.... and drag your farm around under your mouse.

Foolproof script based on the inital poster's one. Improved it to work for any farm, as long as you zoom out to the maximum.

(do note, when you trap your farmer with hay bales, you WILL click him or the haybales whenever you're harvesting. Whenever you have the plow tool or the plant tool selected, you will be able to just type in your entire farm ... 18x18 20x20 22x22 etc, you wont click your Farmerdude)

Script:

Code:
!^p::
GoSub GetFarmSq
GoSub Getfirstsq

looptimes := farmy // 2
checkmod := mod(farmy,2)
newx := startx + 25
newy := starty - 12
oldx := startx - 25
oldy := starty + 12
nextx := startx + 25
nexty := starty + 12

if (farmy = 1)
   goto singleLine
else if (farmy > 1)
   goto multiLine

   
multiLine:
Loop, %looptimes%
   {
   Click %startx%,%starty%

   
   Loop, %farmx%
      {
      Click %newx%,%newy%
      MouseClickDrag, L, newx, newy, startx, starty
      sleep 200
      }
   Click %nextx%,%nexty%
   MouseClickDrag, L, nextx, nexty, startx, starty
   sleep 200
   Loop, %farmx%
      {
      Click %oldx%,%oldy%
      MouseClickDrag, L, oldx, oldy, startx, starty
      sleep 200
      }
   Click %nextx% %nexty%
   MouseClickDrag, L, nextx, nexty, startx, starty
   sleep 200
   }
if (checkmod = 0)
   msgbox, Done
else if (checkmod = 1)
{
   Loop, %farmx%
      {
      Click %newx%,%newy%
      MouseClickDrag, L, newx, newy, startx, starty
      sleep 200
      }
   msgbox, Done
}
return

singleLine:
Click %startx%,%starty%
   Loop, %farmx%
         {
         Click %newx%,%newy%
         MouseClickDrag, L, newx, newy, startx, starty
         sleep 200
         }
msgbox, Done
return


GoSub Getfirstsq

GetFarmsq:
Inputbox, farmx, Hey There, Enter the number of squares in your top row, ,100,150
Inputbox, farmy, Hey There, Enter the number of squares in long, ,100,150
msgbox, you said your farm was %farmx% x %farmy%
farmx--
return

Getfirstsq:
Msgbox, Click the middle of the top left square
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return

!^x::reload
Return


start key got changed to CTRL ALT P (ctrl alt x to reload stayed)

Credits to Bearclaw for a nice base to start off.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 1st, 2009, 9:46 pm 
loldoublepost!!!

Image

(the phailsquares were done by me, cause i'm pro like that =^___^= .. it has nothing to do with the script)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2009, 8:00 am 
Just create a program that calculates all the mouseClicks and that generates the .ahk file for you, according to a set of parameters (like screen resolution, fullscreen button coordinates, window name, farm size, etc).
JavaScript would do.

Just a tip to get you all started :P


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2009, 3:17 pm 
Offline

Joined: April 20th, 2006, 4:08 pm
Posts: 25
Location: Baltimore, MD
eater44 wrote:
Just create a program that calculates all the mouseClicks and that generates the .ahk file for you, according to a set of parameters (like screen resolution, fullscreen button coordinates, window name, farm size, etc).
JavaScript would do.

Just a tip to get you all started :P


You add this like we haven't' developed a couple scripts that do what we need... now granted more ideas are always good, but at this time, we've got scripts that work, I'd be happy to see your solution though.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 142 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 10  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: bekihito, Blackholyman, Exabot [Bot] and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group