Sign in to follow this  
Followers 0
CyNDeR

Error Using script.

1 post in this topic

I've been using a bot for an application on myspace, and after a few hours working fine, i get an error message saying "Out of Memory Line #". The script is:

#include <GUIConstants.au3>
#include <IE.au3>
#Include <Misc.au3>
#include <Date.au3>
#include <Array.au3>

Global $AMPM, $aSplit, $iCHK, $iCTime, $iPid
Global $Button2, $Button3, $pets, $oIE, $site, $file, $usegui
Global $otherlvldif

iniload()

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()
If $usegui = 1 Then
    Opt("GUIOnEventMode", 1)
    $pets = GUICreate("Pet Me", 900, 584, _
            (@DesktopWidth - 1279) / 2, (@DesktopHeight - 797) / 2, _
            $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
    $GUIActiveX = GUICtrlCreateObj($oIE, 5, 4, 730, 576)
    $Button1 = GUICtrlCreateButton("Start", 768, 495, 110, 25, 0)
    GUICtrlSetOnEvent(-1, "Start")
    $Button2 = GUICtrlCreateButton("Pause", 768, 525, 110, 25, 0)
    GUICtrlSetOnEvent(-1, "Stop")
    $Button3 = GUICtrlCreateButton("Close", 768, 555, 110, 25, 0)
    GUICtrlSetOnEvent($Button3, "Terminate")
    $iCTime = GUICtrlCreateLabel('Current Time' & @CRLF & _GetHour(@HOUR) & ':' & @MIN & ':' & @SEC & ' ' & $AMPM _
            , 776, 10, 80, 37, 0x01, BitOR($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate", $pets)
    GUISetState()
EndIf

_IENavigate($oIE, $site)

Stop()

Func Stop()
    While 1
        Sleep(100)
    WEnd
EndFunc  ;==>Stop
Func Terminate();Terminates the script
    Exit 0
EndFunc  ;==>Terminate
Func Start();This is where all the core functions a called in an eternal loop
    If $usegui <> 1 Then
        $oIE = _IEAttach("Pet me")
    EndIf
    Opt("GUIOnEventMode", 1)
    _IELoadWait($oIE)
    $sText = _IEPropertyGet($oIE, "innertext")

    While 1 = 1
        If StringRegExp($sText, 'Pet not showing up on your profile page?') = 0 Then
            _IELoadWait($oIE)
            Feed()
            _IELoadWait($oIE)
            KillMonster()
            _IELoadWait($oIE)
            FightOrEvade()
            _IELoadWait($oIE)
            Fight()
            _IELoadWait($oIE)
        Else
            If StringRegExp($sText, 'You are currently fighting a') = 0 Then

                _IELinkClickByIndex($oIE, 0)
                _IELoadWait($oIE)
                KillMonster()
                _IELoadWait($oIE)
                Fight()
                _IELoadWait($oIE)
            Else
                _IELoadWait($oIE)
                KillMonster()
                _IELoadWait($oIE)
                Fight()
                _IELoadWait($oIE)
            EndIf
        EndIf

        If $usegui <> 1 Then
            $oIE = _IEAttach("Pet me")
        EndIf
        $sText = _IEPropertyGet($oIE, "innertext")
    WEnd
EndFunc  ;==>Start
Func FightOrEvade()
    If $usegui <> 1 Then
        $oIE = _IEAttach("Pet me")
    EndIf
    $sText = _IEPropertyGet($oIE, "innertext")
    Dim $iEnemyLvl, $iEnemyName
    Dim $iPetLvl

    If StringRegExp($sText, 'You are currently fighting a ') = 0 Then
    ; This loop keeps on going until a monster is chosen to be fought.
    ;A monster can only be an Ant and can only be 1 lvl higher
        $while = 0
        While $while = 0
        ;This is where the decision begins
            If $usegui <> 1 Then
                $oIE = _IEAttach("Pet me")
            EndIf
            $sText = _IEPropertyGet($oIE, "innertext")
            $oTextTable = StringSplit(_IEPropertyGet($oIE, "innertext"), " ")
            $oPetName = $oTextTable[1]

        ;this is the only way i found to be able to get a
        ;specific text string (the levels) from the web page
            For $i = 2 To $oTextTable[0]
                If StringRegExp($oTextTable[$i], 'Level') Then
                    If StringRegExp($oTextTable[$i - 2], 'encountered') = 0 Then
                        If StringRegExp($oTextTable[$i - 1], $oPetName) = 0 Then
                            $iEnemyLvl = $oTextTable[$i + 1]
                            $iEnemyName = $oTextTable[$i + 2]
                            $iPetLvl = $oTextTable[$i + 5]
                        EndIf
                    EndIf
                EndIf
            Next

            $iLvlDiff = $iPetLvl - $iEnemyLvl
            If $iLvlDiff >= IniRead('zarox.ini', 'fight', $iEnemyName, $otherlvldif) Then
                $while = 1
            ;this is how i choose a specific button from the page
                $oForms = _IEFormGetCollection($oIE, 0)
                $oElement = _IEFormElementGetCollection($oForms, 4)

                _IELoadWait($oIE)
                _IEAction($oElement, "click")
                _IELoadWait($oIE)

                If $usegui <> 1 Then
                    $oIE = _IEAttach("Pet me")
                EndIf
                $sText = _IEPropertyGet($oIE, "innertext")
            Else
            ;this is how i choose a specific button from the page
                $oForms = _IEFormGetCollection($oIE, 1)
                $oElement = _IEFormElementGetCollection($oForms, 2)

                _IELoadWait($oIE)
                _IEAction($oElement, "click")
                _IELoadWait($oIE)

                If $usegui <> 1 Then
                    $oIE = _IEAttach("Pet me")
                EndIf
                $sText = _IEPropertyGet($oIE, "innertext")
            EndIf
        WEnd
    EndIf
EndFunc  ;==>FightOrEvade
Func Feed();Feeds until energy is full
    iniload()
    If $usegui <> 1 Then
        $oIE = _IEAttach("Pet me")
    EndIf
    $sText = _IEPropertyGet($oIE, "innertext")
    While StringRegExp($sText, 'Your pet has full hit points, no need to eat ') = 0
    ;this is how i choose a specific button from the page
        $oForms = _IEFormGetCollection($oIE, 1)
        $oElement = _IEFormElementGetCollection($oForms, 3)
        _IELoadWait($oIE)
        _IEAction($oElement, "click")

        If StringRegExp($sText, 'You are currently fighting a ') Then ExitLoop
        $sText = _IEPropertyGet($oIE, "innertext")
    WEnd
EndFunc  ;==>Feed
Func KillMonster();Click on the Kill monster button from the main page
    If $usegui <> 1 Then
        $oIE = _IEAttach("Pet me")
    EndIf
    $oForms = _IEFormGetCollection($oIE, 3)
    $oElement = _IEFormElementGetCollection($oForms, 0)
    _IELoadWait($oIE)
    _IEAction($oElement, "click")
    _IELoadWait($oIE)
EndFunc  ;==>KillMonster
Func Fight();Fights until monster dies than loots Losing a battle is not an option...

    If $usegui <> 1 Then
        $oIE = _IEAttach("Pet me")
    EndIf
    $sText = _IEPropertyGet($oIE, "innertext")
    While StringRegExp($sText, 'You have killed a|Pet not showing up|You have died') = 0

    ;this is how i choose a specific button from the page
        $oForms = _IEFormGetCollection($oIE, 0)
        $oElement = _IEFormElementGetCollection($oForms, 0)
        _IEAction($oElement, "click")

        If StringRegExp($sText, 'Pet not showing up on your profile page?') Then ExitLoop
        If StringRegExp($sText, 'You have died') Then ExitLoop
        $sText = _IEPropertyGet($oIE, "innertext")
    WEnd

;wait untill the page loads before click loot
    _IELoadWait($oIE)

    If StringRegExp($sText, 'You have killed a') Then
    ;this is how i choose a specific button from the page
        $oForms = _IEFormGetCollection($oIE, 0)
        $oElement = _IEFormElementGetCollection($oForms, 4)
        _IELoadWait($oIE)
        _IEAction($oElement, "click")
        _IELoadWait($oIE)
    ElseIf StringRegExp($sText, 'Pet not showing up') Then
        _IELinkClickByIndex($oIE, 0)
        _IELoadWait($oIE)
        KillMonster()
        _IELoadWait($oIE)
        Fight()
        _IELoadWait($oIE)
    EndIf

    If StringRegExp($sText, 'You have died') Then
        $oForms = _IEFormGetCollection($oIE, 0)
        $oElement = _IEFormElementGetCollection($oForms, 4)
        _IELoadWait($oIE)
        _IEAction($oElement, "click")
        _IELoadWait($oIE)
    EndIf
EndFunc  ;==>Fight
Func _AdlibManager()
    Local $aSplit = StringSplit(GUICtrlRead($iCTime), ':')
    If $aSplit[0] >= 3 And (Int($aSplit[1]) >= _GetHour(@HOUR) _
            Or Int($aSplit[2]) >= @MIN Or Int(StringTrimRight($aSplit[3], 3)) > @SEC) Then _
            GUICtrlSetData($iCTime, 'Current Time' & @CRLF & _GetHour(@HOUR) & ':' & @MIN & ':' & @SEC & ' ' & $AMPM)
EndFunc  ;==>_AdlibManager
Func _GetHour($iHour)
    Switch $iHour
        Case 12
            $AMPM = 'PM'
            Return $iHour
        Case 13 To 23
            $AMPM = 'PM'
            Return $iHour - 12
        Case 0
            $AMPM = 'AM'
            Return 12
        Case 1 To 11
            $AMPM = 'AM'
            Return $iHour
    EndSwitch
EndFunc  ;==>_GetHour
Func _SwitchHour($iHour)
    Switch $iHour
        Case 12
            If $AMPM = 'AM' Then
                Return 0
            Else
                Return 12
            EndIf
        Case 1 To 11
            If $AMPM = 'PM' Then
                Return $iHour + 12
            Else
                Return $iHour
            EndIf
    EndSwitch
EndFunc  ;==>_SwitchHour
Func iniload()
;Keys
    $usehotkeys = IniRead("zarox.ini", "keys", "usehotkeys", "1")
;Fight
    $otherlvldif = IniRead("zarox.ini", "fight", "leveldifference", "2")
;Other
    $site = IniRead("zarox.ini", "other", "petlink", "http://www.facebook.com")
    $usegui = IniRead("zarox.ini", "other", "usegui", "0")

    If $usehotkeys = 1 Then
        $endkey = IniRead("zarox.ini", "keys", "closekey", "")
        HotKeySet($endkey, "Terminate")
        $startkey = IniRead("zarox.ini", "keys", "startkey", "")
        HotKeySet($startkey, "Start")
        $pausekey = IniRead("zarox.ini", "keys", "pausekey", "")
        HotKeySet($pausekey, "Stop")
    EndIf
EndFunc  ;==>iniload

What causes it, and is there a way to fix it?


My scripts: Random Painter

Share this post


Link to post
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
Sign in to follow this  
Followers 0