Book demo Start trial

Drive mouse actions

Watch this video to learn how to instrument windows using the mouse.

What you will learn

  • How to use the DragMouse building block to move icons.
  • How to hover an image and other positions.
  • How to offset a position.
  • How to reposition an element in Windows

Lesson Overview

Watch this video to learn how to instrument windows using the mouse.

What you will learn

  • How to use the DragMouse building block to move icons.
  • How to hover an image and other positions.
  • How to offset a position.
  • How to reposition an element in Windows

In this video I’ll show you some examples of how to use the Leaptest building blocks to automate different parts of windows.

  • Show desktop

I have 4 copies of the same adobe icon on my desktop and I’m gonna use these icons to show you how to drag with the mouse, how to hover an object with the mouse. I’m also gonna show how to re-position elements and how to transfer values between individual building blocks.

First I’ll add a Find Image building block.

  • Add Find Image.

Then I’ll capture one of the icons on the desktop.

  • Capture icon.

In order to visualize that icon was found, I’ll add a Hover Position building block after the Find Image building block. The Hover Position building block will move the mouse to the specified position so it will hover any element at that position.

I’m wiring up the position where the icon was found with the Hover Position and run the test case.

  • Run case

As you can see the mouse was moved to the first icon – meaning the icon that is at the top.

The Find Image building block will actually find all the icons, so if I change the “Use occur.” to 3, we should see the mouse hover the third icon from the top.

  • Run case

As you can see it went straight to the third icon and hovered it. If we set the “Use occur” to all, we are actually setting up an iteration. This means the Find Image building block will iterate all the 4 icons and trigger the green connector at the top for all the four icons.

Let’s see that in action.

  • Run case

So all of the icons were now hovered in turn.

Another thing we can do with the iteration is to move the icons. I’ll replace the Hover Position building block with a Drag Mouse building block.

  • Add Drag Mouse

This building block will press the left mouse button while moving the mouse from the start position to the end position.

We will use the position where the icons are found as the start position and then set a new end position for each of them. We will use an Offset Position building block to calculate the new end position.

  • Drag wire from position found
  • Add Offset Position

The input to the Offset position is the position where the icons are found. By specifying an offset value we will get the end position. I’ll right-click the offset value and select “Capture the position offset”.

  • Draw a vector

This allows me to draw a vector on the screen which will be added to the start position and thereby calculate the end position.

  • Organize canvas

Let’s run the test case

  • Run case

So all the icons are moved according to the offset position we specified. We could run the test case again to see them moved even further.

  • Run case

This is an example of using positions and how to re-position elements by using the drag mouse. The last example is kind of the same, but instead of using an Offset Position we will move the icons to the recycle bin.

I’ll add another Find Image building block and capture the recycle bin.

  • Add Find Image
  • Capture Recycle bin

Then I use the position found as the end position for the drag mouse.

Let’s run the test case.

  • Run case

And the clean up is done which also signals the end of this video.