Getting the value from the dropdown list with TIG

I have following contents in the dropdown box.
Chinese Newspaper ? Morning
Chinese Newspaper ? Evening
English Newspaper ? Morning
English Newspaper ? Evening

I tried to use the following code to step through each of the items in the dropdown list, the last two items could not be found. I understand, having TIG to find all the words, it may not be a good idea. But this is the only way that I can think of so far. Any better solutions to get around this problem?

Set NewspaperTypeList to (“Morn”, “Even”, “English News”, “English Newspaper - Evening”)
Repeat with each Newspaper in NewspaperTypeList
Run SelectNewspaper NewspaperTypeList
End Repeat

on SelectNewspaper NewspaperType
Click NewspaperType
End SelectNewspaper

Can anyone help me with this problem?

We understand that the TIG may not always match perfectly when whole phrases are used, due to slight differences in word spacing or the like. Sometimes using fractional text sizes can help, but assuming that still won’t work, here are a couple other ideas:

  1. Search for combinations of words. For example, to find the Chinese Newspaper - Evening item, you would find all of the places where “Chinese” appears and all of the places where “Evening” appears and then click the location where they both appear on the same line. Something like this might do the trick:
put everyImageLocation(text:"Chinese") into languageLocs
put everyImageLocation(text:"Evening") into editionLocs
repeat with each location of languageLocs
    repeat with each item of editionLocs
        if location.y - it.y is between -3 and 3 then
            Click location
            exit repeat
        end if
    end repeat
end repeat

Here I allowed for the y locations to be slightly off from each other (up to 3 pixels higher or lower) and still be considered on the same “line”, since the TIG-generated images may differ somewhat (for example, the “g” in “Evening” descends below the text baseline, but “Chinese” doesn’t have any descenders).

  1. If that seems too complex or doesn’t work for some reason, you might consider a totally different approach using coordinate calculations. Since you say you want to step through each of the items, you might simply find the top item, then add to the y coordinate of the location each time through your loop:
put imageLocation(text:"Chinese") into location
repeat 4 times
    Click location
    add (0,30) to location
end repeat

This assumes the distance between items in the list is 30 pixels – you’ll need to adjust that to represent the actual distance.

Hopefully one of these will help you!

Are these values dynamically generated? Will there be a lot more of them? If not, the best plan of attack is to simply capture images of them and not try to use the Text Image Generation feature. The TIG is great in some applications, but it’s not always the answer just because text is involved.

It tends to be the spaces between words that throw off the generated text images. We hope to provide more control over the fine-tuning of these images in the future.