[DllImport ("user32.dll", EntryPoint = "FindWindow", SetLastError = True)]
private static extern IntPtr FindWindow (string lpclassname, string lpwindowname);
[DllImport ("user32.dll", EntryPoint = "FindWindowEx", SetLastError = True)]
private static extern IntPtr FindWindowEx (IntPtr hwndparent, uint hwndchildafter, String lpszclass, string lpszwindow);
[DllImport ("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SendMessage (INTPTR hwnd, uint wmsg, int wParam, int lParam);
[DllImport ("user32.dll", EntryPoint = "SetForegroundWindow", SetLastError = True)]
private static extern void SetForegroundWindow (INTPTR hwnd);
private void Button1_Click (object sender, EventArgs e)
{
var hwndphoto = FindWindow (null, "XMind"); Find the handle to the camera program "Application name in Task Manager"
if (Hwndphoto! = IntPtr.Zero)
{
SetForegroundWindow (Hwndphoto); Set the Ucdemo program as the current active window
Sendkeys.send ("^o");
Clipboard.setdataobject (@ "D:\ thought map \ Document \ Basic Data transformation. Xmind");
System.Threading.Thread.Sleep (200); Pause 500 milliseconds
Sendkeys.send ("^v");
System.Threading.Thread.Sleep (200); Pause 500 milliseconds
Sendkeys.send ("~");
System.Threading.Thread.Sleep (500); Pause 500 milliseconds
Sendkeys.send ("^p");
System.Threading.Thread.Sleep (200); Pause 500 milliseconds
Sendkeys.send ("~");
}
Else
{
MessageBox.Show ("No Boot XMind");
}
}
C # Control Other programs