Skip to content

Latest commit

 

History

History
337 lines (263 loc) · 11 KB

File metadata and controls

337 lines (263 loc) · 11 KB

UnixLepik

UnixLepik - A class that provides methods for Unix machines. Relies on xdotool.

Kind: global class

unixLepik.getMousePosition() ⇒ Object

Gets the current position of the mouse cursor on the screen.

Kind: instance method of UnixLepik
Returns: Object - An object containing the X and Y coordinates of the mouse cursor.
Example

const lepik = require("lepikjs");
let {x,y} = lepik.getMousePosition()

unixLepik.mouseClick([button], [amount])

Performs a click with the specified mouse button.

Kind: instance method of UnixLepik

Param Type Default Description
[button] string | number "'left'" The button to use for the click (left, right, or middle mouse button).
[amount] number 1 The number of clicks to perform. Default value is 1.

Example

const lepik = require("lepikjs");
lepik.mouseClick("right", 2);

unixLepik.mouseDoubleClick([button])

Performs a double-click with the specified mouse button.

Kind: instance method of UnixLepik

Param Type Default Description
[button] string | number "'left'" The button to use for the click (left, right, or middle mouse button).

Example

const lepik = require("lepikjs");
lepik.mouseDoubleClick("middle");

unixLepik.mouseScroll(fromX, fromY, toX, toY, [absolute])

Drag the mouse from the first coordinates to the second coordinates.

Kind: instance method of UnixLepik

Param Type Default Description
fromX number The X-coordinate to start dragging from.
fromY number The Y-coordinate to start dragging from.
toX number The X-coordinate to drag to.
toY number The Y-coordinate to drag to.
[absolute] boolean false Whether or not to use an absolute positioning of the mouse.

Example

const lepik = require("lepikjs");
lepik.mouseDrag(100, 100, 200, 200);

unixLepik.mouseDrag(fromX, fromY, toX, toY, [absolute])

Drag the mouse from the first coordinates to the second coordinates.

Kind: instance method of UnixLepik

Param Type Default Description
fromX number The X-coordinate to start dragging from.
fromY number The Y-coordinate to start dragging from.
toX number The X-coordinate to drag to.
toY number The Y-coordinate to drag to.
[absolute] boolean false Whether or not to use an absolute positioning of the mouse.

Example

const lepik = require("lepikjs");
lepik.mouseDrag(100, 100, 200, 200);

unixLepik.mouseMove(toX, toY, [absolute])

Move the mouse to the specified coordinates.

Kind: instance method of UnixLepik

Param Type Default Description
toX number The X-coordinate to move to.
toY number The Y-coordinate to move to.
[absolute] boolean false Whether or not to use an absolute positioning of the mouse.

Example

const lepik = require("lepikjs");
lepik.mouseMove(500, 500);

unixLepik.keyTap(key) ⇒ void

Sends a key tap event for the given key.

Kind: instance method of UnixLepik

Param Type Description
key string The key to tap. Must be a single character or a key name from the list returned by the getSupportedKeys method.

Example

const lepik = require("lepikjs");
lepik.keyTap("a");

unixLepik.write(text) ⇒ void

Sends a string of text to the active window by simulating individual key presses for each character.

Kind: instance method of UnixLepik

Param Type Description
text string The text to write.

Example

const lepik = require("lepikjs");
lepik.write("Hello, World!");

unixLepik.keyDown(key) ⇒ void

Sends a key down event for the given key.

Kind: instance method of UnixLepik

Param Type Description
key string The key to press. Must be a single character or combination of keys.

Example

const lepik = require("lepikjs");
lepik.keyDown("Shift");

unixLepik.keyUp(key) ⇒ void

Sends a key up event for the given key.

Kind: instance method of UnixLepik

Param Type Description
key string The key to press. Must be a single character or combination of keys.

Example

const lepik = require("lepikjs");
lepik.keyUp("Shift");

unixLepik.copy() ⇒ void

Copies the selected text or content.

Kind: instance method of UnixLepik
Example

const lepik = require("lepikjs");
lepik.copy();

unixLepik.paste() ⇒ void

Pastes the copied text or content.

Kind: instance method of UnixLepik
Example

const lepik = require("lepikjs");
lepik.paste();

unixLepik.getScreenSize() ⇒ Object

Gets the screen size.

Kind: instance method of UnixLepik
Returns: Object - An object containing the width and height of the screen.
Example

const lepik = require("lepikjs");
let {width, height} = lepik.getScreenSize()

unixLepik.getActiveWindow() ⇒ Promise.<number>

Gets the ID of the active window.

Kind: instance method of UnixLepik
Returns: Promise.<number> - A Promise that resolves with the ID of the active window.
Example

const lepik = require("lepikjs");
lepik.getActiveWindow().then((windowId) => {
  console.log(`Active window ID: ${windowId}`);
});

unixLepik.setActiveWindow(windowHandle) ⇒ void

Sets the specified window as the active window.

Kind: instance method of UnixLepik

Param Type Description
windowHandle string The handle of the window to set as active.

Example

const lepik = require("lepikjs");
lepik.setActiveWindow("window123");

unixLepik.minimizeWindow(windowHandle) ⇒ void

Minimizes the specified window.

Kind: instance method of UnixLepik

Param Type Description
windowHandle string The handle of the window to minimize.

Example

const lepik = require("lepikjs");
lepik.minimizeWindow("window123");

unixLepik.maximizeWindow(windowHandle) ⇒ void

Maximizes the specified window.

Kind: instance method of UnixLepik

Param Type Description
windowHandle string The handle of the window to maximize.

Example

const lepik = require("lepikjs");
lepik.maximizeWindow("window123");

unixLepik.closeWindow(windowHandle) ⇒ void

Closes the specified window.

Kind: instance method of UnixLepik

Param Type Description
windowHandle string The handle of the window to close.

Example

const lepik = require("lepikjs");
lepik.closeWindow("window123");

unixLepik.getWindowTitle(windowHandle) ⇒ string

Returns window title of given window.

Kind: instance method of UnixLepik

Param Type Description
windowHandle string The handle of the window to close.

Example

const lepik = require("lepikjs");
let title = lepik.getWindowTitle("window123");

unixLepik.delay(ms) ⇒ Promise.<void>

Delays the execution for the specified number of milliseconds.

Kind: instance method of UnixLepik
Returns: Promise.<void> - A Promise that resolves after the delay.

Param Type Description
ms number The number of milliseconds to delay.