Sign in to follow this  
Followers 0
twister06

Recognize image in game

4 posts in this topic

First of all, yes I have searched but I haven't found what I'm looking for.

Also, I'm somewhat of a noob, so if possible explain to me in the easiest way possible :D

I need my script to recognize an image in a game. Problem is that the image is moving on the screen and it is animated, changing the color somewhat in a loop of about 1-2 seconds.

I need my script to locate this image and click it, but I have no idea how to do it. First I tried using PixelSearch, but it didn't work out too well. Could be because I'm a noob of course.

I've never used PixelSearch before, but if it works the way I think it does I have another problem. There are two images on the screen at one time with the same colors but with small variations, and I need it to click only one of them.

What I was thinking was that I could screencap and crop the image and then tell AutoIt to compare what's on screen to the screencapped image. Don't know if this is possible though. Also, how the heck do I get AutoIt to click it once it's found?

Any help or other suggestions would be appreciated.

Share this post


Link to post
Share on other sites



I'm a noob too so don't feel bad...I have no idea how to get it to recognize the image but I do know how to get it to click it if you know where it pops up...

First use this script...I found it on www.edgeofnowhere.cc and it's very useful for finding pixelcolors and mouse postions:

; Script Start - Add your code below here
Opt("CaretCoordMode", 0) 
Opt("MouseCoordMode", 0) 
Opt("PixelCoordMode", 0) 

#include <File.au3> 
#include <String.au3> 
#include <Misc.au3> 

HotKeySet("{HOME}", "MousePos") 
HotKeySet("{END}", "Terminate") 
HotKeySet("{INSERT}", "TestMe") 

While 1 
   Sleep(100) 
WEnd 

Func MousePos() 

Global $pos = MouseGetPos() 
MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1]) 
Sleep(5) 
$var = PixelGetColor( $pos[0], $pos[1] ) 
$var = PixelGetColor( $pos[0] , $pos[1] )
MsgBox(0,"The decmial color is", $var)
MsgBox(0,"The hex color is", Hex($var, 6))

_FileWriteLog(@SCRIPTDIR & "\Activity.log","[MOUSE POSITION] " & $pos[0] & " " & $pos[1]) 
_FileWriteLog(@SCRIPTDIR & "\Activity.log","") 
_FileWriteLog(@SCRIPTDIR & "\Activity.log","[MOUSE COLOR] " & $var) 
_FileWriteLog(@SCRIPTDIR & "\Activity.log","") 
EndFunc 

Func Terminate() 
   Exit(0) 
EndFunc 

Func TestMe() 
MouseClick("left", 315,480, 1, 0) 
EndFunc

In my game it won't recognize the colors so I have to print screen and paste in paint then use this script to get the colors. For the mouse postions, just hit Home using this and it will tell you the coordinates then type in autoit

Opt("MouseCoordMode", 0) 
MouseMove(x,y,10)
     Sleep (500)
     MouseClick("left", x, y, 1, 10)

If this isn't what you were looking for then sorry for my noobish response...I've only been working with autoit for a couple of days :D

Share this post


Link to post
Share on other sites

Thanks for the quick reply. I don't know exactly where it pops up, can this still be used?

Share this post


Link to post
Share on other sites

Thanks for the quick reply. I don't know exactly where it pops up, can this still be used?

Hmm...as I said I'm a noob, but this intrigues me...I think if autoit has a scanning function...I checked help in autoit and came up with $iScanLines I don't know if this is it or not....then you can use a combination of the script from edgeofnowhere and the scan to get the mouse postion...maybe

Ex: If you can get the scan to find the image then press home when it finds it, it should come up with the mouse postion...then it would need to enter the mouse postion into the x and y of the mouse move...

Sound's very very complicated...I think you need someone with more autoit experience :D I tried :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0