Bliz0r Posted July 7, 2007 Posted July 7, 2007 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. expandcollapse popupHotKeySet("{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 ) 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?
Golbez Posted July 7, 2007 Posted July 7, 2007 (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 July 7, 2007 by Golbez
Bliz0r Posted July 7, 2007 Author Posted July 7, 2007 (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 but didn't change anything.. expandcollapse popup$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 July 7, 2007 by Bliz0r
PsaltyDS Posted July 7, 2007 Posted July 7, 2007 Anyone know? 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... 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
Bliz0r Posted July 7, 2007 Author Posted July 7, 2007 (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... Don't quite get what that Ctrl + t does? just switching the lines :SOh, and I've been using SciTe all the time Edited July 7, 2007 by Bliz0r
Siao Posted July 7, 2007 Posted July 7, 2007 Also read up on If...Else...Endif in the Autoit Help. "be smart, drink your wine"
PsaltyDS Posted July 8, 2007 Posted July 8, 2007 Don't quite get what that Ctrl + t does? just switching the lines :SOh, and I've been using SciTe all the time 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. 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now