Image recognition question

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Image recognition question

Post by mightycpa » Wed Nov 08, 2006 2:59 pm

Hi,

I saw the demo about how to automate non-standard GUI applications (JAVA!), and I really like it... the find an image within an image thingy is really cool.

I have a question about the opposite of that, I guess. I have a Java application where a dialog box pops up, you enter some data and click the button (so far, so good). But next, the app does some data validation before the box disappears, and only the main screen is visible. The length of time that this takes varies, and using a "wait" command really slows down my app. I process thousands of records overnight, and a wait here, wait there really adds up. Right now, I'm using another product to do this, but there is an opportunity to switch, and I'd like to be able to make the switch.

How can I pause to detect the disappearance of an image within an image (i.e., box goes away) before proceeding with the next command?

Tx,

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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

Post by Marcus Tettmar » Wed Nov 08, 2006 3:08 pm

So to wait for an image to disappear just use FindImagePos in a loop:

Code: Select all

Label>WaitForDisappear
  ScreenCapture>x1,y1,x2,y2,c:\screen.bmp
  FindImagePos>c:\DialogImage.bmp,c:\screen.bmp,.....etc...
  Wait>0.2
  If>imgs>0,WaitForDisappear
So if the image is found, it loops back and checks again. It keeps looping until the image is no longer present.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Post by mightycpa » Wed Nov 08, 2006 3:26 pm

Hi,

That's great, thanks... I guess if there's different data in the box, I need to be careful about what image I originally select, perhaps just the title bar of the dialog vs. the entire thing.

Also, does it matter exactly where the dialog box pops up? So, for instance, if the Java app is maximized, and that is my main canvas that I'm working from, and the dialog box pops up on top in slightly different positions over time (this usually happens with new releases of the application), but the title bar of the dialog box stays the same, I can cope with that change without modifying code. Is that correct?

Great product Marcus, thanks.

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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

Post by Marcus Tettmar » Wed Nov 08, 2006 3:31 pm

Yes, I would use the title bar, or a part of the title bar. Something that identifies the box and doesn't change.

No, doesn't matter where the dialog appears assuming the ScreenCapture command is set to capture the entire screen. Sometimes it is useful to have the ScreenCapture only capture a portion of the screen - like a specific window. This is good when we know the image will only appear within those bounds. But if it could be anywhere on the entire screen, then have the ScreenCapture command capture the entire screen (Use GetScreenRes before the loop/top of script to determine the bounds first).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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