Sign in to follow this  
Followers 0
Scinner

Need some beginners help!

34 posts in this topic

Well I dont know how to solve this one but I know you guys wont have a problem with it :)

Please help me.

CODE
Func click()

MouseClick("left", 690, 541, 1) ;The first time the function is called this will be executed

MouseClick("left", 455, 348, 1) ;The second time the function is called this one will be executed

MouseClick("left", 612, 687, 1) ;Third time

MouseClick("left", 312, 494, 1) ;and so on

MouseClick("left", 569, 286, 1) ;and so on

EndFunc

Share this post


Link to post
Share on other sites



Hi there,

Maybe something like this:

$counter = 0

Func click()
    Select
        case $counter = 0 
            MouseClick("left", 690, 541, 1);The first time the function is called this will be executed
        case $counter = 1
            MouseClick("left", 455, 348, 1);The second time the function is called this one will be executed
        case $counter = 2 
            MouseClick("left", 612, 687, 1);Third time
        case $counter = 3       
            MouseClick("left", 312, 494, 1);and so on
        case $counter = 4           
            MouseClick("left", 569, 286, 1);and so on
        case $counter = 5
        ;Do some action because no more mouseclicks are need.
    EndSelect
$counter = $counter +1
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

What exactly is the problem?


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

Hi there,

Maybe something like this:

$counter = 0

Func click()
    Select
        case $counter = 0 
            MouseClick("left", 690, 541, 1);The first time the function is called this will be executed
        case $counter = 1
            MouseClick("left", 455, 348, 1);The second time the function is called this one will be executed
        case $counter = 2 
            MouseClick("left", 612, 687, 1);Third time
        case $counter = 3       
            MouseClick("left", 312, 494, 1);and so on
        case $counter = 4           
            MouseClick("left", 569, 286, 1);and so on
        case $counter = 5
    ;Do some action because no more mouseclicks are need.
    EndSelect
$counter = $counter +1
EndFunc

Cheers

Thanks alot man!

I thought it wouldn't be that hard but when you don't know how to do it you just dont know how to do it, sort of speak. :)

Share this post


Link to post
Share on other sites

Thanks alot man!

I thought it wouldn't be that hard but when you don't know how to do it you just dont know how to do it, sort of speak. :)

I'm glad i could help and understood what you where asking... i thought that you wanted a never ending click loop :lmao:

Cheers m8


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

#6 ·  Posted (edited)

I'm glad i could help and understood what you where asking... i thought that you wanted a never ending click loop :)

Cheers m8

I wont get my script to work. Its a gamebot for the game Travian and i know how much you guys dislikes these bots, but im only trying to learn AutoIt. The purpose of the script isn't that important to me. I'll post it below so you can check it out if you like. Any help will be very appreciated! I´m fairly new at this as you can see.

Func read() ;this function is a home made Firefox reader that will tell me if i got more than 5 soldiers in my village
Sleep(3000) ;60000*5
WinActivate("Travian se4 - Mozilla Firefox")
MouseClick("left", 195, 185, 1)
Sleep(3000)
Send("^a")
Send("^c")
ShellExecute("D:\Mikee\AutoIt Script + Div\test.txt")
Sleep(1000)
Send("^v")
Sleep(500)
Send("^f")
Sleep(500)
Send("Trupper:")
Sleep(500)
Send("!u")
Sleep(500)
Send("{ENTER}")
Send("{DEL}")
Send("{SHIFTDOWN}")
Send("{UP 14}")
Send("{SHIFTUP}")
Send("{DEL 4}")
Send("{RIGHT 2}")
Send("{SHIFTDOWN}")
Send("{PGDN 3}")
Send("{SHIFTUP}")
Send("{DEL}")
Send("{HOME}")
Sleep(500)
Local $File = @ScriptDir & "\test.txt"
$Read = FileRead($File)
$Final = StringStripWS($Read, 8)
If $Read <= 5 Then                        ;More than 5 soldiers? Here im not sure if its right????
    Call("attack")
ElseIf $Read >= 5 Then                    ;Less than 5 soldiers, not sure here either??????
    Sleep(2000)
    WinKill("* D:\Mikee\AutoIt Script + Div\test.txt - Notepad2")
    Call("read")                          ;can i call the same funtion that im in?????????
EndIf
EndFunc



Func attack()
WinKill("* D:\Mikee\AutoIt Script + Div\test.txt - Notepad2")
WinActivate("Travian se4 - Mozilla Firefox")
$counter = 0
    Select
        case $counter = 0                     ;here it keeps repeating this first case and wont proceed to the next?????
            MouseClick("left", 725, 295, 1)   ;all these cases are diffrent targets i want to attack
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
            Call("read")
        case $counter = 1
            MouseClick("left", 725, 315, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 2
            MouseClick("left", 725, 333, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 3
            MouseClick("left", 725, 355, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 4
            MouseClick("left", 725, 375, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 5
            MouseClick("left", 725, 394, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 6
            MouseClick("left", 725, 417, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 7
            MouseClick("left", 725, 436, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 8
            MouseClick("left", 725, 455, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 9
            MouseClick("left", 725, 476, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 10
            MouseClick("left", 725, 496, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 11
            MouseClick("left", 725, 516, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 12
            MouseClick("left", 725, 536, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 13
            MouseClick("left", 725, 555, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 14
            MouseClick("left", 725, 577, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 15
            MouseClick("left", 725, 596, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 16
            MouseClick("left", 725, 615, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 17
            MouseClick("left", 725, 636, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 18
            MouseClick("left", 725, 657, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 19
            MouseClick("left", 725, 676, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 473, 1)
    EndSelect
$counter = $counter +1
EndFunc
call("read")
Edited by Scinner

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I wont get my script to work. Its a gamebot for the game Travian and i know how much you guys dislikes these bots, but im only trying to learn AutoIt. The purpose of the script isn't that important to me. I'll post it below so you can check it out if you like. Any help will be very appreciated! I´m fairly new at this as you can see.

Just a small advice that if you ever wanna make a macro/kind of bot for web related stuff, in this case Travian, try using IE UDF, read autoit helpfile, it is very useful and easy to make. i succesfully made some little scripts for Travian. By using it, you won't need to control mouseclick and key send to mozilla, you can work something else with your computer while to macro is running.

Edited by soulhealer

Share this post


Link to post
Share on other sites

Be willing to work and willing to learn, demonstrate more intelligence than the average pet rock, and you can expect to find some friendly assistance. In my experience, it's not so much the gamebots as the people who want them that are disliked here... the 1337 gamers who want to cheat... and can't be bothered to form a coherent sentence other than to ask someone else to make a 15 billion line script that will level their entire guild from 1 to 80, master all combat skills, farm enough gold to fund a third world dictatorship for several decades, and do their homework before Mom gets home. :)

First thing, check out the existing travian bot.

Use the search function in the Examples forum (Check the "Search this forum only" box.) Search for the term Travian.

The first hit will bring up an existing, and very polished bot. The next hits will bring up various other scripts accomplishing different things.

Share this post


Link to post
Share on other sites

Just a small advice that if you ever wanna make a macro/kind of bot for web related stuff, in this case Travian, try using IE UDF, read autoit helpfile, it is very useful and easy to make. i succesfully made some little scripts for Travian. By using it, you won't need to control mouseclick and key send to mozilla, you can work something else with your computer while to macro is running.

Yes I know, im trying that to. But i would really like to get this one to work and i know im close to doing so. I also got 4 computers at home so i could dedicate one to this script and still have to many computers :) Annyways, thanks for the advice! I just hope someone will help me with this script.

Share this post


Link to post
Share on other sites

Be willing to work and willing to learn, demonstrate more intelligence than the average pet rock, and you can expect to find some friendly assistance. In my experience, it's not so much the gamebots as the people who want them that are disliked here... the 1337 gamers who want to cheat... and can't be bothered to form a coherent sentence other than to ask someone else to make a 15 billion line script that will level their entire guild from 1 to 80, master all combat skills, farm enough gold to fund a third world dictatorship for several decades, and do their homework before Mom gets home. :)

First thing, check out the existing travian bot.

Use the search function in the Examples forum (Check the "Search this forum only" box.) Search for the term Travian.

The first hit will bring up an existing, and very polished bot. The next hits will bring up various other scripts accomplishing different things.

Well that wasn't very nice or even called for. As for my intelligence, everyone cant be Einstein. And im not asking annyone to write me a complete script. This one is allmost complete i just have a few problems with it. And I dont want an allready made script, then i wont learn annything. And I'm not that good at english, is that a crime? Should i stop trying because im from another country and therefor have a hard tim expressing myselfe? This post took me 15 minutes to write. Im 34 years old so my mom wont be home. I couldn't care less about the game but its a good way for ME to start learning AutoIt. One thing is fore sure, i dont want YOU to help me.

Share this post


Link to post
Share on other sites

I wont get my script to work. Its a gamebot for the game Travian and i know how much you guys dislikes these bots, but im only trying to learn AutoIt. The purpose of the script isn't that important to me. I'll post it below so you can check it out if you like. Any help will be very appreciated! I´m fairly new at this as you can see.

Func read() ;this function is a home made Firefox reader that will tell me if i got more than 5 soldiers in my village
Sleep(3000) ;60000*5
WinActivate("Travian se4 - Mozilla Firefox")
MouseClick("left", 195, 185, 1)
Sleep(3000)
Send("^a")
Send("^c")
ShellExecute("D:\Mikee\AutoIt Script + Div\test.txt")
Sleep(1000)
Send("^v")
Sleep(500)
Send("^f")
Sleep(500)
Send("Trupper:")
Sleep(500)
Send("!u")
Sleep(500)
Send("{ENTER}")
Send("{DEL}")
Send("{SHIFTDOWN}")
Send("{UP 14}")
Send("{SHIFTUP}")
Send("{DEL 4}")
Send("{RIGHT 2}")
Send("{SHIFTDOWN}")
Send("{PGDN 3}")
Send("{SHIFTUP}")
Send("{DEL}")
Send("{HOME}")
Sleep(500)
Local $File = @ScriptDir & "\test.txt"
$Read = FileRead($File)
$Final = StringStripWS($Read, 8)
If $Read <= 5 Then                        ;More than 5 soldiers? Here im not sure if its right????
    Call("attack")
ElseIf $Read >= 5 Then                    ;Less than 5 soldiers, not sure here either??????
    Sleep(2000)
    WinKill("* D:\Mikee\AutoIt Script + Div\test.txt - Notepad2")
    Call("read")                          ;can i call the same funtion that im in?????????
EndIf
EndFunc



Func attack()
WinKill("* D:\Mikee\AutoIt Script + Div\test.txt - Notepad2")
WinActivate("Travian se4 - Mozilla Firefox")
$counter = 0
    Select
        case $counter = 0                     ;here it keeps repeating this first case and wont proceed to the next?????
            MouseClick("left", 725, 295, 1)   ;all these cases are diffrent targets i want to attack
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
            Call("read")
        case $counter = 1
            MouseClick("left", 725, 315, 1)
            Sleep(1000)
            MouseClick("left", 200, 330, 1)
            Sleep(500)
            Send("7")
            Sleep(500)
            Send("{ENTER}")
            Sleep(1000)
            MouseClick("left", 180, 474, 1)
        case $counter = 2
                ; some more cases I left out for better overview......
    EndSelect
$counter = $counter +1
EndFunc
call("read")

i think you are produce a loop where you dont want one, as I see this, you are calling the "read" function after every case and the "read" function calls the "attack" function in turn, so i wont ever come to the second case...

as for your question if you can call the same function you are already in: yes you can, it is although limitet to 127 "levels" (that was the last thing I read, maybe this limit has been extended with a newer autoit release)

Share this post


Link to post
Share on other sites

i think you are produce a loop where you dont want one, as I see this, you are calling the "read" function after every case and the "read" function calls the "attack" function in turn, so i wont ever come to the second case...

as for your question if you can call the same function you are already in: yes you can, it is although limitet to 127 "levels" (that was the last thing I read, maybe this limit has been extended with a newer autoit release)

Thanks alot! That got me on the right track and i think it works now. I will have to test it for a while first. If it runs correctly I will post it for you to see the changes ive made. I skipped all the functions among other things. Thank you again!

Share this post


Link to post
Share on other sites

Well that wasn't very nice or even called for. As for my intelligence, everyone cant be Einstein. And im not asking annyone to write me a complete script. This one is allmost complete i just have a few problems with it. And I dont want an allready made script, then i wont learn annything. And I'm not that good at english, is that a crime? Should i stop trying because im from another country and therefor have a hard tim expressing myselfe? This post took me 15 minutes to write. Im 34 years old so my mom wont be home. I couldn't care less about the game but its a good way for ME to start learning AutoIt. One thing is fore sure, i dont want YOU to help me.

I was trying to help you help yourself, and my attempt at humor seems to have been lost in translation. I wasn't calling you a 1337 script kiddy. I was pointing out that you were being mature and coherent, and that most people wouldn't mind helping you out at all.

No offense was intended, and none taken. Just PM me if you want me to clarify anything, if the grammar or wordings are unfamiliar to you. :)

Share this post


Link to post
Share on other sites

I was trying to help you help yourself, and my attempt at humor seems to have been lost in translation. I wasn't calling you a 1337 script kiddy. I was pointing out that you were being mature and coherent, and that most people wouldn't mind helping you out at all.

No offense was intended, and none taken. Just PM me if you want me to clarify anything, if the grammar or wordings are unfamiliar to you. :)

Ok, then i apologize. These language barriers are killing me. Cant make myselfe understood and cant understand what others trying to say to me. :lmao:

Sorry!

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Now I need some help again.

ShellExecute("D:\Mikee\AutoIt Script + Div\test.txt")
Sleep(1000)
Local $File = @ScriptDir & "\test.txt"
$Read = FileRead($File)
If $Read > 5 Then  
    Send("Over")
ElseIf $Read < 5 Then ;It returns "Under" no matter what is in the .txt -What am i doing wrong?
    Send("Under")
EndIf
Edited by Scinner

Share this post


Link to post
Share on other sites

Slight alteration to your code:

Func read() ;this function is a home made Firefox reader that will tell me if i got more than 5 soldiers in my village
    Sleep(3000) ;60000*5
    WinActivate("Travian se4 - Mozilla Firefox")
    MouseClick("left", 195, 185, 1)
    Sleep(3000)
    Send("^a")
    Send("^c")
    ShellExecute("D:\Mikee\AutoIt Script + Div\test.txt")
    Sleep(1000)
    Send("^v")
    Sleep(500)
    Send("^f")
    Sleep(500)
    Send("Trupper:")
    Sleep(500)
    Send("!u")
    Sleep(500)
    Send("{ENTER}")
    Send("{DEL}")
    Send("{SHIFTDOWN}")
    Send("{UP 14}")
    Send("{SHIFTUP}")
    Send("{DEL 4}")
    Send("{RIGHT 2}")
    Send("{SHIFTDOWN}")
    Send("{PGDN 3}")
    Send("{SHIFTUP}")
    Send("{DEL}")
    Send("{HOME}")
    Sleep(500)
    Local $File = @ScriptDir & "\test.txt"
    $Read = FileRead($File)
    $Final = StringStripWS($Read, 8)

    If $Read > 5 Then ; previously you had, "$Read <= 5" which reads: less than or equal to five
        Call("attack")
    ElseIf $Read <= 5 Then ; fixed this too
        Sleep(2000)
        WinKill("* D:\Mikee\AutoIt Script + Div\test.txt - Notepad2")
        Call("read")                          ; it's called recursion and it's pretty neat
    EndIf
EndFunc



Func attack()
    WinKill("* D:\Mikee\AutoIt Script + Div\test.txt - Notepad2")
    WinActivate("Travian se4 - Mozilla Firefox")
    $counter = 0
    Select
        case $counter = 0                     ;here it keeps repeating this first case and wont proceed to the next?????
            MouseClick("left", 725, 295, 1)   ;all these cases are diffrent targets i want to attack
            _func1()       ; I put all of this duplicate code into a function.
        case $counter = 1 
            MouseClick("left", 725, 315, 1)
            _func1()
        case $counter = 2
            MouseClick("left", 725, 333, 1)
            _func1()
        case $counter = 3
            MouseClick("left", 725, 355, 1)
            _func1()
        case $counter = 4
            MouseClick("left", 725, 375, 1)
            _func1()
        case $counter = 5
            MouseClick("left", 725, 394, 1)
            _func1()
        case $counter = 6
            MouseClick("left", 725, 417, 1)
            _func1()
        case $counter = 7
            MouseClick("left", 725, 436, 1)
            _func1()
        case $counter = 8
            MouseClick("left", 725, 455, 1)
            _func1()
        case $counter = 9
            MouseClick("left", 725, 476, 1)
            _func1()
        case $counter = 10
            MouseClick("left", 725, 496, 1)
            _func1()
        case $counter = 11
            MouseClick("left", 725, 516, 1)
            _func1()
        case $counter = 12
            MouseClick("left", 725, 536, 1)
            _func1()
        case $counter = 13
            MouseClick("left", 725, 555, 1)
            _func1()
        case $counter = 14
            MouseClick("left", 725, 577, 1)
            _func1()
        case $counter = 15
            MouseClick("left", 725, 596, 1)
            _func1()
        case $counter = 16
            MouseClick("left", 725, 615, 1)
            _func1()
        case $counter = 17
            MouseClick("left", 725, 636, 1)
            _func1()
        case $counter = 18
            MouseClick("left", 725, 657, 1)
            _func1()
        case $counter = 19
            MouseClick("left", 725, 676, 1)
            _func1()
    EndSelect
    $counter += 1
EndFunc

call("read")

 ; Now if you ever decide to change any of this code  then you  only have to change it once and not 20 times...
Func _func1() ; change the name of this function to something else that you prefer...
    Sleep(1000)                         
    MouseClick("left", 200, 330, 1)
    Sleep(500)
    Send("7")
    Sleep(500)
    Send("{ENTER}")
    Sleep(1000)
    MouseClick("left", 180, 474, 1)
    Call("read")
EndFunc

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Slight alteration to your code:

Thank you for your tips, especialy the insights about functions!

I dont know why but i wont get the "more than/less than" thing to work, any ideas to why that is?

EDIT: Ignore this. Glitch in my brain :)

ShellExecute("D:\Mikee\AutoIt Script + Div\test.txt")
Sleep(1000)
Local $File = @ScriptDir & "\test.txt"
$Read = FileRead($File)
If $Read > 5 Then 
    Send("Over")
ElseIf $Read < 5 Then ;It returns "Under" no matter what is in the .txt -What am i doing wrong?
    Send("Under")
EndIf
Edited by Scinner

Share this post


Link to post
Share on other sites

Do you want to sequentially execute each of those 'atacks' one after the other every time you run the attack function?

Or only execute one specific attack each time?

Anyway, you're setting $counter to 0 at the top of the attack routine and never incrementing it, As written, it will always be 0.

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

You wanting something more like this?

Global $AttackPoints[20][2] = [[725, 295],[725, 315],[725, 333],[725, 355],[725, 375],[725, 394],[725, 417],[725, 436], _
                               [725, 455],[725, 476],[725, 496],[725, 516],[725, 536],[725, 555],[725, 577],[725, 596], _
                               [725, 615],[725, 636],[725, 657],[725, 676]]



Func read();this function is a home made Firefox reader that will tell me if i got more than 5 soldiers in my village
    Sleep(3000);60000*5
    WinActivate("Travian se4 - Mozilla Firefox")
    MouseClick("left", 195, 185, 1)
    Sleep(3000)
    Send("^a")
    Send("^c")
    ShellExecute("D:\Mikee\AutoIt Script + Div\test.txt")
    Sleep(1000)
    Send("^v")
    Sleep(500)
    Send("^f")
    Sleep(500)
    Send("Trupper:")
    Sleep(500)
    Send("!u")
    Sleep(500)
    Send("{ENTER}")
    Send("{DEL}")
    Send("{SHIFTDOWN}")
    Send("{UP 14}")
    Send("{SHIFTUP}")
    Send("{DEL 4}")
    Send("{RIGHT 2}")
    Send("{SHIFTDOWN}")
    Send("{PGDN 3}")
    Send("{SHIFTUP}")
    Send("{DEL}")
    Send("{HOME}")
    Sleep(500)
    Local $File = @ScriptDir & "\test.txt"
    $Read = FileRead($File)
    $Final = StringStripWS($Read, 8)

    If $Read > 5 Then; previously you had, "$Read <= 5" which reads: less than or equal to five
        Call("attack")
    ElseIf $Read <= 5 Then; fixed this too
        Sleep(2000)
        WinKill("* D:\Mikee\AutoIt Script + Div\test.txt - Notepad2")
        Call("read")                    ; it's called recursion and it's pretty neat
    EndIf
EndFunc

Func attack()
    WinKill("* D:\Mikee\AutoIt Script + Div\test.txt - Notepad2")
    WinActivate("Travian se4 - Mozilla Firefox")
    For $x = 0 to 19
        MouseClick("left", $AttackPoints[$x][0],$AttackPoints[$x][1], 1);all these cases are diffrent targets i want to attack
        _func1()    ; I put all of this duplicate code into a function
    Next
EndFunc

call("read")

; Now if you ever decide to change any of this code  then you  only have to change it once and not 20 times...
Func _func1(); change the name of this function to something else that you prefer...
    Sleep(1000)                      
    MouseClick("left", 200, 330, 1)
    Sleep(500)
    Send("7")
    Sleep(500)
    Send("{ENTER}")
    Sleep(1000)
    MouseClick("left", 180, 474, 1)
    Call("read")
EndFunc

PS - Do you just want the read fucntion executed continuosly? calling "read" recursively may be neat, but it's "crazy ivan" spaghetti coding and about the biggest violation of structured programming in existence. You should avoid it like the plague, unless it's absolutely necessary. It'll also overflow your stack in no time. You need to explain what you're wanting to do with the read function, and rethink a cleaner method of achieving it.

Edit: PPS - I assume there is more to this script? An entry point, an exit point? You really need to nix all but one call to the read function, just put the one call into a loop that suits your needs.

Edited by Spiff59

Share this post


Link to post
Share on other sites

Do you want to sequentially execute each of those 'atacks' one after the other every time you run the attack function?

Or only execute one specific attack each time?

Anyway, you're setting $counter to 0 at the top of the attack routine and never incrementing it, As written, it will always be 0.

I want to execute one specific attack each time.

Okeeey, now i understand that the $counter sets to 0 each time and that's not what i want. I want it to step +1 every time the attack function is called. How would i go about incrementing it? Im sorry, but i dont even know the meaning of that word. My AoutIt skills are poor and my english is even worse. I googled it and came up with this link:

http://www.gnu.org/software/emacs/emacs-li...nting-Loop.html

I've read it a couple of times now but i don't get any wiser. Could you give me an example or in some way point me in the right direction? I would really like to understand it.

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