Using Position or Existence of One Image to Select Another Image...

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1378
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Using Position or Existence of One Image to Select Another Image...

Post by Dorian (MJT support) » Fri Apr 07, 2023 11:23 am

Having a better understanding and more time to digest scenario 2, and realising we're using EXACT and not CCOEFF, some adjustments were required. We also didn't need to find the top and bottom, as for those we can use the "middle right of image" offset to get our starting point.

Tested as working with this image. It will look for all of the red stars, capture a rectangle to the right of each star, and look for the green rectangle to the right of each star.

You may need to edit the tolerances (pay careful attention to the permitted values - they are different for EXACT and CCOEFF), and you will need to edit the offsets. Image_1 is the red star and Image_2 is the green rectangle.

Code: Select all

//Find Middle Right of 
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0,8,XArr,YArr,NumFound,EXACT

let>k=0
repeat>k
  Let>xpos=XArr_%k%
  Let>ypos=YArr_%k%

  //Edit these offets
  Let>top=ypos-55
  Let>bottom=ypos+55
  Let>right=xpos+400

  screencapture>xpos,top,right,bottom,%TEMP_DIR%\screenrect.bmp
  //executefile>%TEMP_DIR%\screenrect.bmp

  //Find and Left Click Center of 
  FindImagePos>%BMP_DIR%\image_3.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr2,YArr2,NumFound2,CCOEFF
  If>NumFound2>0
    MouseMove>{%XArr2_0%+%xpos%},{%YArr2_0%+%top%}
    LClick
  Endif

  wait>1
  let>k=k+1
Until>k,NumFound
Yes, we have a Custom Scripting Service. Message me or go here

rjw524
Pro Scripter
Posts: 104
Joined: Wed May 09, 2012 9:45 pm
Location: Michigan

Re: Using Position or Existence of One Image to Select Another Image...

Post by rjw524 » Mon Apr 10, 2023 3:41 pm

Hi Dorian,

I just now saw the updates here!

This worked PERFECTLY!

As far as the Edge question, I hadn't used MS again for a while until recently so I hadn't upgraded to the latest version.

If you think the latest version can grab or open these javascript elements in Edge then I'll upgrade immediately.

Thanks so much for this!

RJ

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1378
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Using Position or Existence of One Image to Select Another Image...

Post by Dorian (MJT support) » Mon Apr 10, 2023 3:48 pm

Always happy to help.

Yes, v15 should be able to click the buttons/images. Certainly a learning curve but one worth spending some time on.

Maybe try the v15 trial so you can test for free.
Yes, we have a Custom Scripting Service. Message me or go here

rjw524
Pro Scripter
Posts: 104
Joined: Wed May 09, 2012 9:45 pm
Location: Michigan

Re: Using Position or Existence of One Image to Select Another Image...

Post by rjw524 » Mon Apr 10, 2023 8:20 pm

I just decided to upgrade my MS to the latest version.

I'm trying out the Edge functions now.

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