Sign in to follow this  
Followers 0
Bliz0r

Having some trouble here.

8 posts in this topic

Hello, I started making this bot for a friend, for a 3d chat, I just recently learned the basics of Autoit v3, and arent that good at spotting & correcting errors.

HotKeySet("{ESC}", "Terminate")
Dim $Forside1, $Account, $Password, $Netstation1, $Netstation2, $Text, $Farve, $Hoejre, $Toppen, $Venstre, $Bunden

$Forside1 = "Mozilla Firefox forside" 
$Account = "Removed"
$Password = "Removed"
$Netstation1 = "Netstationen:Chatunivers for unge"
$Netstation2 = "http://www.n.dk"
$Text = "Hej med dig{ENTER}"
$Farve = 0xFFCC66
$Hoejre = 406
$Toppen = 21
$Venstre = 30
$Bunden = 372

Msgbox(0, "Netstationen bot - Created by Bliz0r", "Tryk ESCAPE For at stoppe botten.", 0)


    send("#r") 
    WinwaitActive("Kør") 
    Send("Firefox.exe{ENTER}") 
    WinWaitactive($Forside1) 
    MouseClick("Primary", 425, 70, 1, 10)
    Send("http://www.netstationen.dk{ENTER}")
    Sleep(5000)
    Mouseclick("Primary", 343, 610, 1, 10) 
    Sleep(5000)
    Mouseclick("Primary", 1260, 10, 1, 0)
    WinWaitActive($Netstation2)
    MouseClickDrag("Primary", 122, 197, 30, 0)
    Sleep(5000)
    MouseClick("Primary", 205, 42, 1, 10)
    Send($Account)
    MouseClick("Primary", 312, 40, 1, 0)
    Send($Password)
    MouseClick("Primary", 390, 41, 1, 0)
    Sleep(30000)
    Mouseclick("Primary", 160, 177, 1, 0)
    Sleep(1000)
    Mouseclick("Primary", 59, 289, 1, 10)
    Sleep(1000)
    Send("/goto 154{ENTER}")
    Sleep(10000)

    $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
    
$Loop = 0
    While 1   
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else mouseClick("Primary", 70, 301, 1, 10)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else mouseClick("Primary", 116, 301, 1, 10)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else mouseClick("Primary", 56, 301, 1, 10)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else mouseClick("Primary", 85, 290, 1, 10)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else Send($Text)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 76, 295, 1, 10)
        WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 105, 290, 1, 10)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 116, 250, 1, 10)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 136, 161, 1, 10)
        WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else Send($Text)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 145, 161, 1, 10)
            WEnd
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 154, 161, 1, 10)
            WEnd
    If $Loop = 1 Then ContinueLoop
WEnd
                
Func Terminate()
    Exit 0
EndFunc

It's supposed to enter a chatroom, and just click & send a message, but every hour in game it'll pop up a screen with a message which I need the bot to click "Ok" on.

If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
    Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)

I don't know what i've done wrong, but when the script gives me theese errors:

C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(52,79) : ERROR: multi-line 'If' missing 'Then'.
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(53,5) : ERROR: syntax error
                Then
                ^
C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(54,4) : ERROR: missing Wend.
            Else
            ^
C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(50,2) : REF: missing Wend.
    While
    ^
C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(3,31) : ERROR: Terminate(): undefined function.
HotKeySet("{ESC}", "Terminate")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3 - 4 error(s), 0 warning(s)
>Exit code: 2   Time: 1.413

Can anyone spot where the errors are, and eventually help me on the way to fix them (if it's not too much asking :whistle:)

I don't know why it gives me the

ERROR: Terminate(): undefined function.
HotKeySet("{ESC}", "Terminate")

since the function is working just fine.

I have no idea about the rest though, can anyone help me out? :lmao:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 154, 161, 1, 10)
WEnd

its not WEnd to send an if...then statement. its EndIf

Edited by Golbez

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
                Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 154, 161, 1, 10)
WEnd

its not WEnd to send an if...then statement. its EndIf

A stupid mistake :whistle: but didn't change anything..

$SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve)
    
$Loop = 0
    While 1   
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else mouseClick("Primary", 70, 301, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else mouseClick("Primary", 116, 301, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else mouseClick("Primary", 56, 301, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else mouseClick("Primary", 85, 290, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else Send($Text)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 76, 295, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 105, 290, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 116, 250, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 136, 161, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else Send($Text)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 145, 161, 1, 10)
            Endif
        Sleep(20000)
            If $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then MouseClick("Primary", $SearchResult, $SearchResult, 10, 0)
            Else MouseClick("Primary", 154, 161, 1, 10)
            Endif
    If $Loop = 1 Then ContinueLoop
WEnd

I still get theese errors:

C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(54,4) : ERROR: missing Wend.

Else

^

C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(50,2) : REF: missing Wend.

While

^

C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(54,4) : ERROR: syntax error

Else

^

C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3(3,31) : ERROR: Terminate(): undefined function.

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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3 - 3 error(s), 0 warning(s)

>Exit code: 2 Time: 0.541

Anyone who can tell me where I've done somthing wrong? and is missing those Wend's ?

Also, when I try to run the script, I get this error:

C:\Documents and Settings\Alex\Dokumenter\Autoit v3\Netstationen bot\Netstationen bot.au3 (53) : ==> "Else" statement with no matching "If" statement.: 
Else mouseClick("Primary", 70, 301, 1, 10)

Why do I get that error?

Edited by Bliz0r

Share this post


Link to post
Share on other sites

Anyone know? :whistle:

Share this post


Link to post
Share on other sites

Anyone know? :lmao:

Work on your scripts in SciTE.

Use Tidy (Ctrl-t) from SciTE and it will flag you errors very clearly.

Then run the SyntaxCheck (Ctrl-F5) from SciTE to find more errors.

Then run the program for testing (F5) from SciTE, noting the outputs in the console pane of SciTE.

And did mention, you should use SciTE... :whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Work on your scripts in SciTE.

Use Tidy (Ctrl-t) from SciTE and it will flag you errors very clearly.

Then run the SyntaxCheck (Ctrl-F5) from SciTE to find more errors.

Then run the program for testing (F5) from SciTE, noting the outputs in the console pane of SciTE.

And did mention, you should use SciTE... :whistle:

Don't quite get what that Ctrl + t does? just switching the lines :S

Oh, and I've been using SciTe all the time :lmao:

Edited by Bliz0r

Share this post


Link to post
Share on other sites

Also read up on If...Else...Endif in the Autoit Help.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Don't quite get what that Ctrl + t does? just switching the lines :S

Oh, and I've been using SciTe all the time :whistle:

Ctrl+t runs Tidy, which is a formatting tool that standardizes indentation and a few other things, save the file, and in the process detects simple mistakes like While without a WEnd, etc. It places "markers" in your code where there are errors. Find the earliest error marker and fix that one first. Then re-run Tidy by hitting Ctrl-t again. Tidy will remove the previous markers and check it again.

Tidy only checks basic format and sequence. After you get a clean run of Tidy, you hit Ctrl+F5 to run the full SyntaxCheck, which finds more subtle errors. Fix all those, and THEN you're ready to run your code for the first time.

:lmao:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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