Feb 6, 2009
I have an external exe file that runs like a console aplication (CLI). It is started as a process and is embedded in a Panel on a form. I can type commands directly at its prompt, but I would also like to send it keystrokes from a button.
View 10 Replies
Here is the code that starts it, embeds it into a Panel, removes its TitleBar, and positions and sizes it to the size of the Panel.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As New System.Diagnostics.ProcessStartInfo
p.FileName = "C:Program FilesConsole2Console.exe"
proc.StartInfo = p
I wondered if SendKeys would work, but the documentation says it should be sent to the 'active window', but there I get confused, as my exe is a process, and I do not know if the Panel it is embedded into is the 'window' referred to, or the proc.MainWindowHandle, and I do not know whether it is active or not.