read text from screen

Hi -
I've a requirement where in the script needs to read text from the screen and use it in next test step.

Can anyone please let me know if this is possible using eggplant or if someone has tried it out.



  • EggplantMattEggplantMatt ForumAdmin admin
    If the text is selectable, this is fairly easy to accomplish; you need to have your script highlight the text, then perform a copy action on the remote system. This will put the selected text on the clipboard of the remote system; you can then access it using the RemoteClipboard() function. An example would look like this:
    DoubleClick "somewhere" -- select a word
    TypeText controlKey, "c" -- copy it to the clipboard
    put RemoteClipboard() into myVar -- store the contents of the clipboard in a variable
    If the text isn't selectable, then the task is harder. It's possible to do a character by character match, but it's a slow process. Is this text infinitely variable, or are there just a few possible values? If it's just a few values, the easiest thing to do is use image capture and capture each of the possible values, then see which one Eggplant finds:
    WaitFor 5, "cat", "dog", "bird", "fish" -- each of these is an image of a word
    put FoundImageInfo().ImageName into myVar
Sign In or Register to comment.