Skip to content

Screen Functions

Oğuzhan edited this page Sep 28, 2023 · 1 revision

To easily use the screen:

const {screen} = jsautogui // jsautogui has to be defined
// or
import {screen} from "jsautogui" // modulejs
// or
const {screen} = require("jsautogui") // commonjs

.size

Gets the size of the screen as an object.

const size = screen.size

console.log(size.width) // 1536
console.log(size.height) // 864

.width .height

Gets the width/height of the screen.

console.log(screen.width) // 1536
console.log(screen.height) // 864

.center

Gets the center position of the screen as an object.

console.log(screen.center.x) // 768
console.log(screen.center.y) // 432

.includes(x, y) .contains(x, y)

Checks whether the given position is in the screen bounds.

console.log(screen.contains(-100, -50)); // false
console.log(screen.contains(1536, 864)); // false
console.log(screen.contains(1535, 863)); // true
console.log(screen.contains(100, 200)); // true