Sign in to follow this  
Followers 0
sebbe133

Case statement

10 posts in this topic

Hi. To start with, I'm a beginner when it comes to AutoIt, just started a couple of days ago.

And I'm sure you've heard this before, but I'm making myself a bot for a certain game. I've managed it decently until now.

I need it to goto different stages of the botting, like in a batch file.

Example:

:start
if exist C:\WINDOWS then goto lul else goto lal
:lul
echo found yerr windows dirr!

:lal
echo cannot find your windows dirr! zomg! :O

And, I figured I had to use the Case statement, but now I'm not really sure..

The code:

case $search

while 1
if PixelGetColor(431,165) <> 0x00BC00 then $attack else $walk
endif
WEnd

Case $walk

while 1
send("{TAB}")
send("{W DOWN}")
sleep(5300)
send("{W UP}")
send("{A DOWN}")
sleep(5300)
send("{A UP}")
Sleep(random(1,2)*1000)
WEnd

case $attack

$i = 0
while PixelGetColor(343,164) = 0x00BC00 AND $i <> 100

sleep(200)
controlsend("World of Warcraft", "", "", 1)
sleep(1200)
controlsend("World of Warcraft", "", "", 2)
sleep(1200)
controlsend("World of Warcraft", "", "", 3)
sleep(1200)
controlsend("World of Warcraft", "", "", 4)
sleep(1200)
controlsend("World of Warcraft", "", "", 5)
sleep(1200)
controlsend("World of Warcraft", "", "", 6)
sleep(1200)
controlsend("World of Warcraft", "", "", 1)
sleep(1200)
controlsend("World of Warcraft", "", "", 2)
sleep(1200)
controlsend("World of Warcraft", "", "", 3)
sleep(1200)
controlsend("World of Warcraft", "", "", 4)
sleep(1200)
controlsend("World of Warcraft", "", "", 5)
sleep(1200)
controlsend("World of Warcraft", "", "", 6)
sleep(1200)
if PixelGetColor(343,164) = 0x00BC00 then $attack else $search
WEnd

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Read the helpfile. It'll tell you what you need to know.

Looking around for it as we speak. But since I'm new to AutoIt it's pretty hard.. mhzaah Edited by sebbe133

Share this post


Link to post
Share on other sites

Notice that you need a statement in the Select Case block.

Local $var=0
Select
    case $Var = 1
        ;Do this
    case $Var = 3
        ;Do that
    case else
        ;Ups! What happend
EndSelect

Switch could be a better choice for you as it gives more flexibility. The help file is your friend..:)

Share this post


Link to post
Share on other sites

Notice that you need a statement in the Select Case block.

Switch could be a better choice for you as it gives more flexibility. The help file is your friend..:)

<3 I love you man. I found this in the helpfile, but it said nothing to me :) Thanks.

Share this post


Link to post
Share on other sites

Notice that you need a statement in the Select Case block.

Local $var=0
Select
    case $Var = 1
        ;Do this
    case $Var = 3
        ;Do that
    case else
        ;Ups! What happend
EndSelect

Switch could be a better choice for you as it gives more flexibility. The help file is your friend..:)

Hi there m8,

I looked at your code and i re-arranged my way.

I use cases for multi results for the same variable.

In your case if...else...endif it´s the better way, but for a clean view and debug i use funcs, take a look :)

while 1
    if PixelGetColor(431,165) <> 0x00BC00 then 
        attack() 
    else
        walk()
    EndIf   
WEnd

func attack()
    $i = 0
    sleep(200)
    controlsend("World of Warcraft", "", "", 1)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 2)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 3)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 4)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 5)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 6)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 1)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 2)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 3)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 4)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 5)
    sleep(1200)
    controlsend("World of Warcraft", "", "", 6)
    sleep(1200)
EndFunc

func walk()
    send("{TAB}")
    send("{W DOWN}")
    sleep(5300)
    send("{W UP}")
    send("{A DOWN}")
    sleep(5300)
    send("{A UP}")
EndFunc

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Hi there m8,

I looked at your code and i re-arranged my way.

I use cases for multi results for the same variable.

Cheers

Wow. Now I really wanna learn more AutoIt.. That's clean man :)

Thanks alot!

Hope to see you guys again :)

Share this post


Link to post
Share on other sites

Wow. Now I really wanna learn more AutoIt.. That's clean man ;)

Thanks alot!

Hope to see you guys again :)

You welcome :)

take a look at this post from Brett, it's really good. Light and straight to the core of AutoIT.

Brett's Great Manual

Cheers o:)


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

You welcome :)

take a look at this post from Brett, it's really good. Light and straight to the core of AutoIT.

Brett's Great Manual

Cheers :)

Code like func attack() is crying out for a couple of loops:

CODE

func attack()

$i = 0

sleep(200)

For $p = 1 To 2

For $n = 1 To 6

controlsend("World of Warcraft", "", "", $n)

sleep(1200)

next

next

EndFunc

Share this post


Link to post
Share on other sites

Code like func attack() is crying out for a couple of loops:

CODE

func attack()

$i = 0

sleep(200)

For $p = 1 To 2

For $n = 1 To 6

controlsend("World of Warcraft", "", "", $n)

sleep(1200)

next

next

EndFunc

Hi again,

What kind of attack are you doing? I play WOW too, so try to check the time to cast/engage and do a sleep between attacks.

Try to get also hoe many stroke with that magis are needed to get the enemy down.

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

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