static class Program {
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string _ClassName, string _WindowName);
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
private static extern IntPtr FindWindowEx(IntPtr hwndPrnt, IntPtr hwndChildAfter, string _ClassName, string _WindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
const int WM_LBUTTONDOWN = 513;
const int WM_LBUTTONUP = 514;
const int WM_RBUTTONDOWN = 516;
const int WM_RBUTTONUP = 517;
const int WM_SETTEXT = 0x000C;
[DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessageText(IntPtr hWnd, int wMsg, int wParam, string lParam);
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run();
}
public static void FindEditWindows(string message)
{
IntPtr calcWindow = FindWindow("SciCalc", "Calculator");
if (calcWindow == IntPtr.Zero)
{
MessageBox.Show("Not found Calculator window");
return;
}
IntPtr editWindow = FindWindowEx(calcWindow, IntPtr.Zero, "Edit", null);
if (editWindow == IntPtr.Zero)
{
MessageBox.Show("Not found Edit");
return;
}
SendMessageText(editWindow, WM_SETTEXT, 0, message);
}