Skip to content

Mouse

Using the methods below, you can control and obtain information from the mouse.

Getting mouse coordinates

If you want to get the mouse coordinate, use the methods below to get the X and Y position of the mouse.

# To get the last coordinate that was saved from the mouse.
x = bot.get_last_x()
y = bot.get_last_y()

print(f'The last saved mouse position is: {x}, {y}')
// To get the last coordinate that was saved from the mouse.
int x = getLastX();
int y = getLastY();

System.out.printf("The last saved mouse position is: %d, %d", x, y);

Moving to a coordinate

To move the mouse to a coordinate, use the method below.

# Moving the mouse to the position x=100 and y=200.
bot.mouse_move(x=100, y=200)
// Moving the mouse to the position x=100 and y=200.
mouseMove(100, 200);

Moving the mouse

If you want to move the mouse to an element, use the methods below.

You can move directly to an element, you can move to a position relative to the position of the found element or to a random position on the page.

Note

The find() is used to look for the element and collect its position. Click here for more information.

# Looking for the element on the page with the label 'SubmitForm'.
if bot.find(label='SubmitForm', matching=0.97, waiting_time=10000):
    # moving directly to the element found
    bot.move()

    # Moving to the position x=100 and y=200 relative to the element found.
    bot.move_relative(x=100, y=200)


# Moving the mouse to a random position within a range x=100 and y=200.
bot.move_random(range_x=100, range_y=200)
// Looking for the element on the page with the label 'SubmitForm'.
if (find("SubmitForm", 0.97, 10000)) {
    // Moving directly to the element found.
    move();

    // Moving to the position x=100 and y=200 relative to the element found.
    moveRelative(100, 200);
}


// Moving the mouse to a random position within a range x=100 and y=200.
moveRandom(100, 200);

Clicking on a coordinate

If you need to click on a position on the page use the method below.

# Left click on the position x=100 and y=200.
bot.click_at(x=100, y=200)

# Right click on the position x=100 and y=200.
bot.right_click_at(x=100, y=200)
// Left click on the position x=100 and y=200.
clickAt(100, 200)

// Right click on the position x=100 and y=200.
rightClickAt(100, 200);

Clicking on the element

If you want to click on the element, use the methods below.

You can click directly on the element or click on a relative position of the found element.

Note

The find() is used to look for the element and collect its position. Click here for more information.

# 'SubmitForm' is the label of the element that will be clicked.
bot.click_on(label='SubmitForm')


# Looking for the element on the page with the label 'SubmitForm'.
if bot.find(label='SubmitForm', matching=0.9, waiting_time=10000):
    # Left click on the element found.
    bot.click()

    # Right click on the element found.
    bot.right_click()


# Looking for the element on the page with the label 'SubmitForm'.
if bot.find(label='SubmitForm', matching=0.9, waiting_time=10000):
    # Left click on the position x=100 and y=200 relative to the element found.
    bot.click_relative(x=100, y=200)

    # Right click on the position x=100 and y=200 relative to the element found.
    bot.right_click_relative(x=100, y=200)
// 'SubmitForm' is the label of the element that will be clicked.
clickOn("SubmitForm");


// Looking for the element on the page with the label 'SubmitForm'.
if (find("SubmitForm", 0.97, 10000)) {
    // Left click on the element found.
    click();

    // Right click on the element found.
    rightClick();
}


// Looking for the element on the page with the label 'SubmitForm'.
if (find("SubmitForm", 0.97, 10000)) {
    // Left click on the position x=100 and y=200 relative to the element found.
    clickRelative(100, 200);

    // Right click on the position x=100 and y=200 relative to the element found.
    rightClickRelative(100, 200);
}

Double-click on the element

If you need to double-click on the element or double-click on a relative position of the element, use the methods below.

Note

The find() is used to look for the element and collect its position. Click here for more information.

# Looking for the element on the page with the label 'SubmitForm'.
if bot.find(label='SubmitForm', matching=0.97, waiting_time=10000):
    # Double click on the element found.
    bot.double_click()

# Looking for the element on the page with the label 'SubmitForm'.
if bot.find(label='SubmitForm', matching=0.97, waiting_time=10000):
    # Double click on the position x=100 and y=200 relative to the element found.
    bot.double_click_relative(x=100, y=200)
// Looking for the element on the page with the label 'SubmitForm'.
if (find("SubmitForm", 0.97, 10000)) {
    // Double click on the element found.
    doubleClick();
}

// Looking for the element on the page with the label 'SubmitForm'.
if (find("SubmitForm", 0.97, 10000)) {
    // Double click on the position x=100 and y=200 relative to the element found.
    doubleClickRelative(100, 200);
}

Triple click on the element

If you need to triple-click on the element or triple-click on a relative position of the element, use the methods below.

Note

The find() is used to look for the element and collect its position. Click here for more information.

# Looking for the element on the page with the label 'SubmitForm'.
if bot.find(label='SubmitForm', matching=0.97, waiting_time=10000):
    # Triple click on the element found.
    bot.triple_click()

# Looking for the element on the page with the label 'SubmitForm'.
if bot.find(label='SubmitForm', matching=0.97, waiting_time=10000):
    # Triple click on the position x=100 and y=200 relative to the element found.
    bot.triple_click_relative(x=100, y=200)
// Looking for the element on the page with the label 'SubmitForm'.
if (find("SubmitForm", 0.97, 10000)) {
    // Triple click on the element found.
    tripleClick();
}

// Looking for the element on the page with the label 'SubmitForm'.
if (find("SubmitForm", 0.97, 10000)) {
    // Triple click on the position x=100 and y=200 relative to the element found.
    tripleClickRelative(100, 200);
}

Pressing and releasing the mouse button

To press and release the mouse button use the methods below, currently only the left button is supported.

# Pressing the mouse button.
bot.mouse_down()

# Peleasing the mouse button.
bot.mouse_up()
// Pressing the mouse button.
mouseDown();

// Releasing the mouse button.
mouseUp();

Scroll through the page

If you need to navigate through the page by scrolling up or down, use the methods below.

# Scroll up 10 times.
bot.scroll_up(clicks=10)

# Scroll down 10 times.
bot.scroll_down(clicks=10)
// Scroll up 10 times.
scrollUp(10);

// Scroll down 10 times.
scrollDown(10);