Jump to content

Easy Script


Recommended Posts

Hi, im very new in AutoIt. I downloaded a script and modified anything, but now I have a problem...

Func CheckMyFarm()
    ClickImage($farmDir,"myfarm")
    Sleep(1000)
    Do
        Sleep(100)
    Until ClickImage($farmDir,"stealplant") = False
    Do
        Sleep(100)
    Until ClickImage($farmDir,"exterminateplant") = False
    Do
        Sleep(100)
    Until ClickImage($farmDir,"weedplant") = False
EndFunc

Func CheckForSteals()
    If $stealCrops = False Then
        Return
    EndIf
    If ClickImage($farmDir,"stealfriend") Then
        Do
            Sleep(100)
        Until ClickImage($farmDir,"stealplant") = False
    EndIf
EndFunc

Func CheckForRecharges()
    If $rechargeTrees = False Then
        Return
    EndIf
    If ClickImage($farmDir,"rechargefriend") Then
        Do
            Sleep(100)
        Until ClickImage($farmDir,"treeofancients") = False
    EndIf
EndFunc

Func NextPage()
    If $pageNumber < $numberOfPages Then
        $pageNumber += 1
        ClickImage($farmDir,"nextpage")
    Else
        $pageNumber = 1
        ClickImage($farmDir,"firstpage")
    EndIf
EndFunc

Func FriendsWithNeeds()
    If $stealCrops And CheckFor($farmDir,"stealfriend") Then
        Return True
    ElseIf $rechargeTrees And CheckFor($farmDir,"rechargefriend") Then
        Return True
    Else
        Return False
    EndIf
EndFunc

Func RunScript()
    ;Main script activated by hotkey
    CheckFor($farmDir,"farmsign")
    While 1
        If $pageNumber = 1 Then
            CheckMyFarm()
        EndIf
        While FriendsWithNeeds()
            CheckForSteals()
            CheckForRecharges()
            CheckForRevives()
            CheckForExterminates()
            CheckForWeeds()
        WEnd
        NextPage()
    WEnd
EndFunc

Thats now the Original code and I want... That he run the main script, acter he did his $pageNumber he shouldnt click "firstpage", but next Account/Browser and then first page... I need it for 4 Accounts, so after 2nd he shall click 3rd accound and first page, after last account he shall click again 1st account and "firstpage".

I tried now any kinds in main function and Func NextPage() but rly havent an idea what I can do.. 1 Problem I think is, he cant find the browser-picture in the taskbar, tried some codes that he should click on a other browser but dont did that.. Here are the codes for the ImageSearch functions and there is an imagesearch.au3 included.. How i understood it begin with the search from 0,0 to the end of desktop hight/width..

Func CheckFor($directory,$img,$tolerance=50,$startX=0,$startY=0,$endX=@DesktopWidth,$endY=@DesktopHeight,$seconds=$defaultCheckRate)
    $c = 0
    MouseMove($sX,$sY,0)
    $string = $bmpLocation & "\" & $directory & "\" & $img & ".bmp"
    $updateString = $img
    ToolTip("Checking for " & $updateString,0,0)
    $tolerance = 70
    If $tolFail > 0 Then
        $tolerance += $tolFail
    EndIf
    Do
        $c += 1
        Sleep(100)
        If $c > ($seconds * 10) Then
            Return False
        EndIf
    ;Until _ImageSearchArea($string,1,$startX,$startY,$endX,$endY,$gX,$gY,$tolerance)
    Until _ImageSearchArea($string,1,216,180,1723,1002,$gX,$gY,$tolerance)
    If $img = "farmsign" Then
        $sX = $gX
        $sY = $gY
    EndIf
    Sleep(500)
    Return True
EndFunc

Func ClickImage($directory,$img,$tolerance=50,$startX=0,$startY=0,$endX=@DesktopWidth,$endY=@DesktopHeight,$seconds=$defaultCheckRate)
    If CheckFor($directory,$img,$tolerance,$startX,$startY,$endX,$endY,$seconds) Then
        MouseClick("left",$gX,$gY,1,0)
        Return True
    Else
        Return False
    EndIf
EndFunc

Func HoverOverImage($directory,$img,$tolerance=50,$startX=0,$startY=0,$endX=@DesktopWidth,$endY=@DesktopHeight,$seconds=$defaultCheckRate)
    If CheckFor($directory,$img,$startX,$startY,$endX,$endY,$seconds,$tolerance) Then
        MouseMove($gX,$gY,0)
        Sleep(2000)
        Return True
    Else
        Return False
    EndIf
EndFunc

I dont think it's that much hard, but like I said Im new in this and need to learn it and it would be nice if some1 can help me and give me one or more codes how it can work and I will ask then what I dont understand :D

Btw. Sorry for my bad english haha

 

Link to comment
Share on other sites

  • Moderators

MrShady187,

Welcome to the AutoIt forum. :)

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now (there is also a link at bottom right of each page) - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

Furthermore, please pay attention to where you post - the "Developer Chat" section where you started this thread is not for general support questions. I would ask you to be more careful in future. ;)

See you soon with a legitimate question I hope. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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