C# Visual Studio windows form...
I'm experimenting on how to access other applications. I want to be able to click other application buttons through my program.
I can't get this code right!
It should click the number 2 in the calculator, but it clicks the "," sign.
WinSpy++ shows that the CONTROL ID of the button 2 is 00000084
Here is the code:
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");
SendMessage(thisWindow, WM_COMMAND, 00000084, 0);
}
}
}