Search code examples
windowsdelphivirtualboxchildrenhandle

Child handles of vbox Windows using Delphi


I want to get all of children handle of Windows that its run in Virtual Box . I want send a key from Host Windows(Main Windows) to notepad of Guest Windows. I know that we can find child window by using EnumChildWindows in delphi but Virtual Box only retrieve QWidget class name. can anyone help me access to all of handle of Guest Windows(its run in Virtual Box) from main windows using delphi ? thank you.


Solution

  • I want to get all of children handle of Windows that its run in Virtual Box .

    Sorry, but you cannot do that. Like AlexK said in comments, windows running within the guest OS simply do not exist within the host OS, so they cannot be accessed or enumerated by apps running in the host OS. The VM is running a completely separate guest OS and is simply rendering the display output of that OS on its own window running on the host OS.

    I want send a key from Host Windows(Main Windows) to notepad of Guest Windows.

    There is no way to do that directly.

    When a user types a key on the physical keyboard or an on-screen keyboard within the host OS, the key is put into the input queue of the host OS and gets routed to the current focused window within the host OS. If that window happens to be the VM, then the VM places the key in the input queue of the guest OS and it gets routed to the current focused window within the guest OS.

    An app running on the host OS can use SendInput() to simulate keyboard input in the host OS, and let it get routed accordingly.

    If you need more control, you will have to run a separate app within the guest OS that is connected to your main app running on the host OS. The host app can then communicate with the guest app, and the guest app can act on guest windows as needed.

    For example, the host app could ask the guest app to enumerate the guest windows and send that list back to the host app. The host app could detect the presence of Notepad and send the desired key(s) to the guest app, which could then send the key(s) to the Notepad window.

    I know that we can find child window by using EnumChildWindows in delphi

    Only for windows that are running in the same OS that the enumerating app is running in.

    but Virtual Box only retrieve QWidget class name.

    Because that is the window that is running within the host OS.