Hey guys, I just started using AHK so I'm new to all this. What I want to do is have my mouse look for certain images then have it click them. I've been reading the docs on ImageSearch and have been messing around with it but I can't seem to understand how to get it to work. Hoping I can get some help with it here, thanks a lot.
Trouble understanding ImageSearch
Started by
HotkeyStick
, May 27 2012 04:29 AM
7 replies to this topic
#1
Posted 27 May 2012 - 04:29 AM
#2
Posted 27 May 2012 - 08:07 AM
Okay, post your script and we will help you to understand the ImageSearch command
#3
Posted 27 May 2012 - 09:55 AM
Well, the thing is I have next to no idea what I'm doing. Maybe someone could point me in the right direction or throw me an example script to help me get started?
#4
Posted 27 May 2012 - 02:25 PM
So it will be something like this:ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile
ImageSearch, outx, outy, 0, 0, 1024, 768, c:\folder\image.bmp if ErrorLevel = 0 ; if success then... MsgBox Image found at X:%outx% Y:%outy%. return
#5
Posted 27 May 2012 - 07:49 PM
So I pasted the code and replaced the c:\folder\image.bmp with my image location but nothing happens when I come across the image on screen. What am I missing here?
#6
Posted 27 May 2012 - 08:02 PM
Try to use color shade variation
ImageSearch, outx, outy, 0, 0, 1024, 768, *5 c:\folder\image.bmp if ErrorLevel = 0 ; if success then... MsgBox Image found at X:%outx% Y:%outy%. else MsgBox ErrorLevel = %ErrorLevel% return
#7
Posted 27 May 2012 - 08:41 PM
Okay, using this one gives me a popup with the coords if the image is found. How can I make it so that my mouse moves to the coords and right-clicks it instead of giving the popup?
#8
Posted 28 May 2012 - 02:35 AM
You should really read the Helpfile, it can be found at the AHK installation folder. You need MouseMove or MouseClick, or just Click.




