I need help for my script. (Newbie)

Ask gaming related questions
akatsura
Posts: 3
Joined: 25 Apr 2016, 14:13

I need help for my script. (Newbie)

25 Apr 2016, 15:18

Hi guys. Im trying to make script for game called "memomonkey". But i stuck.The game is android game and i m running it by bluestacks. Image search doesnt work in bluestacks i think . here is my code. (Sorry for bad english)

Code: Select all

0:

Loop {

x1 := 0
y1 := 0
x2 := 0
y2 := 0
x3 := 0
y3 := 0

1:

CoordMode, Pixel
ImageSearch, x1, y1, 0, 0, 1920, 1080, *5 C:\Users\Abdullah Kırmızıyüz\Pictures\memomonkey\1.png
If ErrorLevel = 0
	CoordMode, Pixel
	ImageSearch, x2, y2, 0, 0, 1920, 1080, *5 C:\Users\Abdullah Kırmızıyüz\Pictures\memomonkey\2.png
	If ErrorLevel = 0
		CoordMode, Pixel
		ImageSearch, x3, y3, 0, 0, 1920, 1080, *5 C:\Users\Abdullah Kırmızıyüz\Pictures\memomonkey\3.png
		If ErrorLevel = 0
			Goto, 2
		If ErrorLevel = 1
			Goto, 1
	

}

2:
Sleep 1500

Click, %x1%, %y1% Left, 1

Click, %x2%, %y2% Left, 1

Click, %x3%, %y3% Left, 1

goto, 0
User avatar
Flarebrass
Posts: 104
Joined: 20 Nov 2015, 13:13
Location: USA
Contact:

Re: I need help for my script. (Newbie)

26 Apr 2016, 06:42

CoordMode only needs to be specified at the beginning of your script to affect the entire script. If you want to switch CoordMode styles mid-script and then revert styles later on, then you can specify CoordMode at each change.

You also need brackets in AHK since it doesn't recognize indentations like Python does.

I've cleaned up your code a bit, but getting it to recognize your images is a different story; I don't have your game and I don't have your image files, so I can't test anything for functionality. Note that your script clicks the very topleft corner of the image that has been found, so if you're trying to click a button and the image file contains the entire button, your click may miss the button. To remedy this, you either need to click at an offset such as Click, % x1+10, % y1+10 (assuming that syntax works) or you need to edit your image file to only include the bottomright corner of the button you're searching for.

Code: Select all

CoordMode, Pixel, Screen

x1 := 0
y1 := 0
x2 := 0
y2 := 0
x3 := 0
y3 := 0

Loop
{
	ImageSearch, x1, y1, 0, 0, 1920, 1080, *5 C:\Users\Abdullah Kırmızıyüz\Pictures\memomonkey\1.png
	If (ErrorLevel = 0)
	{
		ImageSearch, x2, y2, 0, 0, 1920, 1080, *5 C:\Users\Abdullah Kırmızıyüz\Pictures\memomonkey\2.png
		If (ErrorLevel = 0)
		{
			ImageSearch, x3, y3, 0, 0, 1920, 1080, *5 C:\Users\Abdullah Kırmızıyüz\Pictures\memomonkey\3.png
			If (ErrorLevel = 0)
				GoSub, 2
		}
	}
	Sleep, 10
}
return

2:
Sleep, 1500
Click %x1% %y1%
Click %x2% %y2%
Click %x3% %y3%
return
(Note that I can't test my code before posting, so beware of bugs! -Flarebrass Amatzikahni)
akatsura
Posts: 3
Joined: 25 Apr 2016, 14:13

Re: I need help for my script. (Newbie)

30 Apr 2016, 10:46

I will try it. But real problem is Bluestacks i think. Because i can run script over my screenshots of game. But in Bluestacks it didnt work.
akatsura
Posts: 3
Joined: 25 Apr 2016, 14:13

Re: I need help for my script. (Newbie)

30 Apr 2016, 11:31

I tried your code too but it didnt work. Now im changing my emulator. Maybe it will work.
User avatar
Flarebrass
Posts: 104
Joined: 20 Nov 2015, 13:13
Location: USA
Contact:

Re: I need help for my script. (Newbie)

02 May 2016, 05:20

You might find this thread useful: Make AHK work in most games
(Note that I can't test my code before posting, so beware of bugs! -Flarebrass Amatzikahni)

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 10 guests