How to scroll a table precisely using Image Recognition

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
uniadv
Junior Coder
Posts: 29
Joined: Tue Aug 04, 2020 2:16 am

How to scroll a table precisely using Image Recognition

Post by uniadv » Wed Oct 14, 2020 8:01 am

Hi,

I wanted to scroll a table precisely to do some data collection. Here i can't use Arrow Down Key to scroll because it is not precise. Here is an example table:

Image

I was thinking to scroll it using vertical slider and use image recognition make it precise.

What if we capture the Image from Blue Color Box and scroll the table by one step coordinate (y-axis) using MouseMove and check that image same image in Red Color Box, and repeat the loop until the image will be found inside the red box.

Image


Here i cant fix the coordinates in MouseMove because the number of rows are keep on changing in the table so one time it works but other time the script break down.

Is the above method possible to scroll or is there any better alternative for that?
Thanks!

Regards,
Ushahra

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

Re: How to scroll a table precisely using Image Recognition

Post by Dorian (MJT support) » Wed Oct 14, 2020 9:04 am

Just a couple of ideas.

If the scroll bar is always in the same X position you could always use GetPixelColor in a vertical loop until you find green, and then drag the mouse down a few pixels.

Adjust coordinates and increments to suit..

Code: Select all

//Green bar is always at 2890
let>Xpos=2890
Let>Ypos=840

While>PixCol<>5296274
  GetPixelColor>Xpos,Ypos,PixCol
  Let>Ypos=Ypos+25
Endwhile

If>PixCol=5296274
  mousemove>Xpos,Ypos
  Ldown
  mousemove>Xpos,{(%Ypos%+50)}
  LUp
Endif
Image Recognition might be quicker though. Look for the green bar, and drag it 50 pixels..

Code: Select all

FindImagePos>...
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  Ldown
  MouseMove>XArr_0,{(%YArr_0%+50)}
  Lup
Endif
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