Need help with 2 image click function

Hi,

How would I create a function that would take 2 images and use the first image as the Search location and the 2nd image to click on?

For example, the first image might be UniqueName and the second image would be a dropdown button that is common to the page.

I don't want to use hotspot because the button might change location and I can't just use the 2nd image because its not unique.

This is something I am trying out.


************************************************
function TwoImageInput SearchImage, ClickImage

put imageLocation (SearchImage) into newloc
put newloc into newsideloc
add (0, -30) to newloc
add (100,20) to newsideloc

repeat

try


Click ( imageName: ClickImage, searchRectangle: ( newloc, newsideloc ) )
exit repeat
catch
add (100, 0) to newsideloc
end try
end repeat
end TwoImageInput

************************************************

Is there a better way to do this?

Thanks,
David

Comments

  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    Your script is a clever approach to searching an increasingly wide area of the screen. But there is a problem with it: What happens if clickImage isn't found at all? To fix this you would also need to check whether you've expanded your search rectangle all the way to the edge of the screen and give up at that point.

    A simpler approach, I think, would be to simply look at all of the screen to the right of and below the searchImage. Keep in mind that Eggplant always scans the screen (or the searchRectangle) from left to right, starting at the top and working its way down. So if what you want is to click on the first occurrence of the clickImage that's to the right of (and possibly lower on the screen, but not higher than) the searchImage then this will work.

    There is a collection of functions that makes this very easy to do, posted here in our Examples forum: http://www.redstonesoftware.com/phpBB2/viewtopic.php?t=87

    To search below and to the right of your image using these functions, all you need to do is this:
    Click ( imageName:clickImage, searchRectangle: RightOfAndBelow(searchImage) )
    
    Simpler? :-)
Sign In or Register to comment.