Trying to control virtualbox programatically some unexpected behaviour occourse. I try to:
- Place the mouse-cursor at 200x200.
- Move the mouse-cursor by 10x10 to the lower-right.
Steps to reproduce:
- Start a virtualbox-machine.
- Start xev in the virtualbox-machine.
- Start vboxwebsrv
- Enter user-credentials for vboxwebsrv-Server in the code below
This is my code:
VirtualBoxManager manager = VirtualBoxManager.createInstance(null);
private IVirtualBox connect() throws IOException, FileNotFoundException {
manager.connect("http://localhost:18083", "user", "pass");
return manager.getVBox();
}
public void testMousePos() throws Exception {
IVirtualBox box = connect();
for (IMachine machine : box.getMachines()) {
if (machine.getState() == MachineState.Running) {
ISession session = manager.getSessionObject();
machine.lockMachine(session, LockType.Shared);
try {
IConsole console = session.getConsole();
IMouse mouse = console.getMouse();
mouse.putMouseEventAbsolute(200, 200, 0, 0, 0x00);
mouse.putMouseEvent(10, 10, 0, 0, 0x00);
} finally {
session.unlockMachine();
}
}
}
}
This will produce this screenshot:

Now, the first putMouseEventAbsolute(200, 200,
places the mouse to 199x199, that is almost ok.
Then the putMouseEvent(10, 10,
result in the new position of 203x203, that is NOT ok.
Then
If I restart the test it is getting more worst.

The position is now changed from 203x203 to 208x208. The putMouseEventAbsolute
seems to be not executed at all anymore (even if I restart the vboxwebsvr-service).
Any idea?