help with macro using image search

Ask gaming related questions (AHK v1.1 and older)
emby62
Posts: 5
Joined: 22 Nov 2015, 23:54

help with macro using image search

24 Nov 2015, 21:26

so im trying to make a macro that will use image search to find and click something then move to another area and click a designated coordinate.
then accept the dialog by clicking the accept button (also do-able thorough image search i suppose)

its just clicking one of 40 icons which are all the same, then dragging and dropping it to a window and pressing accept. but there is no need to hold down the mouse button to drag.

im new to image search though and having problems using the syntax properly.

this all happens withing a game type application also.
grant
Posts: 323
Joined: 14 Oct 2015, 17:27

Re: help with macro using image search

25 Nov 2015, 02:34

You seem to have missed adding in your script that you need help with.

Imagesearch is sometimes a challenge to get working properly and even more so in games. Here is a starting point where you can fiddle with variables till you get what you are looking for as well as see what each variable is used for. You may have to compile and run your program in administrator mode, it all depends on the game.

Code: Select all

f4::
x1 := 0
y1 := 0
x2 := A_ScreenWidth
y2 := A_ScreenHeight
variation := 50
filename = C:\scripting\diablo2\rune.png

ImageSearch, FoundX, FoundY, x1, y1, x2, y2, *%variation% %filename%
if ErrorLevel = 2
	{
	MsgBox Could not conduct the search. Your file called %filename% does not exist
	return
	}
else if ErrorLevel = 1
	{
	MsgBox Your image %filename% could not be found on the screen.
	return
	}
else
	{
	mousemove, %foundx%, %foundy%
;	clipboard = %foundx%`, %foundy%										;un-comment this line to get the co-ordinates to your clipboard
	MsgBox The image %filename% was found at %FoundX%x%FoundY%.
	Return
	}
emby62
Posts: 5
Joined: 22 Nov 2015, 23:54

Re: help with macro using image search

25 Nov 2015, 12:14

grant wrote:You seem to have missed adding in your script that you need help with.

Imagesearch is sometimes a challenge to get working properly and even more so in games. Here is a starting point where you can fiddle with variables till you get what you are looking for as well as see what each variable is used for. You may have to compile and run your program in administrator mode, it all depends on the game.

Code: Select all

f4::
x1 := 0
y1 := 0
x2 := A_ScreenWidth
y2 := A_ScreenHeight
variation := 50
filename = C:\scripting\diablo2\rune.png

ImageSearch, FoundX, FoundY, x1, y1, x2, y2, *%variation% %filename%
if ErrorLevel = 2
	{
	MsgBox Could not conduct the search. Your file called %filename% does not exist
	return
	}
else if ErrorLevel = 1
	{
	MsgBox Your image %filename% could not be found on the screen.
	return
	}
else
	{
	mousemove, %foundx%, %foundy%
;	clipboard = %foundx%`, %foundy%										;un-comment this line to get the co-ordinates to your clipboard
	MsgBox The image %filename% was found at %FoundX%x%FoundY%.
	Return
	}
thank you! i pretty much figured it would be as easy as image search finding the image. clicking it. then moving to the right coordinate i define and clicking again. just need it to do that on loop. i shall experiment.
S1lver
Posts: 23
Joined: 07 Nov 2020, 04:14

Re: help with macro using image search

23 Jun 2022, 04:53

did you get this to work m8?

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 106 guests