Jump to content

Arrays in AutoIt confuse me


bundyxc
 Share

Recommended Posts

So, I'm having an issue. The beginning of my code sets a global array variable, and immediately afterward it displays a message box of $status[$i] (where $status is my array, and $i is the array index).

If I were to open a MsgBox() after said-code, it will open, displaying the correct string. However, I'm implementing this into a GUI, and it must randomize $i each time the "Start" button on my GUI is pressed. However, if I try to display $status[$i] further down in the code, it gives an error:

C:\Users\Christian Bundy\Desktop\2pointoh.au3 (91) : ==> Subscript used with non-Array variable.:

MsgBox(0, $i, $status[$i])

MsgBox(0, $i, $status^ ERROR

Full code:

#include <GUIConstants.au3>
#include <IE.au3>
#include <UnixTime.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <String.au3>
#include <INet.au3>
#RequireAdmin
;#NoTrayIcon



Global $next_update = 999999999999999999999999999999999
Global $last_update = 0
Global $go = 0
Global $anti_flood = 1
Global $min = 1 * 60000
Global $max = 1 * 60000

Global $status[10]
$status[0] = "Yippee, status number.. zero?"
$status[1] = "Yippee, status number one!"
$status[2] = "Yippee, status number twizzle!"
$status[3] = "Yippee, status number thr33!"
$status[4] = "Yippee, status number 4our!"
$status[5] = "Yippee, status number 5ive!"
$status[6] = "Yippee, status number s!x1"
$status[7] = "Yippee, status number s7v7n!"
$status[8] = "Yippee, status number ate!"
$status[9] = "Yippee, status number one!"
$i = 1
MsgBox(0, $i, $status[$i])

DirCreate(@ProgramFilesDir & "\PureStatus")

Opt("TrayMenuMode",1)
$text = 'Idle'
$progress = 0
$email = "myspaceee@slopsbox.com"
$password = "AutoIt!"
$status = "Can you do the thizzle dance?"
$mood = "Thizzin'"


$GUI = GUICreate("PureStatus - Status Update Bot", 528, 400) ; 528, 210
$oIE = ObjCreate("Shell.Explorer.2")
$oIE.visible = 1
$oIE_control = GUICtrlCreateObj($oIE, 16, 210, 496, 180)
$log = GUICtrlCreateEdit($text, 16, 10, 240, 150, 0x00200800)
$start_stop_button = GUICtrlCreateButton("Start", 264, 10, 240, 30)
$accounts_button = GUICtrlCreateButton("Accounts", 264, 50, 240, 30)
$statuses_button = GUICtrlCreateButton("Statuses", 264, 90, 240, 30)
$settings_button = GUICtrlCreateButton("Settings", 264, 130, 240, 30)
$progressbar = GuiCtrlCreateProgress(16, 170, 496, 30)
GuiCtrlSetData($progressbar, $progress)



_IENavigate($oIE, "http://www.myspace.com/index.cfm?fuseaction=signout")
_IENavigate($oIE, "http://www.myspace.com/")

GUISetState()


While 1
    $msg = GUIGetMsg()
    $now = TimerInit()
    
    
    If $go = 1 Then
        $sofar = TimerDiff($last_update)
        $percent = 100*($sofar/$wait)
        ;MsgBox(0, "Gross", $last_update & " " & $wait & " " & $sofar & " " & $percent)
        

        ;MsgBox(0, "Stuff", "Total: " & $total & " | Sofar: " & $sofar & " | " & $percent)
        GuiCtrlSetData($progressbar, $percent)

        If $sofar > $wait Then
            GuiCtrlSetData($progressbar, 100)
            $msg = $start_stop_button
        EndIf

    EndIf
    
    
    Select
        
    Case $msg = $start_stop_button
        MsgBox(0, $i, $i)
        MsgBox(0, $i, $status[$i])
        $status_now = $status[$i]
        $text = "Account: " & $email
        GuiCtrlSetData($log, $text)
        _IELinkClickByText($oIE, "Log In")
        $form_email = _IEGetObjById($oIE,"ctl00_ctl00_cpMain_cpMain_LoginBox_Email_Textbox")
        $form_password = _IEGetObjById($oIE,"ctl00_ctl00_cpMain_cpMain_LoginBox_Password_Textbox")
        $form_submit = _IEGetObjById($oIE,"dlb")
        _IEFormElementSetValue ($form_email, $email)
        _IEFormElementSetValue ($form_password, $password)
        _IEAction($form_submit,"click")
        _IELoadWait($oIE)
        $logged_in = _IELinkClickByText ($oIE, "view more")
        
        If $logged_in = 0 Then
            $text = $text & @CRLF & "Could not log in."
            GuiCtrlSetData($log, $text)
        Else
            $text = $text & @CRLF & "Logged in!"
            GuiCtrlSetData($log, $text)

        _IELoadWait($oIE)

            
            ;If $anti_flood = 1 Then
                ;_IEImgClick($oIE, "http://x.myspacecdn.com/modules/friends/static/img/delete_icon_gray.gif")
                ;Need to add code to deal with popup verification box.
            ;EndIf
            
            $update_form = _IEFormGetCollection ($oIE, 1)
            $update_status = _IEFormElementGetCollection($update_form, 2)
            $update_mood = _IEFormElementGetCollection($update_form, 3)
            
            _IEFormElementSetValue ($update_status, $status_now)
            _IEFormElementSetValue ($update_mood, $mood)
            _IEFormSubmit($update_form)
            $text = $text & @CRLF & @CRLF & "Status: " & $status_now & @CRLF & "Mood: " & $mood
            GuiCtrlSetData($log, $text)
            _IELinkClickByText($oIE, "Sign Out")
            $text = $text & @CRLF &  @CRLF & "Logged out"
            GuiCtrlSetData($log, $text)
            
            $last_update = TimerInit()
            If $min = $max Then
                $wait = $min
            Else
                $wait = Random($min, $max)
            EndIf
            
            $next_update = $wait + $last_update
            $go = 1
        EndIf
        
    Case $msg = $GUI_EVENT_CLOSE
        Exit
        
    EndSelect
WEnd
Global $arr[2]

$arr[0]="hip"
$arr[1]="hip"
;^^ hip hip array. ^^
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...