Jump to content

AutoIt script assistance


Recommended Posts

Looking for some assistance with this script.

I realise in a different post I made that I came off as someone wanting people to complete the entire thing without me doing any work.

AKA - an asshole that annoys a lot of people.

If you see as that person, give me another shot =-)

I worked on this so hopefully you wont just blow me off.

I am completely new with autoit, so when I have the "NEED HELP" on lines, it is because I honestly do not know what to solution is.

I have used the AutoIt Help and while it is a great tool I have not been able to find some solutions or applicable examples.

Seeing that facebook is so common - you may have it and perhaps you would be willing to check out the "Farm Town" app. to see what I am trying to do.

The program is suppose to buy a haybail, place it. Then sell the haybail and repeat until the loop finishes. (This isn't really an "online" game in the sense that you're not really competing in the same way.)

Any help you can give would be greatly appreciated. I'm not looking for a "look in the help guide more" so please respect that.

Opt("WinWaitDelay",3000)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)

#include <IE.au3>

; declare variable color (use Eyedropper4.0 to find color,
; keep 0x and add your 6 digit number after it)
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

; declare ON true(on) false(off)
Global $ON = False

; set esc and pause
HotKeySet("{ESC}", "Terminate")
HotKeySet("{PAUSE}", "TogglePause")

; Pop-up dialog box to start program
MsgBox(0,"IMPORTANT", "Login to facebook prior to clicking 'OK'")
MsgBox(1,"Holybails", "'OK' to start, press 'ESC' to stop.")

; 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

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('HolyBails is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

If ($CmdLine[11] = 2) Then
    Exit 0
EndIf

If ($CmdLine[11] = 1) Then 
; Open url to play FarmTown
    _IECreate ("http://apps.facebook.com/farmtown/play/", 1, 1, 1, 1)
    $ON = True
; main loop
    While 1=1
    Sleep(500)
        if $ON = True Then
            
        ; start pixel search for store icon
            $coord1 = PixelSearch(0,0,1000,1000, $storeIconColor,0)
            If IsArray($coord1) = 1 Then
            ; save coords as 'storeCoords'
                $storeCoords = ($coord1[0],$coord1[1])
                
            ; click store icon - NEED HELP
            
        ; Error msg
            Else MsgBox(0,"ERROR","Unable to find Store icon "
                        "edit your '$storeIconColor'")
            EndIf
            
        ; start somesort of search to find the 'other' tab - NEED HELP
            $coord2 = 
            If IsArray($coord2) = 1 Then
            ; save coords as 'otherCoords'
                $otherCoords = ($coord2[0],$coord2[1])
                
            ; click 'other' tab - NEED HELP
            
        ; Error msg
            Else MsgBox(0,"ERROR","Unable to find '$otherCoords'")
            EndIf
            
        ; start pixel search for haybail icon
            $coord3 = PixelSearch(0,0,500,500, $hayBailColor,0)
            If IsArray($coord3) = 1 Then
            ; save coords as 'buyHayBailCoords'
                $buyHayBailCoords = ($coord3[0],$coord3[1])
                
            ; click haybail icon - NEED HELP
    
        ; Error msg
            Else MsgBox(0,"ERROR","Unable to find HailBail " 
                        "edit your '$haybailColor'")
            EndIf
            
        ; start pixel search for grass color
            $coord4 = PixelSearch(0,0,500,500, $grassColor,0)
            If IsArray($coord4) = 1 Then
            ; save coords as 'placeHayBailCoords'
                $placeHayBailCoords = ($coord4[0],$coord4[1])
                
            ; click grass - NEED HELP
            ; need to click in the same spot 
            ; slightly after first click (2x total)
            
        ; Error msg
            Else MsgBox(0,"ERROR","Unable to find Grass " 
                        "edit your '$grassColor'")
            EndIf
            
        ; start somesort of search to find the 'sell' tab - NEED HELP
            $coord5 = 
            If IsArray($coord5) = 1 Then
            ; save coords as 'confirmSellCoords'
                MouseMove($coord5[0],$coord5[1])
                
            ; click sell - NEED HELP
                
            ; Error msg
            Else MsgBox(0,"ERROR","Unable to find 'confirmSellCoords'")
            EndIf
        EndIf
        1++
    WEnd
    
    While $bailsTobuy -1 >= 1
        
    ; NEED HELP with the following
        
    ; click at $storeCoords
    ; click at $buyHayBailCoords 
    ; click at $placeHayBailCoords
    ; click at $sellHayBailCoords
    ; click at $confirmSellCoords
        1++
    WEnd
EndIf
Edited by meowbits
Link to comment
Share on other sites

If ($CmdLine[0] = 2) Then


    Exit 0
EndIf

If ($CmdLine[0] = 1) Then
...

;  click at $storeCoords

MouseClick("left", $storeCoords[0], $storeCoords[1])
Thanks, this is a browser game, so will the "mouseClick" work still?
Link to comment
Share on other sites

  • Moderators

1. You're posting in the support forum. I think AutoIt Assistance is a given... doesn't make sense to be a title. Titles should be specific for two reasons, 1... so people don't waste their time, 2... you'll get more qualified answers from people that actually know what they're talking about. The fact that a MVP actually replied to such a useless topic amazes me a bit.

2. Rather than asking the question (will it work still), why not take a "few" minutes out of your time to test it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

1. You're posting in the support forum. I think AutoIt Assistance is a given... doesn't make sense to be a title. Titles should be specific for two reasons, 1... so people don't waste their time, 2... you'll get more qualified answers from people that actually know what they're talking about. The fact that a MVP actually replied to such a useless topic amazes me a bit.

2. Rather than asking the question (will it work still), why not take a "few" minutes out of your time to test it.

Multiple errors, assuming it will work still doesn't help because there are other errors in the way. I like how you took the time to reply with all of that instead of a yes/no so I could perhaps cross it off a list. Appreciated lol.

Link to comment
Share on other sites

  • 2 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...