[vbox-dev] How-to bring VirtualBox VM window to focus ?

Alexey Eromenko al4321 at gmail.com
Sat Jun 11 03:01:40 GMT 2011

The Qt4 GUI can bring the clicked VM window to focus.

Looking at SDK I found:
long long IMachine::showConsoleWindow()

But it lacks any example.

My code: (python on Windows)
from vboxapi import VirtualBoxManager
mgr = VirtualBoxManager(None, None)
vbox = mgr.vbox
name = "Windows XP Motherimage"
mach = vbox.findMachine(name)
session = mgr.mgr.getSessionObject(vbox)

progress = mach.launchVMProcess(session, "gui", "")

import win32gui
hwnd = mach.showConsoleWindow()
win32gui.ShowWindow(int(hwnd), win32con.SW_RESTORE)
And It works !

On Linux, I have tried:
>>> from PyQt4 import QtGui
>>> xdisp = QtGui.QX11Info.display()
but xdisp results in "NoneType" object.

1. How to fix it ?

2. Can the Main API be extended to incorporate all the necessary
functionality ? (by passing handler of the currently active
application to showConsoleWindow() or otherwise) It will make
developer's life easier, and allow me to target more platforms, such
as Mac, which I don't have, but GNS3 users use.

Thanks in advance,
-Alexey Eromenko "Technologov"

More information about the vbox-dev mailing list