Ratón¶
Utilizando los métodos a continuación, puedes controlar y obtener información del ratón.
Obtener las coordenadas del ratón¶
Si deseas obtener las coordenadas del ratón, utiliza los métodos a continuación para obtener la posición X e Y del ratón.
# 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}`)
Mover a una coordenada¶
Para mover el ratón a una coordenada, utiliza el siguiente método.
# Mover el ratón a la posición x=100 e y=200.
bot.mouse_move(x=100, y=200)
// Mover el ratón a la posición x=100 e y=200.
moveTo(100, 200);
// Mover el ratón a la posición x=100 e y=200.
await desktopBot.moveMouse(100, 200)
// Mover el ratón a la posición x=100 e y=200.
await desktopBot.moveMouse(100, 200)
Mover el ratón¶
Si deseas mover el ratón a un elemento, utiliza los métodos a continuación.
Puedes moverte directamente a un elemento o moverte a una posición relativa a la posición del elemento encontrado o a una posición aleatoria en la pantalla.
Note
El método find()
se utiliza para buscar el elemento y recopilar su posición. Haz clic aquí para obtener más información.
# 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)
Hacer clic en una coordenada¶
Si necesitas hacer clic en una posición en la pantalla, utiliza el siguiente método.
# 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')
Hacer clic en el elemento¶
Si deseas hacer clic en el elemento, utiliza los métodos a continuación.
Puedes hacer clic directamente en el elemento o hacer clic en una posición relativa al elemento encontrado.
Note
El método find()
se utiliza para buscar el elemento y recopilar su posición. Haz clic aquí para obtener más información.
# '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')
Hacer doble clic en el elemento¶
Si necesitas hacer doble clic en el elemento o hacer doble clic en una posición relativa del elemento, utiliza los métodos a continuación.
Note
El método find()
se utiliza para buscar el elemento y recopilar su posición. Haz clic aquí para obtener más información.
# 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)
}
Hacer triple clic en el elemento¶
Si necesitas hacer triple clic en el elemento o hacer triple clic en una posición relativa del elemento, utiliza los métodos a continuación.
Note
El método find()
se utiliza para buscar el elemento y recopilar su posición. Haz clic aquí para obtener más información.
# 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)
}
Presionar y soltar el botón del ratón¶
Para presionar y soltar el botón del ratón, utiliza los métodos a continuación. Actualmente, solo se admite el botón izquierdo.
# Pressing the mouse button.
bot.mouse_down()
# Releasing the mouse button.
bot.mouse_up()
// Aún no implementado.
// 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()
Desplazarse por la pantalla¶
Si necesitas navegar por la pantalla utilizando el desplazamiento hacia arriba o hacia abajo, utiliza los métodos a continuación.
# 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)