Jump to content

Script stop after some hours


Recommended Posts

I tried to make a simple macro clicker based on pixelcolor but I got some problem. Can someone fix this script for me? The script run well but after some hours it will usually stop/quit with the error 'Recursion level has been exceeded - AutoIt will quit to prevent stack overflow'. This happens mostly on the lines with the sleep commands.

Script

;~ #include <NomadMemory.au3>
;~ #include <GUIConstants.au3>
;~ #Include <MouseClickPlus.au3>

Opt("CaretCoordMode", 0) ;1=absolute, 0=relative, 2=client
Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client
Opt("PixelCoordMode", 0) ;1=absolute, 0=relative, 2=client

;Unfreeze
;~ Global $unfreeze_addr = 0x00A45EFD

;Game Windowname
Global $APP_TITLE = "FiReFoX"

;Inventory
Global $X[6] = [968, 968 + 39, 968 + 78, 968 + 117, 968 + 156, 968 + 195]
Global $Y1 = 309
Global $Y2 = 309 + 39
Global $Y3 = 309 + 78
Global $Y4 = 309 + 117
Global $Y5 = 309 + 156
Global $Y6 = 309 + 195
Global $Y7 = 309 + 234
Global $Y8 = 309 + 273
;Lottery Pixel Color FirstSlot ;;;;;; Change this for different lottery
Global $ILX = 971
Global $ILY = 306
Global $ILC = 0xF7B210
;Inventory Scroll Middle and Pixel
Global $ISX = 1189
Global $ISY = 443
Global $ISC = 0x686868
;Inventory Scroll Top and Pixel
Global $ISX2 = 1189
Global $ISY2 = 306
Global $ISC2 = 0x686868
;Inventory Sort Button and Pixel
Global $ISBX = 1076
Global $ISBY = 609
Global $ISBC = 0xFFEFDB
;Jackpot Button
Global $JX = 637
Global $JY = 526
;Jackpot Button Donel PixelColor
Global $JDX = 642
Global $JDY = 532
Global $JDC = 0xA6A6A6
;NPC SELL
Global $NX = 160
Global $NY = 452
Global $NC = 0x415879
;Mall
;Review Button
Global $MRX = 572
Global $MRY = 208
;Scrollbar
Global $MSX = 1141
Global $MSY = 667
;Buy Button ;;;;;; Change this for different lottery
Global $MBX = 559
Global $MBY = 666
;Lottery Pixel Color ;;;;;; Change this for different lottery
Global $MLX = 438
Global $MLY = 612
Global $MLC = 0xD9D7EA

;~ Disconnected
Global $DCX = 650
Global $DCY = 459
Global $DCC = 0xFFFFFF

;~ Global $zhwnd = WinGetHandle("[CLASS:ZElementClient Window]")
;~ Global $pid = ProcessExists("elementclient.exe")
;~ Global $openmem = _MemoryOpen($pid)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

If Not WinActive($APP_TITLE, "") Then WinActivate($APP_TITLE, "")
WinMove($APP_TITLE, "", 0, 0, 1296, 838, 2)
HotKeySet("{F10}", "Start")
HotKeySet("{F11}", "Stop")

Wait()

Func Start()
    If Not WinActive($APP_TITLE, "") Then WinActivate($APP_TITLE, "")
    if (PixelGetColor($ILX, $ILY) <> $ILC) Then
        Sleep(500)
        Start()
    elseif (PixelGetColor($ILX, $ILY) == $ILC) Then
        ;Main Script Here
        For $main = 2 To 1 Step -1
            Do
                Sleep(250)
            Until (PixelGetColor($ILX, $ILY) == $ILC)

            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 1 START
            $r1 = 0
            For $r1 = 0 To 5
                Do
                    Sleep(500)
                Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
                MouseClick("right", $X[$r1], $Y1, 2, 1)
                Sleep(250)
                Do
                    MouseClick("left", $JX, $JY, 2, 1)
                    Sleep(250)
                Until (PixelGetColor($JDX, $JDY) == $JDC)
            Next
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 1 END

            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 2 START
            $r2 = 0
            For $r2 = 0 To 5
                Do
                    Sleep(500)
                Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
                MouseClick("right", $X[$r2], $Y2, 2, 1)
                Sleep(250)
                Do
                    MouseClick("left", $JX, $JY, 2, 1)
                    Sleep(250)
                Until (PixelGetColor($JDX, $JDY) == $JDC)
            Next
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 2 END

            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 3 START
            $r3 = 0
            For $r3 = 0 To 5
                Do
                    Sleep(500)
                Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
                MouseClick("right", $X[$r3], $Y3, 2, 1)
                Sleep(250)
                Do
                    MouseClick("left", $JX, $JY, 2, 1)
                    Sleep(250)
                Until (PixelGetColor($JDX, $JDY) == $JDC)
            Next
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 3 END

            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 4 START
            $r4 = 0
            For $r4 = 0 To 5
                Do
                    Sleep(500)
                Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
                MouseClick("right", $X[$r4], $Y4, 2, 1)
                Sleep(250)
                Do
                    MouseClick("left", $JX, $JY, 2, 1)
                    Sleep(250)
                Until (PixelGetColor($JDX, $JDY) == $JDC)
            Next
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 4 END

            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 5 START
            $r5 = 0
            For $r5 = 0 To 5
                Do
                    Sleep(500)
                Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
                MouseClick("right", $X[$r5], $Y5, 2, 1)
                Sleep(250)
                Do
                    MouseClick("left", $JX, $JY, 2, 1)
                    Sleep(250)
                Until (PixelGetColor($JDX, $JDY) == $JDC)
            Next
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 5 END

            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 6 START
            $r6 = 0
            For $r6 = 0 To 5
                Do
                    Sleep(500)
                Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
                MouseClick("right", $X[$r6], $Y6, 2, 1)
                Sleep(250)
                Do
                    MouseClick("left", $JX, $JY, 2, 1)
                    Sleep(250)
                Until (PixelGetColor($JDX, $JDY) == $JDC)
            Next
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 6 END

            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 7 START
            $r7 = 0
            For $r7 = 0 To 5
                Do
                    Sleep(500)
                Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
                MouseClick("right", $X[$r7], $Y7, 2, 1)
                Sleep(250)
                Do
                    MouseClick("left", $JX, $JY, 2, 1)
                    Sleep(250)
                Until (PixelGetColor($JDX, $JDY) == $JDC)
            Next
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 7 END

            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 8 START
            $r8 = 0
            For $r8 = 0 To 5
                Do
                    Sleep(500)
                Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
                MouseClick("right", $X[$r8], $Y8, 2, 1)
                Sleep(250)
                Do
                    MouseClick("left", $JX, $JY, 2, 1)
                    Sleep(250)
                Until (PixelGetColor($JDX, $JDY) == $JDC)
            Next
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ROW 8 END
            Do
                MouseClick("left", $ISX, $ISY, 2, 1)
                Sleep(250)
            Until (PixelGetColor($ISX, $ISY) == $ISC)
        Next
        mall()
    EndIf
EndFunc   ;==>Start

Func sort()
    If Not WinActive($APP_TITLE, "") Then WinActivate($APP_TITLE, "")
    Do
        Sleep(250)
    Until (PixelGetColor($ISBX, $ISBY) == $ISBC)
    MouseClick("left", $ISBX, $ISBY, 1, 1)
    Start()
EndFunc   ;==>sort

Func mall()
    Do
        Sleep(500)
    Until (PixelGetColor($NX, $NY) <> $NC) ;check selling npc
    Sleep(250)
    Send("j")
    Sleep(250)
    MouseClick("left", $MRX, $MRY, 2, 1) ;review
    Sleep(250)
    Do
        MouseClick("left", $MSX, $MSY, 2, 1) ;scrollbar
        Sleep(250)
    Until (PixelGetColor($MLX, $MLY) == $MLC)
    MouseClick("left", $MBX, $MBY, 2, 1) ;buy
    Send("{BACKSPACE}")
    Sleep(250)
    Send("96")
    Send("{Enter}")
    Sleep(250)
    Send("j")
    Do
        MouseClick("left", $ISX2, $ISY2, 2, 1)
        Sleep(250)
    Until (PixelGetColor($ISX2, $ISY2) == $ISC2)
    Sleep(250)
    If (PixelGetColor($ILX, $ILY) == $ILC) Then
        Start()
    ElseIf (PixelGetColor($ILX, $ILY) <> $ILC) Then
        sort()
    EndIf
EndFunc   ;==>mall


Func Wait()
    While 1
        Sleep(250)
    WEnd
EndFunc   ;==>Wait

Func Stop()
    Exit
EndFunc   ;==>Stop

Thanks you.

Link to comment
Share on other sites

  • Moderators

BitByte,

You can fix your own bot - but I will give you a hint about what is going wrong. :party:

Look at this small portion of your code:

Func Start()
    If Not WinActive($APP_TITLE, "") Then WinActivate($APP_TITLE, "")
    if (PixelGetColor($ILX, $ILY) <> $ILC) Then
        Sleep(500)
        Start()

When the condition is met, you call the function from within itself - this is called recursion. Most programmers avoid recursion like the plague if they can - and if they cannot, then they take very great care to undo the recursion levels as quickly as possible.

This is why you are getting the "Recursion level has been exceeded" error - AutoIt can only cope with 5100 such calls before deciding enough is enough. Bsically you will crash the sytem if you go on for too long. :P

You need to rewrite your code so that you do not call your function recursively - but as it is a bot, that is as much help as I am going to give. Have fun! :mellow:

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

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...