Jump to content
Sign in to follow this  
jafuuu

HELP A POOR NOOB PLEASE! =(

Recommended Posts

jafuuu

Please, help me, is my first script, and I need in some parts.

This is a script maked for a internet webbrowsing-based game.

And I need 4 things:

1.- How to make a SplashTextOn appear every time when you run the script? (only at start)

2.- When an "If" case appear, this do correctly their functions, but when reload the page and the problem is the same, the script countinue, How to make the "If" function works again until problem is fixed?

3.- Wait to StatusbarGetText says "Done" or "Finished", if say this, continue execution of the script and how to add a timeout to this?

4.- Read a valor from "Opciones.ini", if the valor is = 0, do until is marked in script (you can see the green letter on the source) and then jump to "X" step, if valor is = 1, do until is marked in script and jump to "X" step, if valor is = ... etc, etc.

PLEASE, HELP THIS POOR NOOB WHIT HIM SCRIPT >_

; BE CAREFULL FOR THE CHANGES YOU DOES!

#include <IE.au3> 

$nombre = IniRead(@ScriptDir&"\Opciones.ini", "GENERAL", "NOMBRE", "")
$serv = IniRead(@ScriptDir&"\Opciones.ini", "GENERAL", "SERVIDOR", "")
$a = IniRead(@ScriptDir&"\Opciones.ini", "GENERAL", "INICIALES", "")

$alumno1 = IniRead(@ScriptDir&"\Opciones.ini", "ALUMNOS", "ALUMNO1", "")
$alumno2 = IniRead(@ScriptDir&"\Opciones.ini", "ALUMNOS", "ALUMNO2", "")
$alumno3 = IniRead(@ScriptDir&"\Opciones.ini", "ALUMNOS", "ALUMNO3", "")
$alumno4 = IniRead(@ScriptDir&"\Opciones.ini", "ALUMNOS", "ALUMNO4", "")
$alumno5 = IniRead(@ScriptDir&"\Opciones.ini", "ALUMNOS", "ALUMNO5", "")
$alumno6 = IniRead(@ScriptDir&"\Opciones.ini", "ALUMNOS", "ALUMNO6", "")

$x1 = IniRead(@ScriptDir&"\Opciones.ini", "COORDENADAS", "X1", "")
$y1 = IniRead(@ScriptDir&"\Opciones.ini", "COORDENADAS", "Y1", "")
$x2 = IniRead(@ScriptDir&"\Opciones.ini", "COORDENADAS", "X2", "")
$y2 = IniRead(@ScriptDir&"\Opciones.ini", "COORDENADAS", "Y2", "")
$x3 = IniRead(@ScriptDir&"\Opciones.ini", "COORDENADAS", "X3", "")
$y3 = IniRead(@ScriptDir&"\Opciones.ini", "COORDENADAS", "Y3", "")

$ip = IniRead(@ScriptDir&"\Opciones.ini", "IP", "IP", "")

$modem = IniRead(@ScriptDir&"\Opciones.ini", "PAUSAS", "MODEM", "")
$p1 = IniRead(@ScriptDir&"\Opciones.ini", "PAUSAS", "PAUSA1", "")
$p2 = IniRead(@ScriptDir&"\Opciones.ini", "PAUSAS", "PAUSA2", "")
$p3 = IniRead(@ScriptDir&"\Opciones.ini", "PAUSAS", "PAUSA3", "")
$p4 = IniRead(@ScriptDir&"\Opciones.ini", "PAUSAS", "PAUSA4", "")
$r = IniRead(@ScriptDir&"\Opciones.ini", "PAUSAS", "RETRASO1", "")
$r2 = IniRead(@ScriptDir&"\Opciones.ini", "PAUSAS", "RETRASO2", "")

$file1 = FileOpen(@ScriptDir&"\Alumnos.txt",1)

$oIE = _IECreate ("http://"&$nombre&"."&$serv&"/")
$text = _IEBodyReadText ($oIE)

If StringInStr($text,"Ha ocurrido un error") Then
    Send ("{F5}")
     Sleep ($p3)
 EndIf
 
 If StringInStr($text,"Mantenimiento en Curso") Then
    WinClose ("Internet Explorer","") 
      SplashTextOn ("Pausa","'Mantenimiento en Curso...', Elbruto-BOT continuara ejecutandose cuando este termine... O puedes cerrar la ejecucion de ElBruto BOT y ejecutarlo manualmente cuando el mantenimiento termine.",500,100) 
        Sleep (900000)
          SplashOff ()
                     Send ("{F5}")
EndIf

;HOW TO MAKE THIS SPLASH APPEAR WHEN YOU START THE SCRIPT????? (ONLY 1 TIME EVERY TIME SCRIPT IS RUNED)
SplashTextOn ("ElBruto BOT","Iniciando ElBruto Bot version 1.0BETA, No olvides visitar la pagina oficial 'HTTP://ElBruto-Bot.blogspopot.com'.",500,70)
Sleep (3000)
SplashOff ()

While 1
    
Opt("WinTitleMatchMode", 2) 
    
WinActivate ("Internet Explorer","")
    
    _IELoadWait ($oIE)
    
    WinSetState ("Internet Explorer","",@SW_SHOW)
    
    WinSetState ("Internet Explorer","",@SW_MAXIMIZE)

Sleep ($p1)

MouseClick("left",$x1,$y1,1,0)
Sleep (100+$r)

Opt("SendKeyDelay", $r2)

$x = Random(1, 100000, 1)

Send ($a&$x)

Opt("SendKeyDelay", 10)

FileWrite ($file1,$a&$x & @CRLF)
FileClose ($file1)

Sleep ($r)
Send ("{ENTER}")
Sleep ($p2)

;READ A VALUE FROM "OPCIONES.INI"
;DO ONLY TO HERE IF THE VALUE IS = 0, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").

ClipPut ("http://"&$a&$x&"."&$serv&"/vs/"&$alumno1)
MouseClick ("left",$x2,$y2,1,0)
Send ("^v")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p3)
MouseClick ("left",$x3,$y3,1,0)
Sleep (100)
Send ("{TAB}")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p4)

;DO ONLY TO HERE IF THE VALUE IS = 1, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").

ClipPut ("http://"&$a&$x&"."&$serv&"/vs/"&$alumno2)
MouseClick ("left",$x2,$y2,1,0)
Send ("^v")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p3)
MouseClick ("left",$x3,$y3,1,0)
Sleep (100)
Send ("{TAB}")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p4)

;DO ONLY TO HERE IF THE VALUE IS = 2, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").

ClipPut ("http://"&$a&$x&"."&$serv&"/vs/"&$alumno3)
MouseClick ("left",$x2,$y2,1,0)
Send ("^v")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p3)
MouseClick ("left",$x3,$y3,1,0)
Sleep (100)
Send ("{TAB}")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p4)

;DO ONLY TO HERE IF THE VALUE IS = 3, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").

ClipPut ("http://"&$a&$x&"."&$serv&"/vs/"&$alumno4)
MouseClick ("left",$x2,$y2,1,0)
Send ("^v")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p3)
MouseClick ("left",$x3,$y3,1,0)
Sleep (100)
Send ("{TAB}")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p4)

;DO ONLY TO HERE IF THE VALUE IS = 4, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").

ClipPut ("http://"&$a&$x&"."&$serv&"/vs/"&$alumno5)
MouseClick ("left",$x2,$y2,1,0)
Send ("^v")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p3)
MouseClick ("left",$x3,$y3,1,0)
Sleep (100)
Send ("{TAB}")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p4)

;DO ONLY TO HERE IF THE VALUE IS = 5, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").

ClipPut ("http://"&$a&$x&"."&$serv&"/vs/"&$alumno6)
MouseClick ("left",$x2,$y2,1,0)
Send ("^v")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p3)
MouseClick ("left",$x3,$y3,1,0)
Sleep (100)
Send ("{TAB}")
Sleep ($r)
Send ("{ENTER}")
Sleep ($p4)

;DO TO HERE IF THE VALUE IS = 6, THEN JUMP TO NEXT STEP (WinClose "Internet Explorer","").

WinClose ("Internet Explorer","")

Sleep (2000)

Run (@ScriptDir&"\CambiarIP\"&$ip)

Sleep ($modem)
Wend

HELP, I KNOW EVERYBODY IN THIS FORUMS ARE A PRO FOR SCRIPTS :(!

Share this post


Link to post
Share on other sites
colafrysen

Added a Switch...Case...EndSwitch

And the splash screen, its only showed once, at script start? (havent runed the script)

; BE CAREFULL FOR THE CHANGES YOU DOES!

#include <IE.au3>

$nombre = IniRead(@ScriptDir & "\Opciones.ini", "GENERAL", "NOMBRE", "")
$serv = IniRead(@ScriptDir & "\Opciones.ini", "GENERAL", "SERVIDOR", "")
$a = IniRead(@ScriptDir & "\Opciones.ini", "GENERAL", "INICIALES", "")

$alumno1 = IniRead(@ScriptDir & "\Opciones.ini", "ALUMNOS", "ALUMNO1", "")
$alumno2 = IniRead(@ScriptDir & "\Opciones.ini", "ALUMNOS", "ALUMNO2", "")
$alumno3 = IniRead(@ScriptDir & "\Opciones.ini", "ALUMNOS", "ALUMNO3", "")
$alumno4 = IniRead(@ScriptDir & "\Opciones.ini", "ALUMNOS", "ALUMNO4", "")
$alumno5 = IniRead(@ScriptDir & "\Opciones.ini", "ALUMNOS", "ALUMNO5", "")
$alumno6 = IniRead(@ScriptDir & "\Opciones.ini", "ALUMNOS", "ALUMNO6", "")

$x1 = IniRead(@ScriptDir & "\Opciones.ini", "COORDENADAS", "X1", "")
$y1 = IniRead(@ScriptDir & "\Opciones.ini", "COORDENADAS", "Y1", "")
$x2 = IniRead(@ScriptDir & "\Opciones.ini", "COORDENADAS", "X2", "")
$y2 = IniRead(@ScriptDir & "\Opciones.ini", "COORDENADAS", "Y2", "")
$x3 = IniRead(@ScriptDir & "\Opciones.ini", "COORDENADAS", "X3", "")
$y3 = IniRead(@ScriptDir & "\Opciones.ini", "COORDENADAS", "Y3", "")

$ip = IniRead(@ScriptDir & "\Opciones.ini", "IP", "IP", "")

$modem = IniRead(@ScriptDir & "\Opciones.ini", "PAUSAS", "MODEM", "")
$p1 = IniRead(@ScriptDir & "\Opciones.ini", "PAUSAS", "PAUSA1", "")
$p2 = IniRead(@ScriptDir & "\Opciones.ini", "PAUSAS", "PAUSA2", "")
$p3 = IniRead(@ScriptDir & "\Opciones.ini", "PAUSAS", "PAUSA3", "")
$p4 = IniRead(@ScriptDir & "\Opciones.ini", "PAUSAS", "PAUSA4", "")
$r = IniRead(@ScriptDir & "\Opciones.ini", "PAUSAS", "RETRASO1", "")
$r2 = IniRead(@ScriptDir & "\Opciones.ini", "PAUSAS", "RETRASO2", "")

$file1 = FileOpen(@ScriptDir & "\Alumnos.txt", 1)

$oIE = _IECreate("http://" & $nombre & "." & $serv & "/")
$text = _IEBodyReadText($oIE)

If StringInStr($text, "Ha ocurrido un error") Then
    Send("{F5}")
    Sleep($p3)
EndIf

If StringInStr($text, "Mantenimiento en Curso") Then
    WinClose("Internet Explorer", "")
    SplashTextOn("Pausa", "'Mantenimiento en Curso...', Elbruto-BOT continuara ejecutandose cuando este termine... O puedes cerrar la ejecucion de ElBruto BOT y ejecutarlo manualmente cuando el mantenimiento termine.", 500, 100)
    Sleep(900000)
    SplashOff()
    Send("{F5}")
EndIf

;HOW TO MAKE THIS SPLASH APPEAR WHEN YOU START THE SCRIPT????? (ONLY 1 TIME EVERY TIME SCRIPT IS RUNED)
SplashTextOn("ElBruto BOT", "Iniciando ElBruto Bot version 1.0BETA, No olvides visitar la pagina oficial 'HTTP://ElBruto-Bot.blogspopot.com'.", 500, 70)
Sleep(3000)
SplashOff()

While 1

    Opt("WinTitleMatchMode", 2)

    WinActivate("Internet Explorer", "")

    _IELoadWait($oIE)

    WinSetState("Internet Explorer", "", @SW_SHOW)

    WinSetState("Internet Explorer", "", @SW_MAXIMIZE)

    Sleep($p1)

    MouseClick("left", $x1, $y1, 1, 0)
    Sleep(100 + $r)

    Opt("SendKeyDelay", $r2)

    $x = Random(1, 100000, 1)

    Send($a & $x)

    Opt("SendKeyDelay", 10)

    FileWrite($file1, $a & $x & @CRLF)
    FileClose($file1)

    Sleep($r)
    Send("{ENTER}")
    Sleep($p2)

    ;READ A VALUE FROM "OPCIONES.INI"
    ;DO ONLY TO HERE IF THE VALUE IS = 0, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").
    Switch IniRead("OPCIONES.INI", "sect", "key", "deafult")
        Case 0

            ClipPut("http://" & $a & $x & "." & $serv & "/vs/" & $alumno1)
            MouseClick("left", $x2, $y2, 1, 0)
            Send("^v")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p3)
            MouseClick("left", $x3, $y3, 1, 0)
            Sleep(100)
            Send("{TAB}")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p4)

            ;DO ONLY TO HERE IF THE VALUE IS = 1, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").
        Case 1
            ClipPut("http://" & $a & $x & "." & $serv & "/vs/" & $alumno2)
            MouseClick("left", $x2, $y2, 1, 0)
            Send("^v")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p3)
            MouseClick("left", $x3, $y3, 1, 0)
            Sleep(100)
            Send("{TAB}")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p4)

            ;DO ONLY TO HERE IF THE VALUE IS = 2, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").
        Case 2
            ClipPut("http://" & $a & $x & "." & $serv & "/vs/" & $alumno3)
            MouseClick("left", $x2, $y2, 1, 0)
            Send("^v")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p3)
            MouseClick("left", $x3, $y3, 1, 0)
            Sleep(100)
            Send("{TAB}")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p4)

            ;DO ONLY TO HERE IF THE VALUE IS = 3, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").
        Case 3
            ClipPut("http://" & $a & $x & "." & $serv & "/vs/" & $alumno4)
            MouseClick("left", $x2, $y2, 1, 0)
            Send("^v")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p3)
            MouseClick("left", $x3, $y3, 1, 0)
            Sleep(100)
            Send("{TAB}")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p4)

            ;DO ONLY TO HERE IF THE VALUE IS = 4, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").
        Case 4
            ClipPut("http://" & $a & $x & "." & $serv & "/vs/" & $alumno5)
            MouseClick("left", $x2, $y2, 1, 0)
            Send("^v")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p3)
            MouseClick("left", $x3, $y3, 1, 0)
            Sleep(100)
            Send("{TAB}")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p4)

            ;DO ONLY TO HERE IF THE VALUE IS = 5, THEN JUMP TO LINE 180 (WinClose "Internet Explorer","").
        Case 5
            ClipPut("http://" & $a & $x & "." & $serv & "/vs/" & $alumno6)
            MouseClick("left", $x2, $y2, 1, 0)
            Send("^v")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p3)
            MouseClick("left", $x3, $y3, 1, 0)
            Sleep(100)
            Send("{TAB}")
            Sleep($r)
            Send("{ENTER}")
            Sleep($p4)

            ;DO TO HERE IF THE VALUE IS = 6, THEN JUMP TO NEXT STEP (WinClose "Internet Explorer","").
    EndSwitch
    WinClose("Internet Explorer", "")

    Sleep(2000)

    Run(@ScriptDir & "\CambiarIP\" & $ip)

    Sleep($modem)
WEnd

Edit: Also, code is meant to be written in English (my opinion)

Edited by colafrysen

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]

Share this post


Link to post
Share on other sites
jafuuu

Added a Switch...Case...EndSwitch

And the splash screen, its only showed once, at script start? (havent runed the script)

Edit: Also, code is meant to be written in English (my opinion)

haha code is in spanish, but is easy to understand, aanyway..

Thanks for Switch...Case...EndSwitch, it works >_<, I need to put 0 To 1, 0 To 2, but anyway its works :(

I fix the splsh screen problem, dont worry..

Can you help me with the If..The..EndIf statments?

Share this post


Link to post
Share on other sites
colafrysen

I don't quite understand what you are trying to accomplish with the If.

The basic syntax though:

If Expression Then ;If an expression if correct (True) like for example 1=1, 8>9 and 5<=5

Else ;If the expression was not true (False) like for example 1=2, 9>8 and 5.0000001<=5

Endif ;If Else Endif done, returning to execute the rest of the script


[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]

Share this post


Link to post
Share on other sites
jafuuu

I don't quite understand what you are trying to accomplish with the If.

The basic syntax though:

If Expression Then ;If an expression if correct (True) like for example 1=1, 8>9 and 5<=5

Else ;If the expression was not true (False) like for example 1=2, 9>8 and 5.0000001<=5

Endif ;If Else Endif done, returning to execute the rest of the script

Yes, I undestand how works If...Then...Else...EndIf etc...

But, for example:

If the webpage says "An error has occurred", the "If" statment send "F5" to reload the page

but, when send the key "F5" and is the same error in the webpage, the page is not reloaded again

and the scipts continue...

I want to know how to continue sending "F5" until the message "An error has ocurred" dissapear.

And, there is anyway to check the "If" function every step of the script?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.