[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 button2_Click(object sender, EventArgs e)
{
const uint BM_CLICK = 0xF5; // , , API
IntPtr hwndPhoto = FindWindow(null, "UC580Demo"); // 【 】
if (hwndPhoto != IntPtr.Zero)
{
IntPtr hwndThree = FindWindowEx(hwndCalc, 0, null, " "); //
SetForegroundWindow(hwndPhoto); // UcDemo
System.Threading.Thread.Sleep(500); // 500
SendMessage(hwndThree, BM_CLICK, 0, 0);//
}
else
{
MessageBox.Show(" UcDemo");
}
}