4

I know how to send keyboard events (keystrokes) to a VirtualBox Virtual Machine, using VBoxManage controlvm keyboardputscancode <scancode> <scancode> <etc...>

Is there a similar way to simulate mouse or touch events? For example, move the mouse to a certain coordinate or over a certain distance, or send a mouse click, or send a touch/tap on a given coordinate?

RocketNuts
  • 9,958
  • 11
  • 47
  • 88

1 Answers1

1

You can do this using Python and https://pypi.org/project/vboxapi/

from vboxapi import VirtualBoxManager

mgr = VirtualBoxManager(None, None)
vbox = mgr.getVirtualBox()
machine = vbox.findMachine('CentOS')
session = mgr.getSessionObject(vbox)
machine.LockMachine(session, mgr.constants.LockType_Shared)
session.Console.Mouse.putMouseEventAbsolute(100,100,0,0,1)

for more information, please see it here

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
EJL
  • 205
  • 2
  • 10
  • 1
    Thanks, that looks promising! However if I run this example (after renaming 'CentOS' to my VM name of course) I get an error: AttributeError: XPCOM component '' has no attribute 'LockMachine' ([full error message](https://pastebin.com/raw/faiFmhUZ)) – RocketNuts Apr 14 '19 at 10:34
  • you should install vboxapi using the command *python pip install vboxapi* – EJL Apr 15 '19 at 01:22