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 mouse coordinate.
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);
// To get the mouse coordinate.
const x = desktopBot.getLastX()
const y = desktopBot.getLastY()

console.log(`The last saved mouse position is: ${x}, ${y}`)
// To get the mouse coordinate.
const x: number = desktopBot.getLastX()
const y: number = desktopBot.getLastY()

console.log(`The last saved mouse position is: ${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.
moveTo(100, 200);
// Moving the mouse to the position x=100 and y=200.
await desktopBot.moveMouse(100, 200)
// Moving the mouse to the position x=100 and y=200.
await desktopBot.moveMouse(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 or move to a position relative to the position of the found element or to a random position on the screen.

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);
// Looking for the element on the page with the label 'SubmitForm'.
if (await desktopBot.find('SubmitForm')) {
    const center = this.state.center()
    await desktopBot.moveMouse(center.x, center.y)

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

// Moving the mouse to a random position within a range x=100 and y=200.
await desktopBot.moveRandom(100, 200)
// Looking for the element on the page with the label 'SubmitForm'.
if (await desktopBot.find('SubmitForm')) {
    const center: object = this.state.center()
    await desktopBot.moveMouse(center?.x, center?.y)

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

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

Clicking on a coordinate

If you need to click on a position on the screen 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);
// Left click on the position x=100 and y=200.
await desktopBot.clickAt(100, 200)

// Right click on the position x=100 and y=200.
await desktopBot.clickAt(100, 200, 'right')
// Left click on the position x=100 and y=200.
await desktopBot.clickAt(100, 200)

// Right click on the position x=100 and y=200.
await desktopBot.clickAt(100, 200, 'right')

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):
    # Clicking 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):
    # Clicking 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)) {
    // Clicking 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)) {
    // Clicking 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);
}
// 'SubmitForm' is the label of the element that will be clicked.
await desktopBot.clickOn('SubmitForm')


// Looking for the element on the page with the label 'SubmitForm'.
if (await bot.find('SubmitForm') !== null) {
    // Clicking on the element found.
    await desktopBot.click()

    // Right click on the element found.
    await desktopBot.click('right')
}

// Looking for the element on the page with the label 'SubmitForm'.
if (await desktopBot.find('SubmitForm') !== null):
    // Clicking on the position x=100 and y=200 relative to the element found.
    await desktopBot.clickRelative(100, 200)

    // Right click on the position x=100 and y=200 relative to the element found.
    await desktopBot.clickRelative(100, 200, 'right')
// 'SubmitForm' is the label of the element that will be clicked.
await desktopBot.clickOn('SubmitForm')


// Looking for the element on the page with the label 'SubmitForm'.
if (await bot.find('SubmitForm') !== null) {
    // Clicking on the element found.
    await desktopBot.click()

    // Right click on the element found.
    await desktopBot.click('right')
}

// Looking for the element on the page with the label 'SubmitForm'.
if (await desktopBot.find('SubmitForm') !== null):
    // Clicking on the position x=100 and y=200 relative to the element found.
    await desktopBot.clickRelative(100, 200)

    // Right click on the position x=100 and y=200 relative to the element found.
    await desktopBot.clickRelative(100, 200, 'right')

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);
}
// Looking for the element on the page with the label 'SubmitForm'.
if (await desktopBot.find('SubmitForm')){
    // Double click on the element found.
    await desktopBot.doubleClick()
}

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

// Looking for the element on the page with the label 'SubmitForm'.
if (await desktopBot.find('SubmitForm')){
    // Double click on the position x=100 and y=200 relative to the element found.
    await desktopBot.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);
}
// Looking for the element on the page with the label 'SubmitForm'.
if (await desktopBot.find('SubmitForm'){
    // Triple click on the element found
    await desktopBot.tripleClick()
}

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

// Looking for the element on the page with the label 'SubmitForm'.
if (await desktopBot.find('SubmitForm'){
    // Triple-click on the position x=100 and y=200 relative to the element found.
    await desktopBot.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()

# Releasing the mouse button.
bot.mouse_up()
// Not yet implemented.
// Pressing the mouse button.
await desktopBot.mouse_down()

// Releasing the mouse button.
await desktopBot.mouse_up()
// Pressing the mouse button.
await desktopBot.mouse_down()

// Releasing the mouse button.
await desktopBot.mouse_up()

Scroll through the screen

If you need to navigate around the screen using 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);
// Scroll up 10 times.
await desktopBot.scrollUp(10)

// Scroll down 10 times.
await desktopBot.scrollDown(10)
// Scroll up 10 times.
await desktopBot.scrollUp(10)

// Scroll down 10 times.
await desktopBot.scrollDown(10)