I try to use sendkeys, problem is focus.
First i parent a external .exe in a panel.
All works fine :-).

VB.NET
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        proc = Process.Start("C:\Program Files\DOSBox-0.72\dosbox.exe", "-noconsole")

        proc.WaitForInputIdle()
        For Each proc As Process In Process.GetProcesses()
            If proc.MainWindowTitle.StartsWith("DOSBox") Then
                handle = proc.MainWindowHandle
            End If
        Next

        SetParent(proc.MainWindowHandle, Me.Panel1.Handle)

        SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
        
    End Sub

Only problem is senkeys to that .exe.

VB.NET
 Public Function whichbuttonpushed(ByVal _sender As String) As String



        SetActiveWindow(Me.Panel1.Handle) 'Set focus Active window



        Select Case _sender
            Case "btna"
                keybd_event(VK_A, 0, 0, 0) 'send a key
                keybd_event(VK_A, 0, KEYEVENTF_KEYUP, 0) 'release a key 
                My.Computer.Keyboard.SendKeys("22", True)

        End Select

    End Function

Here i have a focus problem.
I'm using vb.net2008, learning from books add home just for fun.