Picture recognition

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 12, 2006 9:42 am

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?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri May 12, 2006 3:11 pm

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>

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

ok

Post by guyash2 » Fri Jun 09, 2006 9:25 am

Ok thank you two and sorry for the late reply

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts