- Joined
- Mar 26, 2012
- Messages
- 1,465
- Reaction score
- 131
So I have embedded another exe within my C# coding inside a groupbox so that the buttons would still remain visible but, I would like to know how I can make the embedded window active when I click on any of my buttons. Ex.(Send Keystrokes to the NOTEPAD inside of the groupbox.)
Any help here would be much appreciated. Thank you.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; //required for APIs
using System.Threading;
using System.Diagnostics;
private void button1_Click(object sender, EventArgs e)
{
//Need to bring the focus of the "notepad.exe" below here and use send keys
SendKeys.Send("{ENTER}");
}
private void button2_Click(object sender, EventArgs e)
{
this.Size = new Size(1280, 900);
Process p = Process.Start("notepad.exe");
Thread.Sleep(500);
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, groupBox1.Handle);
}