Skip to content

Instantly share code, notes, and snippets.

@Nithanim
Created December 30, 2020 19:12
Show Gist options
  • Save Nithanim/4190b76ca41c38e349dc0430b2e6b8cd to your computer and use it in GitHub Desktop.
Save Nithanim/4190b76ca41c38e349dc0430b2e6b8cd to your computer and use it in GitHub Desktop.
Virtualbox: Send shortcuts from host to guest
You might have the circumstance that you have a program sandboxed in a VM in VirtualBox.
But you want to control the program with shortcuts as if it was running on the host.
An example would be voice chat software where you want to toggle the microphone.
You need the HEX values of the keyboard scancodes ("the description of the location on the keyboard", not the character to press!).
Search for "scancode list" on google; e.g. http://www.winfaq.de/faq_html/Content/tip1500/onlinefaq.php?h=tip1576.htm
# send ctrl (left) + shift (left)
VBoxManage controlvm <vmName> keyboardputscancode 1D 2A
# send "m"
VBoxManage controlvm <vmName> keyboardputscancode 32
# key+0x80 = keyup; for emulating letting go of the ctrl and shift key
VBoxManage controlvm <vmName> keyboardputscancode 9D AA
You could also put all codes on the same line, in the same command:
VBoxManage controlvm <vmName> keyboardputscancode 1D 2A 32 9D AA
The put it in a script file and bind it with the same (or even different) shortcut on your OS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment