|
You last visited: Today at 01:17
Advertisement
Nothing happens after "start" function
Discussion on Nothing happens after "start" function within the AutoIt forum part of the Coders Den category.
09/12/2013, 16:36
|
#1
|
elite*gold: 0
Join Date: Jul 2012
Posts: 56
Received Thanks: 1
|
Nothing happens after "start" function
Pretty new to AutoIt, so probably a very noob error. Everything goes fine until the "Func login()" line, it just stop and doesnt do anything. Any idea?
Code:
#include <ImageSearch.au3>
;Alpha, No GUI LoL Bot
HotKeySet("q", "stopbot") ;Emergency Stop
;Open League of Legends Launcher
Run("C:\Riot Games\League of Legends\" & "\lol.launcher.exe", "", @SW_MAXIMIZE)
Sleep(500)
;Press "Play" in League of Legends Launcher
$x = 0
$y = 0
start()
While 1
Sleep(500)
WEnd
Func start()
While 1
$result = _ImageSearch("Pressplay.bmp", 0, $x, $y, 1)
If $result = 1 Then
MouseMove($x, $y)
MouseClick("left")
EndIf
WEnd
EndFunc ;==>start
;Inputs Username and Password from File
$accountfile = @ScriptDir & "\account.txt"
$x1 = 780
$x2 = 520
$y1 = 780
$y2 = 580
Func login()
While 1
$Openusr = FileOpen($accountfile)
$Readusr = FileReadLine($Openusr, 1)
ClipPut($Readusr)
FileClose($Openusr)
MouseMove($x1, $y1)
MouseClick("left")
Send("{LCTRL}+v")
$Openpw = FileOpen($accountfile)
$Readpw = FileReadLine($Openpw, 2)
ClipPut($Readpw)
FileClose($Openpw)
Sleep(5000)
MouseMove($x2, $y2)
MouseClick("left")
Send("{LCTRL}+v")
WEnd
EndFunc ;==>login
;Stops the bot with HotKeySet "q" - ALWAYS LAST FUNC
Func stopbot()
Exit 0
EndFunc ;==>stopbot
|
|
|
09/12/2013, 16:45
|
#2
|
elite*gold: 113
Join Date: Dec 2009
Posts: 16,685
Received Thanks: 4,450
|
Try using Function names, that aren't that common.
It might be, that start() and login() are already used commands by AutoIt, so it won't work.
"_startBot
_AccountLogin"
Would be "safe" Function names, that should prevent such problems.
(I might be missing a mistake in the code itself, yet I wanted to point that out)
|
|
|
09/12/2013, 16:46
|
#3
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Maybe because you forgot to call login()?
Rorc, if these functionnames are used then his Editor would show it up by colored functionnames.
The problem why it doesn't work is because he didn't call login().
|
|
|
09/12/2013, 16:47
|
#4
|
elite*gold: 3653
Join Date: Aug 2008
Posts: 30,854
Received Thanks: 529
|
you can use Mouseclick("left",x,y,amount of clicks,movespeed)
and your script keeps in the first while 1, since there is no escape out of it. only the hotkey kills the whole script
|
|
|
09/12/2013, 17:22
|
#5
|
elite*gold: 0
Join Date: Jul 2012
Posts: 56
Received Thanks: 1
|
I tried the function on an empty page and it only worked when i removed func login() and endfunc, then i tried call("login") and it worked.
But where do i have to put the call("login") in the full script? And where should i put the while 1?
|
|
|
09/12/2013, 17:48
|
#6
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
It depens on what you want to get. Think through your steps and try other placements until it fits well.
|
|
|
09/12/2013, 18:00
|
#7
|
elite*gold: 0
Join Date: Jul 2012
Posts: 56
Received Thanks: 1
|
Okay, i got it to work! Thanks all!
|
|
|
All times are GMT +1. The time now is 01:18.
|
|