Click here to Skip to main content
15,890,440 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
c# VS.

When I use WinSpy++ on windows calculators result field, it shows the result in a field called Caption.
Is it possible to copy the Caption field from the calculator into a messagebox on my app ?
C#
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);

        }




    }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900