AutoHotkey Community

It is currently May 27th, 2012, 12:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 142 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 10  Next
Author Message
 Post subject:
PostPosted: September 17th, 2009, 3:47 pm 
Offline

Joined: August 5th, 2008, 10:58 am
Posts: 17
Thanks for the reply. It's pretty clear right now, I will try it .

P.S
Mine is also 18X18, so when the box prompt i have to put 18X18, because I did put the number of the parcels horizontally X number of parcels vertically ! Or I'm wrong ?

And, do I have to work on full screen or it doesn't work ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 18th, 2009, 3:07 am 
Offline

Joined: April 20th, 2006, 4:08 pm
Posts: 25
Location: Baltimore, MD
A couple of things:
I have my text boxes default to 10x16, I have a 20x16 farm. I do it in two sections. So unless something goes wrong, I run it twice, accepting the defaults each time.

You can Plow, Plant and Harvest using the script.
I have my guy trapped in the middle. I've found that if I click toward the left/middle of the square it will still click the square but not select the dude.

Also, if you want it to run the whole farm, you can accept both the text boxes, and then hit the pause button, go full screen and press pause again, and then click the top-left square.

If something happens after entering the farm size, hit ctrl+alt+x and it will reload the script.

I just logged in, and it seems that they added a menu item to the animals - rotate and allow move - the right-click harvest probably needs some tweaking now.

I've seen some other post that included a timer, but if you wanted to add one that plowed, planted, harvested you'd need to include some sort of timer, that looped every 4 hours. I might be able to work on this tomorrow.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 18th, 2009, 4:39 am 
Tuxhedoh, that would be GREATLY appreciated if you could work on that script with the timer. Im only planting 12x12 atm with the only exception is the middle square where my farmer is trapped. Even if I go bigger, I will use the same 12x12 for the script to run on its own as the other squares I will plant longer cycle plants to gain more coins over time. If the guy in the middle is a problem, I could move him to a corner and trap him before I start the script, then I could go to bed and to work in the morning and not have to bother with it. So a simple 12x12 with the farmers default starting point as the center that plows, plants, and harvests strawberries every 4 hours would be great. One thing I was thinking about is it might have to be like 4 1/2 hours to allow for any possible delays with the farmville server.

Again, thanks for looking into it :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 18th, 2009, 11:20 pm 
I started trying to do this by saving the mouse clicks, but it was all a big nightmare.

Tux`s script is awesome! Gratz, man.

Now, I wonder if someone has already done something similar to auto buy/sell hay bales, or even better to auto destroy crops, so that we could it to make tons of xp with soy bean. Now, THAT would be interesting! ^^


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 18th, 2009, 11:24 pm 
DeadBambi wrote:
Tuxhedoh, that would be GREATLY appreciated if you could work on that script with the timer. Im only planting 12x12 atm with the only exception is the middle square where my farmer is trapped. Even if I go bigger, I will use the same 12x12 for the script to run on its own as the other squares I will plant longer cycle plants to gain more coins over time. If the guy in the middle is a problem, I could move him to a corner and trap him before I start the script, then I could go to bed and to work in the morning and not have to bother with it. So a simple 12x12 with the farmers default starting point as the center that plows, plants, and harvests strawberries every 4 hours would be great. One thing I was thinking about is it might have to be like 4 1/2 hours to allow for any possible delays with the farmville server.

Again, thanks for looking into it :)


Its sounds interesting...but I wouldn`t trust it very much. I mean, with fv going out of sync quite frequently and eventual updates that forces us to refresh...
It would ruin everything....unless the script starts by running farmville, waiting for it to load, setting zoom, and so on and so forth.


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

Joined: September 17th, 2009, 3:13 pm
Posts: 5
MeMyself&I wrote:
Now, I wonder if someone has already done something similar to auto buy/sell hay bales, or even better to auto destroy crops, so that we could it to make tons of xp with soy bean. Now, THAT would be interesting! ^^

The soy bean script has been discussed and posted earlier in this thread.

And works great, BTW.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2009, 6:51 pm 
Really? Well...its a huge thread...I still can`t find it :/


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 24th, 2009, 4:33 pm 
Offline

Joined: September 17th, 2009, 3:13 pm
Posts: 5
Here's the script I'm using for the soybean delete:

qwerty wrote:
lavier wrote:
qwerty wrote:
lavier wrote:
Can u explain how to use your codec more clearly. I added them to AHK script and then don't know how to do next


This reply is for the soybean delete program.

So you pasted the code into a blank notepad document, saved this document as somename.ahk, doubleclicked it and have the little green H icon down in the bottom right corner of your screen.

All you need to do is hit "ctrl 0" (zero) then follow the popups. To stop the program hit "ctrl x"

If you mess up when following the popups, stop the program and start over.


After I click on .ahk file it's alwasy got notice: Error at line 28 etc. This line does not contain recoignize action . Maybe I did something wrong??? Pls help me


Sorry about that I tried it myself and got the same error.

try this and see if u get it again.
Code:
^0::

;CTRL 0 to start
;Ctrl X to stop

gosub Market
gosub Buysoybean
gosub getlocationplot
sleep 1000
click %asoX%, %asoY%
sleep 1000
click %mezoX%, %mezoY%
sleep 1000
gosub accept
msgbox, The script will run until you stop it with control+x. The script written by Szilveszter
inputbox,xp,xp,xp,,100,150
gosub mainLOOP
msgbox, %xp%*3 xp-t termelt a script
return


Market:
msgbox, click on the Market icon on your farm screen (midle of the icon)
KeyWait, LButton, D
KeyWait, LButton, D
mousegetpos, shopX, ShopY
sleep 100
powlX:=shopX
powlY:=shopY-55
powltoolY:=powlY-70
multiX:=powlX-46
multiY:=powlY
asoX:=powlX+45
asoY:=powlY
return


Buysoybean:
msgbox,click on Middle of the soybeans buy icon.
KeyWait, LButton, D
KeyWait, LButton, D
mousegetpos, soybeX, soybeY
sleep 200
return


getlocationplot:
msgbox, click on the bottom corner of the farm plot you want to use and wait.
KeyWait, LButton, D
KeyWait, LButton, D
mousegetpos, mezoX, mezoY
sleep 100
return

accept:
msgbox click on the big ACCEPT button.
KeyWait, LButton, D
KeyWait, LButton, D
mousegetpos, asoOKX, AsoOKY
sleep 200
return

mainLoop:
Loop %xp%
{
click %powlX%, %PowlY%
sleep 500
click %powlx%, %powltoolY%
sleep 500
click %mezoX%, %mezoY%
sleep 500
click %shopX%, %shopY%
sleep 1500
click %soybeX%, %soyBEY%
sleep 200
click %mezoX%, %mezoY%
sleep 500
click %asoX%, %asoY%
sleep 500
click %mezoX% , %mezoY%
sleep 750
click %asoOKX%, %asoOKY%
}
return
^x:: reload


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2009, 4:36 am 
Offline

Joined: May 16th, 2008, 8:09 pm
Posts: 12
Quote:

Its sounds interesting...but I wouldn`t trust it very much. I mean, with fv going out of sync quite frequently and eventual updates that forces us to refresh...
It would ruin everything....unless the script starts by running farmville, waiting for it to load, setting zoom, and so on and so forth.

Here's my script, complete with timer and start-up code. Every cycle it closes out any existing farmville shockwave app, then restarts.

I run at 1920,1200 resolution and my script is hard coded for that, so you will likely have trouble if you try to use it without modification.

Also the startupFarmville function included uses some image files of the "play" button up top and the zoom and full screen buttons that you will have to create for yourself.


Code:
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#SingleInstance Force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Include C:\DSC\AutoHotkey\SearchImages.AHK

isRunning:=0
DeltaX1:=20
DeltaY1:=10
DeltaX2:=20
DeltaY2:=10
;NextHarvest:=200909131117
IniRead, NextHarvest,C:\FVAHK.ini,Timer,NextHarvest
IniRead, LastHarvest,C:\FVAHK.ini,Timer,LastHarvest

SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
Gui, Add, Radio, vRadio1 , Blue Berries
Gui, Add, Radio, vRadio2 , Tomatoes (8h)
Gui, Add, Radio, vRadio3 , Carrots
Gui, Add, Radio, vRadio4 , Peas(1 day)
Gui, Add, Radio, vRadio5 , Coffee
Gui, Add, Radio, vRadio6 Checked, Blackberries
Gui, Add, Radio, vRadio7 , Sugar Cane


Gui, Add, Text, vCurTime,Time:
GUI, Add,Edit,w30 vAlarmHour,5
GUI, Add,Edit,w30 vAlarmMinute,5
GUI, Add,Edit,w30 vAlarmSeconds,5

Gui Add,Button, gSetAlarm,Set
Gui Add,Button, gStart,Start

Gui, Add, Text, vLastHarvestTime,Last Harvest:
Gui, Add, Text, vLHTDisplay w120,
Gui, Add, Text, vNextHarvestTime,Next Harvest:
Gui, Add, Text, vNHTDisplay w120,

Gui, Add, Text, vTTNH,Remaining Time to Next:
Gui, Add, Text, vTTNDisplay w100,



Gui, Add, Text, vStatus1 w250,
Gui, Add, Text, vStatus2 w250,

Gui Add,Button, gReloadBut,Reload
UpdateAlarmControls(NextHarvest)
Gui Show, x1600 y100

Gosub, UpdateStatus


UpdateStatusMsg(msg,idx)
{
   GuiControl, Text, Status%idx%,%msg%
}

SetTimer, UpdateStatus, 1000
Return
leadingZero(str)
{
   
   if(str="")
   {
      str=0
   }
   
   if(str<10)
   {
      retVal=0%str%
   }   
   Else
   {
      retVal:=str
      }
   return retVal
}
UpdateAlarmControls(val)
{
   FormatTime, Hour, %val%, HH
   FormatTime, Min, %val%, mm
   FormatTime, Sec, %val%, ss
   GuiControl, Text, AlarmHour, %Hour%
   GuiControl, Text, AlarmMinute, %Min%
   GuiControl, Text, AlarmSeconds, %Sec%
   
   
}
SetAlarm:
{
   FormatTime, New,, yyyyMMdd
   GuiControlGet, Hour,,AlarmHour
   GuiControlGet, Min,,AlarmMinute
   GuiControlGet, Sec,,AlarmSeconds

;GUI, Add,Edit,w30 vAlarmMinute
;GUI, Add,Edit,w30 vAlarmSeconds
;   Hour:=leadingZero(Hour)
;   Min:=leadingZero(Min)
;   Sec:=leadingZero(Sec)

   New=%New%%Hour%%Min%%Sec%
   Dif:= New
   EnvSub, Dif,A_Now, seconds
   if(Dif<0)
   {
      EnvAdd,New,1, days
      
   }
   SetNextHarvest(New)
   return
}
UpdateDisplay:
{
   FormatTime, LHT, %LastHarvest%, M/d/yyyy h:mm:ss tt
   NHTDisplay:= LHT
   GuiControl,Text,LHTDisplay, %LHT%

   FormatTime, NHT, %NextHarvest%, M/d/yyyy h:mm:ss tt
   NHTDisplay:= NHT
   GuiControl,Text,NHTDisplay, %NHT%
   Remaining:=NextHarvest
   EnvSub, Remaining, %A_Now%, Seconds
   GuiControl,Text,TTNDisplay, %Remaining% Seconds
   return
}

UpdateStatus:
{
Gosub, UpdateDisplay
if(Remaining<0)
{
   
   if (Remaining>-60)
   {
      isRunning:=0
      TimerExpired()
   }
}
if(remaining<500)
{
if(remaining>330)
{
   IfWinExist, ahk_class ShockwaveFlashFullScreen
   {
      WinClose, ahk_class ShockwaveFlashFullScreen
}
   IfWinExist, ahk_class IEFrame
   {
      WinClose, ahk_class IEFrame   
   }
}
}


if(remaining<300)
{
   ;Make sure the windows exist
   if (remaining>10)
   {

      IfWinNotExist, ahk_class ShockwaveFlashFullScreen
      {
         initialize()
      }
   }
}
;SetTimer, UpdateStatus, 1000
;SetNextHarvest(10)
;MsgBox, %NHT%
return
}
TimerExpired()
{
   SetTimer, UpdateStatus, Off

   ;Reset Next Harvest

   Global NextHarvest
   SetLastHarvest(NextHarvest)
;   SetNextHarvest(20991231235959)
   ;Gosub, UpdateDisplay
   TimerHarvest(18)
   SetTimer, UpdateStatus, 1000
}
TimerHarvest(times)
{
   startX:=532
   startY:=598

   GuiControlGet,r1,,Radio1
   GuiControlGet,r2,,Radio2
   GuiControlGet,r3,,Radio3
   GuiControlGet,r4,,Radio4
   GuiControlGet,r5,,Radio5
   GuiControlGet,r6,,Radio6
   GuiControlGet,r7,,Radio7
   
   if(r1)
   {
      Cycle=4
   }
   if(r2)
   {
      Cycle=8
   }
   if(r3)
   {
      Cycle=12
   }
   if(r4)
   {
      Cycle=23
   }
   if(r5)
   {
      Cycle=16
   }
   if(r6)
   {
      Cycle=4
   }
   if(r7)
   {
      Cycle=8
   }


idx:=0
   posX:=startX
   posY:=startY
   TimerHarvestRepeat:
   if(   CheckAbort("Begining"+%idx%))
   {
      return
   }

   if(idx=8)
   {
      HarvestAndPlantRow(posX+(25*idx),posY+(12*idx),times,9)
   }
   Else
   {
      HarvestAndPlantRow(posX+(25*idx),posY+(12*idx),times,-1)
   }
   if(idx=0)
   {
         NewHarvestTime:=A_Now
         Delay:=Cycle*60*60 + 70
         UpdateStatusMsg(Delay,2)
         EnvAdd, NewHarvestTime,Delay, Seconds
         SetNextHarvest(NewHarvestTime)
         Gosub, UpdateDisplay
   }

   idx:=idx+1
   UpdateStatusMsg(idx,2)
   if(idx<times)
   {
      
      goto,TimerHarvestRepeat

   }
   UpdateStatusMsg( Finished Cycle, 1)
}
CheckAbort(msg)
{
   IfWinNotActive, ahk_class ShockwaveFlashFullScreen
   {
      ;For now, if we have a problem, then just bail
      UpdateStatusMsg( Msg, 1)
      Return 1
      
   }
   return 0
   
}
SetNextHarvestDelta(delta)
{
   ; Sets the time for the next harvest in seconds from now
   Global NextHarvest:=A_Now
   EnvAdd, NextHarvest, delta, seconds
   SetNextHarvest(NextHarvest)
   
}
SetNextHarvest(value)
{
   Global NextHarvest:=value
   IniWrite, %NextHarvest%,C:\FVAHK.ini,Timer,NextHarvest
}


SetLastHarvest(value)
{
   Global LastHarvest:=value
   IniWrite, %value%,C:\FVAHK.ini,Timer,LastHarvest
}

^!o::
ExitApp
return

^!p::
ReloadBut:
{
  Reload
Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing?
IfMsgBox, Yes, Edit

  return
}


ClickFullField(size,dir1,dir2,dir3)
{
   MouseClick, L
   repeatCount:=0
   RepeatFull:
      RepeatClick(dir1,size-1,-1)
      RepeatClick(dir2,1,-1)
      RepeatClick(dir3,size-1,-1)
      repeatCount := repeatCount + 2
      if(repeatCount<size)
      {
      RepeatClick(dir2,1,-1)
      Goto RepeatFull
      }
}
ClickRowSkip(X,Y,times,skip)
{
   if(skip=-1)
   {
      ClickRow(X,Y,times)
   }
   Else
   {
      ClickRow(X,Y,skip)
      nextX:=X+skip*25+25
      nextY:=Y-skip*12-12
      ClickRow(nextX,nextY,times-skip - 1)
      
   }   
}
ClickRow(X,Y,times)
{
   if(CheckAbort("Click"))
   {
      Return
   }
      curX:=X
      curY:=Y
      idx:=0
      RepeatClickRow:
         MouseClick, L, curX, CurY
         curX:=curX+25
         curY:=curY-12
         idx:=idx+1
         Sleep, 120
      if(idx<times)
      {
         goto, RepeatClickRow
      }
}
RepeatClick(quad,times,skip)
{
   deltaXBase=25
   deltaYBase=12
   idx:=0
   if (quad=1)
   {
      deltaX:=deltaXBase
      deltaY:=-deltaYBase
   }
   if (quad=2)
   {
      deltaX:=-deltaXBase
      deltaY:=-deltaYBase
   }
   if (quad=3)
   {
      deltaX:=-deltaXBase
      deltaY:=deltaYBase
   }
   if (quad=4)
   {
      deltaX:=deltaXBase
      deltaY:=deltaYBase
   }
   MouseGetPos, curX, curY
   MouseClick, L, curX, curY
RepeatLoop:
if (idx<times)
   {
      curX:=curX+deltaX
      curY:=curY+deltaY


if(idx<>skip)
      {
         MouseClick, L, curX,CurY
      }
      Else
      {
         MouseMove, curX, CurY
      }
      idx:=idx+1
      Goto, RepeatLoop
   }
   
}


HarvestAndPlantFull(startX,startY,times)
{
   idx:=0
   posX:=startX
   posY:=startY
   FullHarvestRepeat:
   HarvestAndPlantRow(posX+(25*idx),posY+(12*idx),times,-1)
   FirstRowTime:=%A_Now%
   idx:=idx+1
   if(idx<times)
   {
      
      goto,FullHarvestRepeat
   }
   return, %FirstRowTime%
}
^d::
   MouseGetPos, curX, curY
   ;ClickRow(curX,CurY,18,9)
   HarvestAndPlantRow(curX,curY,18,9)
   
Return

^e::
   MouseGetPos, curX, curY
   HarvestAndPlantRow(curX,curY,18,-1)
   
Return
HarvestAndPlantRow(X,Y,times,skip)
{

   GuiControlGet,r1,,Radio1
   GuiControlGet,r2,,Radio2
   GuiControlGet,r3,,Radio3
   GuiControlGet,r4,,Radio4
   GuiControlGet,r5,,Radio5
   GuiControlGet,r6,,Radio6
   GuiControlGet,r7,,Radio7

   
   ;Select Multi Tool
   ;Harvest
   GuiControl, Text, Status1, Harvesting

   MouseClick,L,1210,1110
   MouseClick,L,1210,1110
   ClickRowSkip( X, Y, times,skip)
    ;return ; insert return here for testing purposes to skip remaining steps and pauses
   Sleep, times * 890
;Plow

   GuiControl, Text, Status1, Plowing
   MouseClick,L,1260,1110
   MouseClick,L,1260,1110
   ClickRowSkip( X, Y, times,skip)

   
   if(r1)
   {
      SeedTime:=BlueBerries()
   }
   if(r2)
   {
      SeedTime:=Tomatoes()

   }
   if(r3)
   {
         SeedTime:=Carrots()   
   }
   if(r4)
   {
         SeedTime:=Peas()   
   }
   if(r5)
   {
         SeedTime:=Coffee()   
   }
   if(r6)
   {
         SeedTime:=Blackberries()   
   }
   if(r7)
   {
         SeedTime:=SugarCane()   
   }


   Sleep, times * 890 - SeedTime
   GuiControl, Text, Status1, Planting
   ;;Plant
   ClickRowSkip( X, Y, times,skip)
   Sleep, times * 890
   return
}

SoyBeanRepeat(X,Y,times)
{
   idx:=0
   SetTimer, UpdateStatus, Off
   retries:=0
   SoyBeanRepeatLabel:
   if(idx<times)
   {
      idx:=idx+1
      if(SoyBeanDelete(X,Y)=0)
      {
         Status=%idx%/%times% r:%retries%
         UpdateStatusMsg(status,2)
         Sleep, 100
         Goto SoyBeanRepeatLabel
      }
      Else
      {
         UpdateStatusMsg("Failed SD",2)
         Initialize()
         WinClose
         retries:=retries+1
         Goto, SoyBeanRepeatLabel
         
      }
   }
   SetTimer, UpdateStatus, 1000
   
}
BlueBerries()
{

   return SelectPlant(1020,820,1)

}


SoyBean()
{
   return SelectPlant2(1150,650,0)
}

Tomatoes()
{

   ;Tomatoes
   return SelectPlant(880,650,2)


}

Peas()
{

   ;Peas
   return SelectPlant(752,821,3)


}


Carrots()
{

   ;Tomatoes
   return SelectPlant(1150,650,2)


}
Coffee()
{

   ;Coffee
   return SelectPlant(752,821,2)


}

Blackberries()
{

   ;Blackberries
   return SelectPlant(880,650,3)


}

SugarCane()
{

   ;Blackberries
   return SelectPlant(1020,650,3)


}



SelectPlant(X,Y,Page)

{
   ;Market
      
   MouseCLick, L,1260,1160
   Sleep 2300
   idx:=0
   
   RepeatMarketPage2:
   if(idx<Page)
   {
      ;Next Arrow
      MouseCLick, L,1280,660
      Sleep, 1200
      idx:=idx+1
      Goto, RepeatMarketPage2
   }

   ;
   MouseCLick, L,X,Y

   return 1200 * Page + 2300
}


SelectPlant2(X,Y,Page)
{
   ;Market
   StartTime:=A_TickCount
   MouseCLick, L,1260,1160
;   Sleep 2300
   WaitForArrow:
   ArrowWait:=0
   PixelGetColor, Arrow, 1280,660
   Msg="Arrow:"%Arrow%
   UpdateStatusMsg(Msg,1)
   if(Arrow<>"0x3A5470")
   {
      ArrowWait:=ArrowWait+1
      Sleep, 10
      if(ArrowWait>300)
      {
         return, -1
      }
      Goto, WaitForArrow
   }
   Sleep, 100
   
   idx:=0
   
   RepeatMarketPage:
   if(idx<Page)
   {
      ;Next Arrow
      MouseCLick, L,1280,660
      Sleep, 1200
      idx:=idx+1
      Goto, RepeatMarketPage
   }

   ;

   ButtonWait:=0
   WaitForButton:
   PixelGetColor, ButColor, X,Y
   if(ButColor<>"0x41BC94")
   {
      Sleep, 10
      ButtonWait:=ButtonWait+1
      if(ButtonWait>300)
      {
         return -1
      }
      Goto, WaitForButton
   }
   Sleep, 50
   MouseCLick, L,X,Y
   Elapsed:=A_tickcount - StartTime
   
   return, Elapsed
}

;41BC94
;40C631

ClickVerified(X,Y)
{
   IfWinActive, ahk_class ShockwaveFlashFullScreen
   {
      MouseClick, L, X,Y
      return, 1
   }

}
ClickGreenButton(X,Y)
{
   Failures:=0
   RetryGreen:
   Sleep, 10

   PixelGetColor, C1, X, Y, Slow
   if((C1="0x41BC94") OR (C1="0x40C631"))
   {
      ButtonFound:

      MouseMove, X, Y
      Sleep, 50
      PixelGetColor, C2, X, Y, Slow
      
      ;MsgBox,,,%C2%
      if(C2="0x40C631")
      {
         MouseClick, L, X, Y
         Sleep, 50
         WaitForDismiss:
         if(C2<>"0x40C631")
         {
            return 0
         }
         else
         {
            PixelGetColor, C2, X, Y, Slow
            UpdateStatusMsg("Unable to Dismiss Delete",1)
            Goto, WaitForDismiss
         }

      }
   
   }
   Failures:=Failures+1
   ;MsgBox, ,, %C1%
   if(Failures<50)
   {
;      MsgBox,,,Failed + %C1%
      UpdateStatusMsg(C1,1)
      Sleep, 50
      Goto, RetryGreen
      }
   UpdateStatusMsg(C1,1)
   return -1
   
}


SoyBeanDelete(X,Y)
{
   ;plow
   ClickVerified(1260,1110)
   ClickVerified(1260,1110)
   ClickVerified(X,Y)
   IfWinNotActive, ahk_class ShockwaveFlashFullScreen
   {
      return 1
   }

   ;soybean
   PixelGetColor, LastColor, X-8, Y-8, Slow
   Msg="Plow" %LastColor%
   UpdateStatusMsg(Msg,1)
   Sleep, 100
   retval:=Soybean()
   if(Soybean<0)
   {
;      return 1
   }
   IfWinNotActive, ahk_class ShockwaveFlashFullScreen
   {
      return 1
   }
   Sleep, 500
   ClickVerified(X-8,Y-8)
   DisplayColor:
   
   ;delete
   ClickVerified(1300, 1100)
   idx:=0
   ;965,588
   WaitPlant:
   PixelGetColor, PlantColor, 965,588, Slow
   Msg="Soybean" %idx% %PlantColor%
    UpdateStatusMsg(Msg,1)
   idx:=idx+1
   Sleep, 1500
;   if(PlantColor<>"0x1B478A")
   if(0)
   {
      sleep, 10
      if(idx>200)
      {
         return 1
      }
      goto, WaitPlant
      
   }
   
   ;MsgBox,,,%PlantColor%
   ;0x265E68
   
   ClickVerified(X-8,Y-8)
   ;Accept
   Sleep, 100
   if(   ClickGreenButton(890,680)=0)
   {
   }
   Else
   {
      ClickVerified(X-8,Y-8)
      UpdateStatusMsg("Retried Delete",1)
      if(   ClickGreenButton(890,680)<>0)
      {
         return 1
      }
   }
   IfWinNotActive, ahk_class ShockwaveFlashFullScreen
   {
      return 1
   }
   Sleep, 500
;   ClickVerified(890,680)

   return, 0
   
   
}


Initialize()
{
   retryStartup:
   Success:=StartUpFarmville()
   if(Success<>0)
   {
   UpdateStatusMsg("Startup Retry",2)
   goto, retryStartup
   }
   UpdateStatusMsg("Startup Successful",1)

   global isRunning:=1
}

SearchImageClick(image,MaxRetries)
{
   retries:=0
   MouseMove, 100,100
   UpdateStatusMsg(image,1)
   RepeatSearch:
   ImageSearch, XLoc,YLoc, 0,0,1800,1100, %image%
   if(ErrorLevel=2)
   {
      MsgBox,,,"Search problem")
   }
   if(ErrorLevel=1)
   {
      retries:=retries+1
      Sleep, 50
      if(retries>MaxRetries)
      {
         return, 1
      }
      msg=%image% %retries%
      UpdateStatusMsg(msg,1)
      Goto, RepeatSearch
   }
   if(ErrorLevel=0)
   {
      Global xFound:=Xloc
      Global yFound:=YLoc
   }
   MouseClick, L, XLoc,YLoc
   MouseMove, 100,100
   return, 0
}
StartUpFarmville()
{
   UpdateStatusMsg("Starting Up Farmville",2)
   FVURL=http://apps.facebook.com/onthefarm/index.php?ref=tab
   IfWinExist, ahk_class ShockwaveFlashFullScreen
   {
      ; Assume this is the farmville App
      WinActivate, ahk_class ShockwaveFlashFullScreen
      WinClose
      ;return
   }
   IfWinExist,, FarmVille on Facebook
   {
      WinActivate,,FarmVille on Facebook
   }


   ;Activate Browser
   IfWinNotExist, ahk_class IEFrame
   {
      
      Run, C:\Program Files\Internet Explorer\iexplore.exe http://apps.facebook.com/onthefarm/index.php?ref=tab
      Sleep, 15000
      WinMaximize, ahk_class IEFrame
      
   }
   
   ;Find the play button and click
   if(   SearchImageClick("C:\dsc\Autohotkey\Farmville\playWhite.png",10))
   {
      if(   SearchImageClick("C:\dsc\AutoHotkey\Farmville\play.png",100))
      {
         if(SearchImageClick("C:\dsc\Autohotkey\Farmville\playWhite.png",100))
         {
            return 1
         }
      }
   }

   Sleep, 1500
   CanRepeat:=0
   CanX:=880
   CanY:=650
   CheckCan:
   PixelGetColor, CanColor, CanX,CanY Slow
   UpdateStatusMsg(CanColor %CanRepeat%,1)
   if(CanColor="0x3A46C3")
   {
      Sleep, 100
      MouseClick, L, CanX,CanY
   }
   Else
   {   
      Sleep, 50
      CanRepeat:=CanRepeat+1
      if(CanRepeat<100)
      {
         goto, CheckCan   
      }
   }
   ;SearchImageClick("C:\dsc\AutoHotkey\Farmville\Ca.png",100)
   
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\Fullscreen.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)
   SearchImageClick("C:\dsc\AutoHotkey\Farmville\ZoomOut.png",500)

   swcnt:=0
   waitShockWave:
   IfWinExist, ahk_class ShockwaveFlashFullScreen
   {
      UpdateStatusMsg("Init Successful",2)

      return, 0
   }
   if(swcnt<100)
   {
      UpdateStatusMsg("WaitSW" %swcnt%,2)
      swcnt:=swcnt+1
      Sleep, 100
      goto, waitShockWave
   }
   return, 1
}

BlockHay()
{
   Bale1X:=0
   Bale1Y:=0
   Bale2X:=0
   Bale2Y:=0
   
   PixelGetColor,B1C,Bale1X,Bale2Y
   PixelGetColor,B2C,Bale2X,Bale2Y

   ;Check if haybales in corner already
   
   ;Move Farmer to corner
   
}
Start:
Initialize()

Return
SoyBean2(X,Y)
{
   
   ;Plow
   MouseClick,L, 1172,763
   MouseClick,L, 1172,763

   Sleep, 50
   MouseClick, L,861,585
   
   MouseClick, L, 1160,814
   Sleep, 1500
   MouseClick, L ,1058,622
   Sleep, 500
   MouseClick, L,876,536
   Sleep, 1000

   ; Delete
   MouseClick, L,1220, 770
   Sleep, 100
   ;Square
   MouseClick, L,876,536
   Sleep, 600
   MouseClick, L,780,670   
   Sleep, 500



}
SoyBean3(X,Y)
{
   
   ;Plow
   MouseClick,L, 1172,813
   MouseClick,L, 1172,813

   Sleep, 50
   MouseClick, L,861,635
   
   MouseClick, L, 1160,864
   Sleep, 1400
   MouseClick, L ,1058,672
   Sleep, 400
   MouseClick, L,876,586
   Sleep, 1000

   ; Delete
   MouseClick, L,1220, 820
   Sleep, 100
   ;Square
   MouseClick, L,876,586
   Sleep, 680
   MouseClick, L,780,720   
   Sleep, 500



}

^!f::

   WinActivate,,FarmVille
   idx:=0
   RepeatSB2:
      IfWinNotActive,, FarmVille
      {
         return
      }
      SoyBean2(0,0)
      idx:=idx+1
      UpdateStatusMsg(idx,1)
      if(idx<3000)
      {
         Goto, RepeatSB2
      }
Return

#IfWinActive, ahk_class ShockwaveFlashFullScreen
^!q::
XButton1::
   TimerExpired()
Return



Return
^+LButton::
   MouseGetPos, curX, curY
    SoyBeanRepeat(curX,curY,1700)
Return


^!s::
RepeatClick(1,17,-1)
Return


^!a::
RepeatClick(2,17,-1)
Return

^!z::
RepeatClick(3,17,-1)
Return

^!x::
RepeatClick(4,17,-1)
Return

deleteBalloon(X,Y)
{
   mouseClick, L, X,Y   
   sleep, 100
   ClickGreenButton(890,680)
   sleep, 400
   
}
deleteRowBalloons(X,Y)
{
   idx:=0
   RepeatDeleteB:
   deleteBalloon(X,Y)
   X:=X+25
   Y:=Y+12
   idx:=idx+1
   if(idx<18)
   {
      goto, RepeatDeleteB
   }
}
^!e::
;delete balloons
MouseGetPos, CurX, CurY
deleteRowBalloons(curX,CurY)
return
; FullScreen Button 1180,740


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2009, 11:27 pm 
Offline

Joined: October 2nd, 2009, 11:21 pm
Posts: 40
I can't get yehster's script to do anything let alone work. Maybe it has something to do with his apparently being coded using version 1. I'm also having troubles with imagesearch working in farmville. I've tried every syntax I can think of and the image is not being found. I'm trying to use it to click on the full screen icon. Can anyone else tell me if they are successful in getting imagesearch to work in farmville? Any help would be appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2009, 12:49 pm 
Is it possible to make soyabean delete script to work on grid of lets say 2x2 or 4x4,it would be much faster and easier when planting and removing multiple crops than doing it 1 by 1


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2009, 1:55 pm 
Offline

Joined: May 16th, 2008, 8:09 pm
Posts: 12
dmina wrote:
Is it possible to make soyabean delete script to work on grid of lets say 2x2 or 4x4,it would be much faster and easier when planting and removing multiple crops than doing it 1 by 1

Of course it is possible, but if you do that you lose the the crops you would grow on those 3 additional squares. It takes my script 5 seconds to SBD 1 square, 3 of those seconds are selecting soybean. Selecting soy bean is the part that would be sped up by doing multiples, but the max possible speed is still only going to be 2-3 seconds.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2009, 2:10 pm 
Offline

Joined: May 16th, 2008, 8:09 pm
Posts: 12
xxmarkxx wrote:
I can't get yehster's script to do anything let alone work. Maybe it has something to do with his apparently being coded using version 1. I'm also having troubles with imagesearch working in farmville. I've tried every syntax I can think of and the image is not being found. I'm trying to use it to click on the full screen icon. Can anyone else tell me if they are successful in getting imagesearch to work in farmville? Any help would be appreciated.

That version 1.x comment is auto generated by AHK when you right click and say create new AHK script. It is just a comment and is completely irrelevant.

ImageSearch is really touchy, and I'm not sure why. It works with the screen control buttons for me, but doesn't work when I try it for the accept and cancel buttons. Also, I had trouble getting the startup/search functions to work on a different machine.

You can still startup farmville and zoomout/fullscreen manually and use the harvest functions. Zynga moved the plant buttons in the market with the addition of sweet potatoes, so coordinates do not correspond anymore.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: farmville script
PostPosted: October 4th, 2009, 6:25 am 
this is my script that i currently use..

some of it is hardcoded (my farm, for instance, is 14x21 squares. ^r, ^5 farms my whole field.. for you it might be something like ^r, ^4, 20x20, click), but stuff like the selective farming (^4) will work fine for everybody.

it includes several of the scripts on this page, only modified by me..

Code:
/*
gui, add, text, ^o to open farmville
gui, add, text, ^r to set beginning view
gui, add, text, ^Left and ^Right to switch pages of seeds
gui, add, text, ^t to trap the farmer (view dependant)
gui, add, text, ^q to reload
gui, add, text,
gui, add, text, ^5 to click all
gui, add, text, ^6 to use the soybean xp
gui, add, text, ^7 to reload and click all
gui, add, text, ^8 try to harvest, plow, and plant
Gui, Show, , , , New GUI Window

*/
;^o to open farmville
;^r to set beginning view
;^Left and ^Right to switch pages of seeds
;^t to trap the farmer (view dependant)
;^q to reload

;^5 to click all
;^4 to pick field size (for mom)
;^6 to use the soybean xp
;^7 to reload and click all
;^8 try to harvest, plow, and plant
;^9 to help neighbors



^8::
CoordMode, Mouse, Screen
Run http://apps.facebook.com/onthefarm
gosub Reload
gosub Harvest
gosub Reload
gosub Plow
gosub Reload
;gosub pickplant
;eventually.. it'll have a gui. for now you just have to hurry and pick a plant. best to know what you're planting before you start
Click 924,767
msgbox 20 seconds to choose a plant. dont move the view!
sleep 20000
msgbox dont close this box till you have the plant ready to be seeded

gosub plant

msgbox Done.
reload

;-----------------------------------------------------------

Reload:
sleep 100
Click 342, 182
sleep 14000
MouseMove, 689, 660, 100
Click
MouseMove, 907, 667, 100
Click
Sleep 200
Click
Sleep 200
Click
sleep 200
MouseClickDrag, L, 521,510, 645, 520, 75
sleep 200
gosub trap
return

;-----------------------------------------------------------

pickplant:
msgbox ctrl right or ctrl left for different pages of plants
Click 924,767
InputBox, planttype
if (%planttype% := 1)
{Click 410, 560
}
if (%planttype% := 2)
{Click 550,560
}
if (%planttype% := 3)
{Click 690,560
}
if (%planttype% := 4)
{Click 830,560
}
if (%planttype% := 5)
{Click 410,755
}
if (%planttype% := 6)
{Click 550,755
}
if (%planttype% := 7)
{Click 690,755
}
if (%planttype% := 8)
{Click 830,755
}
return

;-----------------------------------------------------------

Harvest:
Click 877,707, 2
gosub Clickall
Return

;-----------------------------------------------------------

Plow:
Click 926, 707, 2
gosub Clickall
Return

;-----------------------------------------------------------

Plant:
Click 921,771
gosub clickall
Return

;-----------------------------------------------------------

Clickall:
CoordMode, Mouse, Screen
KeyWait, LButton, D
MouseGetPos, tlsx, tlsy
Click
/*
   tls is beginning mouse position
   click is where it should click next
   l is where it clicked last
*/
tlsx-=25
tlsy+=11
pass := 1
clickx := tlsx
clicky := tlsy
lx := clickx
ly := clicky
Loop, 14
{
   Loop, 17
   {   Sleep 100
       clickx := lx+25
       clicky := ly-11
       clickypo := clicky--
;       if pass = 1
;       {   
;      Click %clickx%, %clickypo%
;      pass--
;       } else {   
      Click %clickx%, %clicky%
;      pass++
;       }
       lx := clickx
       ly := clicky
   }
   lx := tlsx+25
;   if pass = 1
;       {
          ly := tlsy+11
;       } else {
;          ly := tlsy+13
;       }
   tlsx := lx
   tlsy := ly

}
MouseClickDrag left, 695,520,470,440,50
KeyWait, LButton, D
MouseGetPos, tlsx, tlsy
Click
tlsx-=25
tlsy+=11
pass := 1
clickx := tlsx
clicky := tlsy
lx := clickx
ly := clicky
Loop, 6
{
   Loop, 17
   {   Sleep 100
       clickx := lx+25
       clicky := ly-11
       clickypo := clicky--
;       if pass = 1
;       {   
;      Click %clickx%, %clickypo%
;      pass--
;       } else {   
      Click %clickx%, %clicky%
;      pass++
;       }
       lx := clickx
       ly := clicky
   }
   lx := tlsx+25
;   if pass = 1
;       {
          ly := tlsy+11
;       } else {
;          ly := tlsy+13
;       }
   tlsx := lx
   tlsy := ly

}
return
return

;-----------------------------------------------------------

^6::
gosub Market
gosub Buysoybean
gosub getlocationplot
sleep 1000
click %asoX%, %asoY%
sleep 1000
click %mezoX%, %mezoY%
sleep 1000
gosub accept
msgbox, The script will run until you stop it with control+q.
inputbox,xp,xp,xp,,100,150
gosub soybeanLOOP
msgbox, %xp%*3 All Done!
return
Market:
msgbox, [Market]
KeyWait, LButton, D
KeyWait, LButton, D
mousegetpos, shopX, ShopY
sleep 100
powlX:=shopX
powlY:=shopY-55
powltoolY:=powlY-70
multiX:=powlX-46
multiY:=powlY
asoX:=powlX+45
asoY:=powlY
return
Buysoybean:
msgbox, Soybeans [BUY]
KeyWait, LButton, D
KeyWait, LButton, D
mousegetpos, soybeX, soybeY
sleep 200
return
getlocationplot:
msgbox, click on the bottom corner of the farm plot you want to use.
KeyWait, LButton, D
KeyWait, LButton, D
mousegetpos, mezoX, mezoY
sleep 100
return
accept:
msgbox [Accept]
KeyWait, LButton, D
KeyWait, LButton, D
mousegetpos, asoOKX, AsoOKY
sleep 200
return
soybeanLoop:
Loop %xp%
{
click %powlX%, %PowlY%
sleep 800
click %powlx%, %powltoolY%
sleep 800
click %mezoX%, %mezoY%
sleep 800
click %shopX%, %shopY%
sleep 1800
click %soybeX%, %soyBEY%
sleep 500
click %mezoX%, %mezoY%
sleep 800
click %asoX%, %asoY%
sleep 800
click %mezoX% , %mezoY%
sleep 1050
click %asoOKX%, %asoOKY%
}
WinClose
return

;-----------------------------------------------------------

^9::
neighborLoop:
Loop 500
{
sleep 5000
click 425, 187
sleep 11500
Mousemove 655, 320
click 655, 320
sleep 28000
Mousemove 550, 475, 100
Click 550, 475, 2
}
WinKill, ahk_class Chrome_WidgetWin_0, FarmVille,300
return

;-----------------------------------------------------------

^Left::
CoordMode, Mouse, Screen
Click 285, 540
winactivate, asdf.ahk
return

^Right::
CoordMode, Mouse, Screen
Click 950, 540
winactivate, asdf.ahk
return

;-----------------------------------------------------------

^t::
gosub trap
return

trap:
Click 708, 331
sleep 400
Click 713, 358
Sleep 400
Click 752, 350
Sleep 400
Click 788, 321
;moves the guy and waits to walk
Sleep 11000
Click 753, 343
Sleep 400
Click 757, 377
Sleep 400
Click 723, 343
Sleep 400
return
;-----------------------------------------------------------

^5::
gosub clickall
return

^7::
gosub Reload
gosub clickall
return

^o::
Run http://apps.facebook.com/onthefarm
gosub Reload
return

^r::
gosub reload
return

^q::
exit:
msgbox restarting
reload

;



^4::
gosub selectfarming
return
selectfarming:
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
CoordMode, Mouse, Screen
KeyWait, LButton, D
MouseGetPos, tlsx, tlsy
Click
/*
   tls is beginning mouse position
   click is where it should click next
   l is where it clicked last
*/
tlsx-=25
tlsy+=11
pass := 1
clickx := tlsx
clicky := tlsy
lx := clickx
ly := clicky
Loop, %farmy%
{
   Loop, %farmx%
   {   Sleep 100
       clickx := lx+25
       clicky := ly-11
       clickypo := clicky--
;       if pass = 1
;       {   
;      Click %clickx%, %clickypo%
;      pass--
;       } else {   
      Click %clickx%, %clicky%
;      pass++
;       }
       lx := clickx
       ly := clicky
   }
   lx := tlsx+25
;   if pass = 1
;       {
          ly := tlsy+11
;       } else {
;          ly := tlsy+13
;       }
   tlsx := lx
   tlsy := ly

}
return



you might notice the gui portion is commented out.. i cant seem to get it to show anything.. so its gonna be put on hold for now. if you wanna help, i'd like to have the gui always on top, on the right hand side of the farmville screen (around 1040x225 for me on a 1440x900 screen)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2009, 7:20 am 
Offline

Joined: May 16th, 2008, 8:09 pm
Posts: 12
tcaruth wrote:
you might notice the gui portion is commented out.. i cant seem to get it to show anything.. so its gonna be put on hold for now. if you wanna help, i'd like to have the gui always on top, on the right hand side of the farmville screen (around 1040x225 for me on a 1440x900 screen)



Code:
Gui, Show, x1040 y225
WinSet, AlwaysOnTop, On

Try this for the gui


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, 6, 7, 8 ... 10  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 54 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