Stepping Through An Array

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
CyberCitizen
Automation Wizard
Posts: 720
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Stepping Through An Array

Post by CyberCitizen » Thu Sep 12, 2019 2:56 am

Hi Guy's,

Been absent for a bit, but hoping you can help me.

I have a website I am needing to automate part of the screen using image capture and then clicking on said location.

The screen looks like this
Image

I am needing to find all the Hyphens (Dashes). I am using an exact match to put them into an Array. I am then needing to step through the Array clicking on the location of the dash. Note I am using a screen capture to limit the search location as such there is the MouseMove>{%DashXArr_0%+767},{%DashYArr_0%+402} command but I am stuck trying to workout out how to step through the array getting each position and being able to mouse move to that location. I think I am having a brain fart in my old age, please help.

[snippet=]//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_10.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,DashXArr,DashYArr,DashNumFound,EXACT
If>NumFound>0
MouseMove>{%DashXArr_0%+767},{%DashYArr_0%+402}
LClick
Wait>0.5
EndIf
Endif[/snippet]
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3282
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Stepping Through An Array

Post by JRL » Fri Sep 13, 2019 1:15 pm

Hi Cy.
Welcome back!
I don't have time to test but this should be close and you'll understand the concept.

Code: Select all

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_10.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,DashXArr,DashYArr,DashNumFound,EXACT
If>NumFound>0
  Let>kk=-1
  Repeat>kk
    Add>kk,1
    Let>XMove=DashXArr_%kk%
    Let>YMove=DashYArr_%kk%
    MouseMove>{%XMove%+767},{%YMove%+402}
    LClick
    Wait>0.5
  Until>kk={%DashNumFound%-1}
EndIf

User avatar
CyberCitizen
Automation Wizard
Posts: 720
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Stepping Through An Array

Post by CyberCitizen » Thu Oct 03, 2019 4:43 am

Thanks JRL,

Got it working successfully now, turns out I was a little rusty in my MS Coding. Once I stopped and thought about it overnight it came back to me.
FIREFIGHTER

Post Reply