// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
private void simpleButton1_Click(object sender, EventArgs e)
{
IntPtr wordHandle = FindWindow(null, "Документ1 - Microsoft Word");
// Verify that word is a running process.
if (wordHandle == IntPtr.Zero)
{
MessageBox.Show("wordis not running.");
return;
}
SetForegroundWindow(wordHandle);
System.Threading.Thread.Sleep(100);
SendKeys.SendWait("5");
SendKeys.SendWait("*");
SendKeys.SendWait("6");
SendKeys.SendWait("=");
SendKeys.Flush();
}
0.00 (0%) 0 votes











