using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsFormsApplication2 { public partial class Form1 : Form { [DllImport("user32.dll")] public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam); [DllImport("user32.dll")] static extern int FindWindow(string lpClassName, string lpWindowName); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { const int WM_COMMAND = 0x0111; int thisWindow = FindWindow("CalcFrame", "Calculator"); //This writes the number 8 in calculator SendMessage(thisWindow, WM_COMMAND, 0x08A, 0); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)