Error Missing "}" Topic is solved

Ask gaming related questions (AHK v1.1 and older)
k666sper
Posts: 2
Joined: 13 Apr 2021, 13:06

Error Missing "}"

Post by k666sper » 13 Apr 2021, 13:16

Hello guys, I am new to AHK, just started 2 hours ago, and I made this code for a game I am playing. However, whenever I try to run it, it tells me that there is a missing "}" with an arrow pointing at line 10 (just after the Loop). Please excuse how bad and inefficient my code is, I know I could have made functions in a lot of places, but I didn't :3

Code: Select all

F7::pause


Loop
{                                ;this is the line it says there is an error with
	GameOpen = 0
	If WinActive("ahk_class RiotWindowClass")
	{
		GameOpen = 1
	}
	
	While (GameOpen = 0)
	{
		CrossX := ""
		ImageSearch, CrossX, CrossY, 330, 525, 380, 570, C:\Users\oem\Desktop\ARAM_Bot\Cross.PNG
		While (CrossX != "")
		{
			Click, %CrossX% %CrossY%
			Sleep 2000
			Click, 93 34
			Sleep 2000
			Click, 300 200
			Sleep 2000
			Click, 430 550
			Sleep 2000
			Click, 430 550
			ImageSearch, CrossX2, CrossY2, 330, 525, 380, 570, C:\Users\oem\Desktop\ARAM_Bot\Cross.PNG
			While (CrossX2 != "")
			{
				Click 500 450
				ImageSearch, CrossX3, CrossY3, 330, 525, 380, 570, C:\Users\oem\Desktop\ARAM_Bot\Cross.PNG
				If (CrossX3 = "")
				{
					CrossX2 := ""
				}
				Sleep 4000
			CrossX := ""
		}
		
		ImageSearch, LevelupX, LevelupY, 439, 518, 579, 565, C:\Users\oem\Desktop\ARAM_Bot\Levelup.PNG
		If (LevelupX != "")
		{
			Click %LevelupX% %LevelupY%
			LevelupX := ""
		}
		
		If WinActive("ahk_class RiotWindowClass")
		{
			GameOpen = 1
		}
	}
	While (GameOpen = 1)
	{
		ImageSearch, 2minX, 2minY, 1300, 26, 1340, 43, C:\Users\oem\Desktop\ARAM_Bot\2min.PNG
		While (2minX != "")
		{
			ImageSearch, RedSideX, RedSideY, 1286, 460, 1335, 90, C:\Users\oem\Desktop\ARAM_Bot\RedSide.PNG
			While (RedSideX = "")
			{
				Send {Ctrl down}
				Sleep 100
				Send {q down}
				Sleep 100
				Send {q up}
				Send {w down}
				Sleep 100
				Send {w up}
				Send {e down}
				Sleep 100
				Send {e up}
				Send {Ctrl up}
				Sleep 100
				Send {p down}
				Sleep 50
				Send {p up}
				Click, 271 343, right
				Sleep 50
				Send {p down}
				Sleep 50
				Send {p up}
				Sleep 50
				GameOpen = 0
				Click, 1215 595
				Send {q down}
				Sleep 50
				Send {q up}
				Sleep 5000
				Send {w down}
				Sleep 50
				Send {w up}
				Sleep 5000
				Send {e down}
				Sleep 50
				Send {e up}
				Sleep 5000
				GameOpen = 0
				Click, 1222 602
				Sleep 5000
				GameOpen = 0
				Click, 1227 612
				Sleep 50
				GameOpen = 0
				If WinActive("ahk_class RiotWindowClass")
				{
					GameOpen = 1
				}
				If (GameOpen = 0)
				{
					RedSideX = 0
					2minX := ""
				}
			}
			While (RedSideX > 0)
			{
				Send {Ctrl down}
				Sleep 100
				Send {q down}
				Sleep 100
				Send {q up}
				Send {w down}
				Sleep 100
				Send {w up}
				Send {e down}
				Sleep 100
				Send {e up}
				Send {Ctrl up}
				Sleep 100
				Send {p down}
				Sleep 50
				Send {p up}
				Click, 271 343, right
				Sleep 50
				Send {p down}
				Sleep 50
				Send {p up}
				Sleep 50
				GameOpen = 0
				Click, 1235 578
				Send {q down}
				Sleep 50
				Send {q up}
				Sleep 5000
				Send {w down}
				Sleep 50
				Send {w up}
				Sleep 5000
				Send {e down}
				Sleep 50
				Send {e up}
				Sleep 5000
				Click, 1240 587
				Sleep 5000
				Click, 1247 595
				Sleep 50
				GameOpen = 0
				If WinActive("ahk_class RiotWindowClass")
				{
					GameOpen = 1
				}
				If (GameOpen = 0)
				{
					RedSideX = 0
					2minX := ""
				}
			}
		}
	}
}
Any help please? I am truly not sure why it is not working.

User avatar
boiler
Posts: 16919
Joined: 21 Dec 2014, 02:44

Re: Error Missing "}"  Topic is solved

Post by boiler » 13 Apr 2021, 14:07

See the fix below with the missing } identified with a comment. Use an editor that highlights brace pairs like Visual Studio Code or Notepad++ to easily identify pairs of braces.

Code: Select all

F7::pause


Loop
{                                ;this is the line it says there is an error with
	GameOpen = 0
	If WinActive("ahk_class RiotWindowClass")
	{
		GameOpen = 1
	}
	
	While (GameOpen = 0)
	{
		CrossX := ""
		ImageSearch, CrossX, CrossY, 330, 525, 380, 570, C:\Users\oem\Desktop\ARAM_Bot\Cross.PNG
		While (CrossX != "")
		{
			Click, %CrossX% %CrossY%
			Sleep 2000
			Click, 93 34
			Sleep 2000
			Click, 300 200
			Sleep 2000
			Click, 430 550
			Sleep 2000
			Click, 430 550
			ImageSearch, CrossX2, CrossY2, 330, 525, 380, 570, C:\Users\oem\Desktop\ARAM_Bot\Cross.PNG
			While (CrossX2 != "")
			{
				Click 500 450
				ImageSearch, CrossX3, CrossY3, 330, 525, 380, 570, C:\Users\oem\Desktop\ARAM_Bot\Cross.PNG
				If (CrossX3 = "")
				{
					CrossX2 := ""
				}
				Sleep 4000
			} ; <<<< THIS IS THE ONE THAT WAS MISSING
			CrossX := ""
		}
		
		ImageSearch, LevelupX, LevelupY, 439, 518, 579, 565, C:\Users\oem\Desktop\ARAM_Bot\Levelup.PNG
		If (LevelupX != "")
		{
			Click %LevelupX% %LevelupY%
			LevelupX := ""
		}
		
		If WinActive("ahk_class RiotWindowClass")
		{
			GameOpen = 1
		}
	}
	While (GameOpen = 1)
	{
		ImageSearch, 2minX, 2minY, 1300, 26, 1340, 43, C:\Users\oem\Desktop\ARAM_Bot\2min.PNG
		While (2minX != "")
		{
			ImageSearch, RedSideX, RedSideY, 1286, 460, 1335, 90, C:\Users\oem\Desktop\ARAM_Bot\RedSide.PNG
			While (RedSideX = "")
			{
				Send {Ctrl down}
				Sleep 100
				Send {q down}
				Sleep 100
				Send {q up}
				Send {w down}
				Sleep 100
				Send {w up}
				Send {e down}
				Sleep 100
				Send {e up}
				Send {Ctrl up}
				Sleep 100
				Send {p down}
				Sleep 50
				Send {p up}
				Click, 271 343, right
				Sleep 50
				Send {p down}
				Sleep 50
				Send {p up}
				Sleep 50
				GameOpen = 0
				Click, 1215 595
				Send {q down}
				Sleep 50
				Send {q up}
				Sleep 5000
				Send {w down}
				Sleep 50
				Send {w up}
				Sleep 5000
				Send {e down}
				Sleep 50
				Send {e up}
				Sleep 5000
				GameOpen = 0
				Click, 1222 602
				Sleep 5000
				GameOpen = 0
				Click, 1227 612
				Sleep 50
				GameOpen = 0
				If WinActive("ahk_class RiotWindowClass")
				{
					GameOpen = 1
				}
				If (GameOpen = 0)
				{
					RedSideX = 0
					2minX := ""
				}
			}
			While (RedSideX > 0)
			{
				Send {Ctrl down}
				Sleep 100
				Send {q down}
				Sleep 100
				Send {q up}
				Send {w down}
				Sleep 100
				Send {w up}
				Send {e down}
				Sleep 100
				Send {e up}
				Send {Ctrl up}
				Sleep 100
				Send {p down}
				Sleep 50
				Send {p up}
				Click, 271 343, right
				Sleep 50
				Send {p down}
				Sleep 50
				Send {p up}
				Sleep 50
				GameOpen = 0
				Click, 1235 578
				Send {q down}
				Sleep 50
				Send {q up}
				Sleep 5000
				Send {w down}
				Sleep 50
				Send {w up}
				Sleep 5000
				Send {e down}
				Sleep 50
				Send {e up}
				Sleep 5000
				Click, 1240 587
				Sleep 5000
				Click, 1247 595
				Sleep 50
				GameOpen = 0
				If WinActive("ahk_class RiotWindowClass")
				{
					GameOpen = 1
				}
				If (GameOpen = 0)
				{
					RedSideX = 0
					2minX := ""
				}
			}
		}
	}
}

k666sper
Posts: 2
Joined: 13 Apr 2021, 13:06

Re: Error Missing "}"

Post by k666sper » 13 Apr 2021, 14:14

ohh man thank you a lot, I was using Notepad++ but I was so focused on the first column (?) since I was given the error message about the line after the Loop for some reason. Thanks again

Post Reply

Return to “Gaming Help (v1)”