search area determined by previous image location

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
faaramin
Newbie
Posts: 1
Joined: Mon Dec 30, 2019 3:50 pm

search area determined by previous image location

Post by faaramin » Tue Jan 28, 2020 5:08 pm

hi all,
I've looked but didn't find an answer so if i've missed something point me in the right direction pls. And yes im new to this so all help is appreciated, and if there some wizard/preset for a variable position like this pls advise.
but here is the situation:
i have to find an image and click it. easy. coded and working.
however i have situations where i have 2 of the same image in the search area. and as they change positions its not possible to lets say find both and click the first one.
however there is an image next to each of them that can be used to determine which one to click.
Yes i know there is an option where you can click right/left/above/below and image with a preset offset. but the distance between image 1 and image 2 is not always exactly the same. and except in one scenario its not in a straight line more like down and to the right (which i guess you can solve by 2 move mouse commands one for each direction). but the variable distance is the problem factor.

so tried to do that by defining the search area based on the location of that unique image.

so basically search for Image 1
find its location
use that location to determine the search area of the Image 2 (that one we need to click)

Code: Select all

ScreenCapture>6,160,647,703,%TEMP_DIR%\screenrect.bmp
//Find and Do Nothing Top Left of 
FindImagePos>%BMP_DIR%\image_1.bmp,%TEMP_DIR%\screenrect.bmp,0.7,0,XArr,YArr,NumFound,CCOEFF

**BREAKPOINT**
ScreenCapture>{%XArr_0%+6},{%YArr_0%+160},{%XArr_0%+435},{%YArr_0%+298},%TEMP_DIR%\screenrect.bmp
//Find and Left Click Center of 
FindImagePos>%BMP_DIR%\image_2.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>{%XArr_0%+159},{%YArr_0%+576}
  LClick
Endif
طراحی سایت هتل طراحی سایت رستوران طراحی سایت املاک طراحی سایت دانشگاه طراحی سایت سازمانی طراحی سایت کلینیک طراحی سایت آموزشگاه طراحی سایت آژانس مسافرتی طراحی سایت نیاوران طراحی سایت ولنجک طراحی سایت سعادت آباد طراحی سایت قیطریه
so this was my attemtp to make that work:

Code: Select all

ScreenCapture>{%XArr_0%+6},{%YArr_0%+160},{%XArr_0%+435},{%YArr_0%+298},%TEMP_DIR%\screenrect.bmp
طراحی سایت the stab in the dark actually miraculously worked, confirmed by checking the created screenrect.bmp in the temp directory :)

but here is where i run out of luck. and can't figure out how to solve
ثبت دامنه

Code: Select all

 If>NumFound>0
  MouseMove>{%XArr_0%+159},{%YArr_0%+576} 
since 159 & 576 are original X,Y starting coordinates for the ScreenCapture/search area i determined in the Image recognition Wizard before i adjusted it to the variable one.
بلیط هواپیما but because the X,Y are not static and thus incorrect the mouse obviously moves to the wrong place.
so it should read something to the effect of:

Code: Select all

If>NumFound>0
  MouseMove>{%XArr_0%+(old%XArr_0%+6) },{%YArr_0%+(old%XArr_0%+160)}
طراحی سایت فروشگاهی طراحی سایت شرکتی تبلیغات گوگل طراحی سایت صنعتی طراحی سایت پزشکی طراحی سایت ارزان طراحی سایت بیمارستان طراحی سایت مدرسه سئوکار

except i have no clue how to tell it to use the original XArr_0, from image 1 at this point.

thanks for the help
Last edited by faaramin on Sat Feb 08, 2020 2:44 pm, edited 2 times in total.

DreamTheater
Newbie
Posts: 19
Joined: Mon Oct 14, 2019 6:23 am

Re: search area determined by previous image location

Post by DreamTheater » Wed Jan 29, 2020 6:43 am

The FindObject Wizard under Window Objects may be useful.
If it's a website then try the IE Element Wizard under WebRecorder Functions.


What sort of application/website is it? I try to use image recognition as a last resort, there might be an easier way to achieve this, especially if it's a website.

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

Re: search area determined by previous image location

Post by Dorian (MJT support) » Wed Jan 29, 2020 12:21 pm

DreamTheater wrote:
Wed Jan 29, 2020 6:43 am
The FindObject Wizard under Window Objects may be useful.
If it's a website then try the IE Element Wizard under WebRecorder Functions.


What sort of application/website is it? I try to use image recognition as a last resort, there might be an easier way to achieve this, especially if it's a website.
I totally agree. That's my rule of thumb too. When writing custom scripts I usually only resort to Image Recognition as a "catch-all" when all other methods have failed.

@faaramin, it might also help you to know that if you go here and type "wizard" the first few suggestions will be all the Macro Scheduler wizards.
Yes, we have a Custom Scripting Service. Message me or go here

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