Nothing happens after "start" function

09/12/2013 16:36 milk4hunn#1
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 Rorc#2
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 alpines#3
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 c0w#4
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 milk4hunn#5
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 alpines#6
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 milk4hunn#7
Okay, i got it to work! Thanks all!