Last active
April 20, 2022 12:40
-
-
Save mjdorma/9132605 to your computer and use it in GitHub Desktop.
pyvbox: Register for decoded keystrokes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""pyvbox: Register for decoded keystrokes | |
The following code will print key press events from the guest | |
VM to the host's stdout. | |
""" | |
import sys | |
import virtualbox | |
vbox = virtualbox.VirtualBox() | |
m = vbox.find_machine("win7") | |
s = m.create_session() | |
def callback(state, key): | |
if state == 1 and len(key) == 1: | |
sys.stdout.write(key) | |
sys.stdout.flush() | |
s.console.keyboard.register_key_callback(callback) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment