Displaced mouse throu vboxwebsvr

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Scott Grim
Posts: 8
Joined: 30. Mar 2023, 22:40

Displaced mouse throu vboxwebsvr

Post by Scott Grim »

Trying to control virtualbox programatically some unexpected behaviour occoure. The mouse is displaced. I call putMouseEventAbsolute and then putMouseEvent
but the position of the mouse is wrong. By this forum I am not allowed to reference the handbook here.

I am using virtualbox 7.0.6 r155176 (Qt 5.15.8)
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Displaced mouse throu vboxwebsvr

Post by scottgus1 »

Moved to "Virtualbox API" for the deep gurus to ponder.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Displaced mouse throu vboxwebsvr

Post by noteirak »

Scott Grim wrote:Trying to control virtualbox programatically some unexpected behaviour occoure. The mouse is displaced. I call putMouseEventAbsolute and then putMouseEvent
but the position of the mouse is wrong. By this forum I am not allowed to reference the handbook here.

I am using virtualbox 7.0.6 r155176 (Qt 5.15.8)
Please read the Posting Guidelines and provide all listed information please.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Scott Grim
Posts: 8
Joined: 30. Mar 2023, 22:40

Re: Displaced mouse throu vboxwebsvr

Post by Scott Grim »

I tried but can not for some wierd reason: Because I am not member for at least one day since last year. I try to post it step by step.
I am using virtualbox 7.0.6 r155176 (Qt 5.15.8)
Scott Grim
Posts: 8
Joined: 30. Mar 2023, 22:40

Re: Displaced mouse throu vboxwebsvr

Post by Scott Grim »

The API is generated automatically throu webservice.
Scott Grim
Posts: 8
Joined: 30. Mar 2023, 22:40

Re: Displaced mouse throu vboxwebsvr

Post by Scott Grim »

The Connection type (Webservice) is Webservice throu vboxwebsrv.
The language used is java.
The os used is
Scott Grim
Posts: 8
Joined: 30. Mar 2023, 22:40

Re: Displaced mouse throu vboxwebsvr

Post by Scott Grim »

THE OS used is linux
Scott Grim
Posts: 8
Joined: 30. Mar 2023, 22:40

Re: Displaced mouse throu vboxwebsvr

Post by Scott Grim »

The standalone code is:

Code: Select all

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();
            }
        }
    }
}
Scott Grim
Posts: 8
Joined: 30. Mar 2023, 22:40

Re: Displaced mouse throu vboxwebsvr

Post by Scott Grim »

Sorry the requirements point out that: "Make sure your code is readable/documented" and can run without dependencies is not possible. I will not place the JDK in here because the JDK is pretty huge, please download the jdk by yourself instead.

It is very hard to meet the posting guidelines. I posted more informations elsewhere but am not allowed to tell where.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Displaced mouse throu vboxwebsvr

Post by scottgus1 »

Scott, you should be past the one day no links limit now.
Scott Grim
Posts: 8
Joined: 30. Mar 2023, 22:40

Re: Displaced mouse throu vboxwebsvr

Post by Scott Grim »

I try to post links again:

https://stackoverflow.com/questions/76361805

Aha! It works now!
Post Reply