Skip to content

Controlling the Mouse

Pieter Ouwerkerk edited this page Oct 18, 2016 · 5 revisions

<click />

Moves the mouse to a specified location or object on the screen (see attributes below), and clicks on it. If you specify a selector, click will automatically wait for it to be visible (no need to separately call <wait.visible>).

Attributes

  • selector (optional) - A selector for an item on the screen to click on.

  • window (optional) - Specify which window to look for the selector, or null for the main page.

  • dx (optional) - A delta to move the clicking location x by.

  • dy (optional) - A delta to move the clicking location y by.

  • x (optional) - An x-coordinate to click on.

  • y (optional) - A y-coordinate to click on.

  • space (defaults to Scene) - The coordinate space to interpret the x and y in.

  • move (defaults to true) - Whether to move the mouse to the location first, otherwise an "invisible" click takes place.

  • effect (defaults to true) - Whether to show a click effect when clicking.

  • reveal (experimental) - Whether to move the mouse away from the item after its done clicking it.

const { click } = require("demokit/mouse");

// Click on the submit button in the DuckDuckGo window.
<click window = "duckduckgo" selector = "input[type=submit]" />

// Click the top left corner of the scene.
<click x = { 0 } y = { 0 } />

// Click the top left corner of the DuckDuckGo window.
<click x = { 0 } y = { 0 } space = "duckduckgo" />

<mouse.move />

Moves the mouse to a specified location or object on the screen (see attributes below). If you specify a selector, click will automatically wait for it to be visible (no need to separately call <wait.visible>).

Attributes

  • selector (optional) - A selector for an item on the screen to click on.

  • window (optional) - Specify which window to look for the selector, or null for the main page.

  • dx (optional) - A delta to move the clicking location x by.

  • dy (optional) - A delta to move the clicking location y by.

  • x (optional) - An x-coordinate to click on.

  • y (optional) - A y-coordinate to click on.

  • space (defaults to Scene) - The coordinate space to interpret the x and y in.

const mouse = require("demokit/mouse");

// Move the mouse to the submit button in the DuckDuckGo window.
<mouse.move window = "duckduckgo" selector = "input[type=submit]" />

// Move the mouse to the top left corner of the scene.
<mouse.move x = { 0 } y = { 0 } />

// Move the mouse to the top left corner of the DuckDuckGo window.
<mouse.move x = { 0 } y = { 0 } space = "duckduckgo" />

<mouse.effect />

Display a click effect at the specified location or object on the screen (see attributes below). If you specify a selector, click will automatically wait for it to be visible (no need to separately call <wait.visible>). This is useful if you need to pretend to click on something, but otherwise take a different action.

Attributes

  • selector (optional) - A selector for an item on the screen to click on.

  • window (optional) - Specify which window to look for the selector, or null for the main page.

  • dx (optional) - A delta to move the clicking location x by.

  • dy (optional) - A delta to move the clicking location y by.

  • x (optional) - An x-coordinate to click on.

  • y (optional) - A y-coordinate to click on.

  • space (defaults to Scene) - The coordinate space to interpret the x and y in.

const mouse = require("demokit/mouse");

// Pretend to click on the submit button in the DuckDuckGo window.
<mouse.effect window = "duckduckgo" selector = "input[type=submit]" />

// Pretend to click the top left corner of the scene.
<mouse.effect x = { 0 } y = { 0 } />

// Pretend to click the top left corner of the DuckDuckGo window.
<mouse.effect x = { 0 } y = { 0 } space = "duckduckgo" />
Clone this wiki locally