Clicking X pixels left/right/above/below TIG found text

I?ve been searching & searching thru the forums for an example script that I know I saw some time ago & now need. Maybe you recall the script or example?

Here?s what I?m trying to do. My screen looks somewhat like this:

O New album: {some random default text________________________________+_______}

I?m trying to TIG find the ?new album? text, then click way to the right of the text at the plus sign above so I can backspace out the default chars & enter my own string. I?m looking for the example script that had commands such as above&toTheRight, toTheLeftOfFoundImage, etc.

Do you remember the thread/script I?m referring to? I believe it is similar to the ‘ImageOrientationExample.suite’ but not the same thing.

Thanks in advance for any & all responses.

Michael Brinlee
QA Manager

If you have the section of screen real estate that you are referring, capture it in Eggpant as .tiff and post it, or you can even use the cmd-shift-4 rect capture built into OS X. That helps avoid the character graphic drawing that so long ago went out of fashion while I was playing rogue at the UW campus in the late 70s :slight_smile:

You can always move the hotspot around in your TIG definition. When you find some text, just offset it from the topleft corner (0,0) of the TIG, to the point where you want the click to occur…

set (x, y) to (20, 10) -- go right 20 pixels, down 10
Click (Text: "Stuff To Find", HotSpot:(x, y))

You could always wrap that into a handler and call it…

to ClickNear   pt,  tigs...
	if pt is not a point then
		insert pt before tigs
		set pt to (0,0)
	end if
	repeat with each item in tigs
		Click (Text: it, HotSpot: pt )
	end repeat
end ClickNear

Which means you could then call it with…

ClickNear (20, 10), (“Stuff To Find”, More, “Stuff To Click”)

and Eggplant would attempt to find three strings and click to the right and below by 20 and 10 pixels respectively.

I’m not positive, but the example script you might be referring to deals with setting the search rectangle relative to another image:

In your case I think you can do what you want quite a bit more simply.

One option would be to just set the HotSpot property of the Text Image. This is measured from the top left of the image but can be outside the image area itself. So if your text field is 300 pixels wide you could do something like this:

click (text:"MyString", textfont:"Courier", HotSpot:(295,10))

A more sophisticated option would be to use some vector arithmetic to move a certain number of pixels (say 15) to the right of the found text image:

set myText to (text:"MyString", textfont:"Courier", HotSpot:(0,0))
click imageLocation(myText) + imageSize(myText) + (15,0)

Hopefully some of those work for you.

Jonathan, that was the example I was looking for, thanks!

Todd, excellent example. The HotSpot offset will do the trick nicely.

Also thanks for the pointer on posting a .tif, I’ll do that next time. Although I’m still a fan of the ASCII based Star Wars. (To see this classic, google ‘ASCII Star Wars’) :slight_smile: