Jump to content

Help! Do... Until.. Loop


Recommended Posts

:( Hey I'am making a bot for my favorite game, And I need some help with the loop here is the part of the code which is messing up.

$var1 = "Server Exceeded."

Do

WinGetText("ROSE Online", "$var1")

MouseClick("left", 513, 392, 2)

Send("{ENTER}")

Sleep("700")

Until $var1 = "Select character."

Sleep ("3000")

MouseClick("left", 254, 578, 5)

Since the server gets full many of the times you have to make it loop and try to login continously, But after it logs in, It keeps looping even after it says 'Select character.' ! Help me plz!

Link to comment
Share on other sites

  • Developers

I change the $var 2 that??

<{POST_SNAPBACK}>

you are not changing $var1 in your loop...

What needs to happen for the Loop to end ??

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

ooooo, A little text after it logs in says "Select Character."

<{POST_SNAPBACK}>

Which you want to retrieve with WinGetText() right ?

The result of WinGetText() need to be put into a variabe.....

$Variable = WinGetText()

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

:( I dont understand, After it loops the login. The server will then send me to the Select Character screen, I want it to end the loop when it sees the 'Select Character' text. Please simplify it for my noob self. Like place it as if it was in the full code. Edited by Meep
Link to comment
Share on other sites

  • Developers

:( I dont understand, After it loops the login. The server will then send me to the Select Character screen, I want it to end the loop when it sees the 'Select Character' text. Please simplify it for my noob self. Like place it as if it was in the full code.

<{POST_SNAPBACK}>

Have a look at the helpfile example and see if that makes sence...

But thye function WinGetText() retrieves the text from the selected window and then puts that information into a variable.

so logic to me would be something like this... This code will keep on looping till somewhere in the text it contains "Select character." :

Do
    $var1=WinGetText("ROSE Online", "")
    Sleep(10)
Until StringInStr($var1,"Select character.")
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It still keeps looping afterwards... Is there anyway I can use the pixelfinder to just look for the color The textbox is? Only problem the pixelfinder thingy (I dont understand it...) This is how the code looks like now.

$var1 = "Server Exceeded."

Do

$var1=WinGetText("ROSE Online", "$var1")

Sleep("10")

MouseClick("left", 513, 392, 2)

Send("{ENTER}")

Sleep("700")

Until StringInStr($var1,"Select character.")

Sleep ("3000")

MouseClick("left", 254, 578, 5)

Do i remove the first line???

Edited by Meep
Link to comment
Share on other sites

Ok, first off, the first line

$var1 = "Server Exceeded"

Should maybe be named this:

$text = "Server Exceeded"

The third line:

$var1=WinGetText("ROSE Online", "$var1")

Should be this:

$var1=WinGetText("ROSE Online", $text)

Don't ever put quotes around a variable because then it thinks you actually want to use $var1 or $text as the text, rather then the data inside $text.

So heres the finished product should look like:

$text = "Server Exceeded."
Do

$var1 =WinGetText("ROSE Online", $text)
Sleep(10)
MouseClick("left", 513, 392, 2) 
Send("{ENTER}")
Sleep("700")

Until StringInStr($var1,"Select character.")

Sleep ("3000")
MouseClick("left", 254, 578, 5)

That should work, post back and tell us your results.

FootbaG
Link to comment
Share on other sites

WinWaitActive("ROSE Online")
Do
    Sleep("10")
    MouseClick("left", 513, 392, 2)
    Send("{ENTER}")
    Sleep("700")
    $var1=WinGetText("ROSE Online", "$var1")
Until StringInStr($var1,"Select character.")

Sleep ("3000")
MouseClick("left", 254, 578, 5)

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

hehe, oops, am I slow or what...

try this:

WinWaitActive("ROSE Online")
Do
    Sleep("10")
    MouseClick("left", 513, 392, 2)
    Send("{ENTER}")
    Sleep("700")
    $var1=WinGetText("ROSE Online", "")
Until StringInStr($var1,"Select character.")

Sleep ("3000")
MouseClick("left", 254, 578, 5)

the other thing I can think of trying is using ControlSend()

WinWaitActive("ROSE Online")
Do
    Sleep("10")
    MouseClick("left", 513, 392, 2)
    ControlSend("ROSE Online", "", "", "{ENTER}")
    Sleep("700")
    $var1=WinGetText("ROSE Online", "")
Until StringInStr($var1,"Select character.")

Sleep ("3000")
MouseClick("left", 254, 578, 5)
Edited by MSLx Fanboy

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

I would look into using another Do...Until or While..WEnd loop to check the title again.

I don't play ROSE, though I know people who do...I'll ask next time I talk to them

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

Are we sure that the "text" can be "seen" by the AutoIt Window Info tool (henceforth known as "the tool")?

Perhaps things have changed, but in this post in early May, there was no visible window text. See posts #17 and #19 for various images of "the tool" for this game.

If "the tool" can "see" some text, then that text should be copied from "the tool" and pasted into your script code. Do not try to type it in. It has to be perfect... Notice that the text is refered to in the earlier posts as:

Select Character and as

Select character.

Select Character does not equal Select character.

Perhaps there are multiple clients for this game and this version has "Visible Window Text".

Also, you might want to search the forum for "rose online".

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

StringToLower() can be a good wrapper for making sure that character casing is not an issue...

Great point plato

<{POST_SNAPBACK}>

I was burned by my script looking for one space between two words of text - when in reality, there were two spaces. (and I knew better, I knew to copy/paste, but nooooo, I typed it in for some stupid reason)

I suppose that one could wrap with StringStripWS also...

[size="1"][font="Arial"].[u].[/u][/font][/size]

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