UnixLepik - A class that provides methods for Unix machines. Relies on xdotool.
Kind: global class
- UnixLepik
- .getMousePosition() ⇒
Object - .mouseClick([button], [amount])
- .mouseDoubleClick([button])
- .mouseScroll(fromX, fromY, toX, toY, [absolute])
- .mouseDrag(fromX, fromY, toX, toY, [absolute])
- .mouseMove(toX, toY, [absolute])
- .keyTap(key) ⇒
void - .write(text) ⇒
void - .keyDown(key) ⇒
void - .keyUp(key) ⇒
void - .copy() ⇒
void - .paste() ⇒
void - .getScreenSize() ⇒
Object - .getActiveWindow() ⇒
Promise.<number> - .setActiveWindow(windowHandle) ⇒
void - .minimizeWindow(windowHandle) ⇒
void - .maximizeWindow(windowHandle) ⇒
void - .closeWindow(windowHandle) ⇒
void - .getWindowTitle(windowHandle) ⇒
string - .delay(ms) ⇒
Promise.<void>
- .getMousePosition() ⇒
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()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);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");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);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);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);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");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!");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");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");Copies the selected text or content.
Kind: instance method of UnixLepik
Example
const lepik = require("lepikjs");
lepik.copy();Pastes the copied text or content.
Kind: instance method of UnixLepik
Example
const lepik = require("lepikjs");
lepik.paste();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()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}`);
});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");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");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");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");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");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. |