sethmlarson / virtualbox-python

Complete implementation of VirtualBox's COM API with a Pythonic interface.
https://pypi.org/project/virtualbox
Apache License 2.0
354 stars 75 forks source link

Failed to find attribute display in <virtualbox.library_ext.console.IConsole object #51

Closed dickreuter closed 7 years ago

dickreuter commented 8 years ago

import virtualbox vbox = virtualbox.VirtualBox() print("VM(s):\n + %s" % "\n + ".join([vm.name for vm in vbox.machines])) vm = vbox.find_machine('Windows') session = vm.createsession() h, w, , , , _= session.console.display.get_screen_resolution(0) png = session.console.display.take_screen_shot_png_to_array(0, h, w)

gives the follwing error:

raise AttributeError("Failed to find attribute %s in %s" % (name, self)) AttributeError: Failed to find attribute display in <virtualbox.library_ext.console.IConsole object at 0x00000237D28EE710> Win32 exception occurred releasing IUnknown at 0xd2ac9730

sethmlarson commented 7 years ago

The reason that the IConsole object doesn't have a display attribute is not because it doesn't actually not have that attribute but rather that the session's console object isn't an active console with the virtual machine running. Try starting the VM via launch_vm_process() and try this again with the resulting session object.