Book demo Start trial

Get Clipboard content

Watch this video to understand how to use the clipboard to read text from the screen.

What you learn in this lesson

  • How to select text on the screen.
  • How to add this to the clipboard.
  • How to use the GetClipboard block in a flow.

Download the file used in the demo: getclipboard

Lesson Overview

Watch this video to understand how to use the clipboard to read text from the screen.

What you learn in this lesson

  • How to select text on the screen.
  • How to add this to the clipboard.
  • How to use the GetClipboard block in a flow.

Download the file used in the demo: getclipboard

In this video I will demonstrate the Get Clipboard building block.

 

Using the clipboard can solve some types of automation challenges that is hard to solve with image and text recognition.

The example I’m gonna show in this video, is reading some text in a situation where OCR could have difficulties: black text in a field with a dark grey background. Some systems use the grey background to indicate that the field is not editable, so it is a problem I have seen in real life scenarios.

I have created a small demo web page, that includes a field and a label.

  • Show demo web page

The field is non-editable and has a dark-grey background. On top of this I have added the value “1100550011”,which OCR could read as some l’s, o’ and s’es taken the dark background into consideration.

Instead of using OCR to get the value from the field, I’ll select the text, send a CTRL+C – which is a copy command in windows – and then use the Get Clipboard building block to get the value from the clipboard.

  • Focus in Leaptest

I’ll start by adding a Find Image building block and capturing the field label. I’m including just the leftmost pixel of the field.

  • Capture image

I’m using this building block to get the position where the text starts, so I’ll adjust the image position by moving the cross hair into the field.

  • Adjust position

Now that we have a position where the field starts, we can add a Drag Mouse building block to select the text in the field.

  • Add Drag Mouse

I’ll wire up the position from the image to the start position of the Drag Mouse building block.

  • Wire up the position from the start position

I’ll add an Offset Position building block to define the end position for the drag operation.

  • Add Offset Position

I’m capturing an offset value that will move the position from the start of the field to the end of the field.

  • Capture offset vector

And then I’ll connect the offset position to the end position of the Drag Mouse.

Running this should put the mouse pointer at the start of the field and then select the text in the field.

Let’s run the case.

  • Run case

Voila. Text selected.

The next thing is to use a Type Text building block to send a “CTRL-C” to copy the selected text to the clipboard.

  • Add Type Text

I’m activating “Capture” to add the “CTRL-C” combination into the text field.

The last things to do is to get the clipboard back, and write this as a message to the activity log.

  • Add Get Clipboard
  • Add Log Message
  • Wire up text with message

Now the text selected should be copied to the clipboard and then printed in the log.

Let’s run the case.

  • Run case.

As we can see, the number was correctly returned from the clipboard.

In this video I demonstrated how to use the Get Clipboard building block to get values from an application into the workflow in Leaptest.

This ends this video.