MCPcopy Create free account
hub / github.com/e2b-dev/desktop / getCursorPosition

Method getCursorPosition

packages/js-sdk/src/sandbox.ts:362–378  ·  view source on GitHub ↗

* Get the current cursor position. * @returns A object with the x and y coordinates * @throws Error if cursor position cannot be determined

()

Source from the content-addressed store, hash-verified

360 * @throws Error if cursor position cannot be determined
361 */
362 async getCursorPosition(): Promise<CursorPosition> {
363 const result = await this.commands.run('xdotool getmouselocation')
364
365 const match = result.stdout.match(/x:(\d+)\s+y:(\d+)/)
366 if (!match) {
367 throw new Error(
368 `Failed to parse cursor position from output: ${result.stdout}`
369 )
370 }
371
372 const [, x, y] = match
373 if (!x || !y) {
374 throw new Error(`Invalid cursor position values: x=${x}, y=${y}`)
375 }
376
377 return { x: parseInt(x), y: parseInt(y) }
378 }
379
380 /**
381 * Get the current screen size.

Callers 1

mouse.test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected