Sending mouse or touch events to VirtualBox VM from host shell?

三世轮回 提交于 2019-12-04 04:48:11

问题


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?


回答1:


You can do this using Python

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



来源:https://stackoverflow.com/questions/51275313/sending-mouse-or-touch-events-to-virtualbox-vm-from-host-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!