-1

In Windows 10 this is easy. You import the DLL "User32.dll" and call the SetCursorPos(int x, int y) function, for example.

I was looking for the Linux/Unix/OSX equivalents?

  • On the JVM you can move the cursor with [java.awt.Robot](https://docs.oracle.com/javase/8/docs/api/java/awt/Robot.html#mouseMove-int-int-) - might be worth looking into how that is implemented. – Chris Martin Mar 25 '16 at 01:41

1 Answers1

0

There is more than one equivalent to SetCursorPos, depending on whether you are running in a terminal or in the X Window system.

  • in a terminal, using escape sequences (e.g., ncurses), or
  • in X, using a feature called "Warp Pointer"

The choice really depends on what you are trying to do. For a simple program, you could run it in a terminal (or terminal window). Warping the pointer is not done often in X, but is well-known enough to make it easy to find discussion on the topic. Programming in X (no matter what toolkit you use), however, is more complicated than programming for a terminal.

Further reading:

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105