Picture recognition
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
If I have understood you correctly you have several predefined images on disk and you want the macro to tell you which one of those is on the screen at a specific place. You can use the CompareBitmaps example. The only difference is that you will run it in a loop for each of the images on disk, and instead of taking the whole screen you will extract the portion of the screen which you want to compare against each image on disk. Alternatively use FindImgPos for each image against a dump of the entire screen and see which one returns as found.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Here is a sample of code which will take a screen shot of the current app, then search within that window for a specific bitmap file. this may be a good starting point for you. Try this, then we can discuss how to make it more complex.
Of course, you will need to edit the paths/files as yours are likely to differ.
Let>imglibDLL=C:\Program Files\MacroSchedulerImageLibrary\imglib.dll
LibLoad>imglibDll,imglib
Setfocus>YOUR APPLICATION
wait>3
GetActiveWindow>title,X,Y,W,H
IfFileExists>c:\screen.bmp
DeleteFile>c:\screen.bmp
EndIf>
ScreenCapture>X,Y,W,H,c:\screen.bmp
wait>3
LibFunc>imglib,FindImgPos,imgs,C:\Program Files\MJT\MacroScheduler\YourFile.bmp,c:\screen.bmp,20,1,ref:0,ref:0
If>%imgs%>0
Let>x=imgs_5+%x%
Let>y=imgs_6+%y%
mousemove>%x%,%y%
wait>1
LClick
else>
mdl>your image could not be located with the current app window
Endif>
Of course, you will need to edit the paths/files as yours are likely to differ.
Let>imglibDLL=C:\Program Files\MacroSchedulerImageLibrary\imglib.dll
LibLoad>imglibDll,imglib
Setfocus>YOUR APPLICATION
wait>3
GetActiveWindow>title,X,Y,W,H
IfFileExists>c:\screen.bmp
DeleteFile>c:\screen.bmp
EndIf>
ScreenCapture>X,Y,W,H,c:\screen.bmp
wait>3
LibFunc>imglib,FindImgPos,imgs,C:\Program Files\MJT\MacroScheduler\YourFile.bmp,c:\screen.bmp,20,1,ref:0,ref:0
If>%imgs%>0
Let>x=imgs_5+%x%
Let>y=imgs_6+%y%
mousemove>%x%,%y%
wait>1
LClick
else>
mdl>your image could not be located with the current app window
Endif>