Jump to content

Array Choice Each loop


Recommended Posts

I am still very new to Auto It but am learning quickly. When I set the array

Dim $channel[5]

$channel[4] = MouseClick("left", 265, 364, 1)

$channel[3] = MouseClick("left", 366, 334, 1)

$channel[2] = MouseClick("left", 474, 335, 1)

$channel[1] = MouseClick("left", 274, 400, 1)

$channel[0] = MouseClick("left", 284, 431, 1)

It just clicks those spots until the last one is clicked and it moves on. I want it so that each loop it chooses a different channel.

Like First loop is $channel[4] = MouseClick("left", 265, 364, 1)

Second $channel[3] = MouseClick("left", 366, 334, 1)

and so on. Any help is much appreciated.

HotKeySet("{ESC}", "Terminate")


While 1
    GameLogin()
    Sleep(500)
    GoZapIt()
    Sleep(500)
WEnd

;======================================================================================
; Func GameLogin()                                          Hot Key = None
;======================================================================================
Func GameLogin()
If WinGetState("MapleStory") = 16 Then
   WinSetState("MapleStory", "", @SW_MAXIMIZE)
EndIf
    Sleep(400)
    MouseClick("left", 419, 334, 1)
    Sleep(400)
    MouseClick("left", 454, 286, 1)
    Send("******{Enter}")
    Sleep(500)
    MouseClick("left", 163, 157, 1)
    Sleep(300)

Dim $channel[5]
$channel[4] = MouseClick("left", 265, 364, 1)
$channel[3] = MouseClick("left", 366, 334, 1)
$channel[2] = MouseClick("left", 474, 335, 1)
$channel[1] = MouseClick("left", 274, 400, 1)
$channel[0] = MouseClick("left", 284, 431, 1)

    Sleep(300)
    MouseClick("left", 555, 252, 1)
    Sleep(300)
    MouseClick("left", 252, 343, 1)
    Sleep(300)
    MouseClick("left", 624, 159, 1)
    Sleep(3000)
EndFunc;==>GameLogin

;======================================================================================
; Func GoZapIt()                                            Hot Key = None
;======================================================================================
Func GoZapIt()

    Local $iMax = 40; Change this if you want to change the number of times it hits
    Local $iCnt    ; This does the counting
    For $iCnt = 1 To $iMax
        Send("a")
        Sleep(200)
If WinGetState("MapleStory") = 16 Then
   WinSetState("MapleStory", "", @SW_MAXIMIZE)
EndIf
    Next
     Return
EndFunc;==>GoZapIt

;======================================================================================
; Func Terminate()                                          Hot Key = Escape
;======================================================================================
Func Terminate()                                          ; Hot Key = Escape
    MsgBox(0, "Terminating Script", "Script Name: " & @ScriptName & @LF & @LF & "Located: " & @ScriptDir & @LF & @LF & "is now Terminated")
    Exit 0
EndFunc;==>Terminate
Edited by Leprechaun
Link to comment
Share on other sites

Here is how you would want the loop...

Dim $channel[5]
$channel[4] = MouseClick("left", 265, 364, 1)
$channel[3] = MouseClick("left", 366, 334, 1)
$channel[2] = MouseClick("left", 474, 335, 1)
$channel[1] = MouseClick("left", 274, 400, 1)
$channel[0] = MouseClick("left", 284, 431, 1)

While 1
    $channel[Random(0, 4, 1)]
;That makes it a random value from 0 to 4 and returns integers.
WEnd

Let me know if that helps any.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Your code dosnt work. I used the same code as yours and just modified it a little bit to look like the following but I get the error, " Expected a "=" operator in assignment statement after the closing bracket on "$channel[Random(0, 8, 1)]"

Dim $channel[8]

$channel[7] = MouseClick("left", 363, 304, 1) ;Channel 2

$channel[6] = MouseClick("left", 275, 332, 1) ;Channel 5

$channel[5] = MouseClick("left", 553, 305, 1) ;Channel 4

$channel[4] = MouseClick("left", 265, 364, 1) ;Channel 9

$channel[3] = MouseClick("left", 366, 334, 1) ;Channel 6

$channel[2] = MouseClick("left", 474, 335, 1) ;Channel 7

$channel[1] = MouseClick("left", 274, 400, 1) ;Channel 13

$channel[0] = MouseClick("left", 284, 431, 1) ;Channel 17

While 1

$channel[Random(0, 8, 1)]

;That makes it a random value from 0 to 4 and returns integers.

WEnd

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

Its alright guys I figured it out on my own with a little sit down and read..with a little trial and error too. =)

Dim $channel

$channel = Random(0, 8, 1)

If $channel = 0 Then MouseClick("left", 284, 431, 1)

If $channel = 1 Then MouseClick("left", 274, 400, 1)

If $channel = 2 Then MouseClick("left", 474, 335, 1)

If $channel = 3 Then MouseClick("left", 366, 334, 1)

If $channel = 4 Then MouseClick("left", 265, 364, 1)

If $channel = 5 Then MouseClick("left", 553, 305, 1)

If $channel = 6 Then MouseClick("left", 275, 332, 1)

If $channel = 7 Then MouseClick("left", 363, 304, 1)

That code works perfectly and is exactly what I was loking for.

Link to comment
Share on other sites

Its alright guys I figured it out on my own with a little sit down and read..with a little trial and error too. =)

Dim $channel 

$channel = Random(0, 8, 1)

If $channel = 0 Then MouseClick("left", 284, 431, 1)

If $channel = 1 Then MouseClick("left", 274, 400, 1)

If $channel = 2 Then MouseClick("left", 474, 335, 1)

If $channel = 3 Then MouseClick("left", 366, 334, 1)

If $channel = 4 Then MouseClick("left", 265, 364, 1)

If $channel = 5 Then MouseClick("left", 553, 305, 1)

If $channel = 6 Then MouseClick("left", 275, 332, 1)

If $channel = 7 Then MouseClick("left", 363, 304, 1)

That code works perfectly and is exactly what I was loking for.

<{POST_SNAPBACK}>

Well I am glad you had it working. I was giving an example you would have had to take my example and put that variable in a place it could have been used some how to return the value.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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