P
pipo
Hi all,
I am trying to interact with the windows calculator.
I want to open the calculator for the user so the user can work with it.
When the user is done (or during) working with calculator I need the
(displayed)value of the calcultor back in my textbox.
I have no problem starting calculator or even put values in calculator.
I just cant get the value out of the Edit class of the calculator.
Any tips or idea's for me?
Here is my code (so far)
//Opening the calculator
Process p =Process.Start("calc.exe");
//Calculator Handle
hwndCalc = p.MainWindowHandle.ToInt32();
//Get the Handle of the Edit class (textbox of the calculator)
IntPtr pntr = FindWindowEx(p.MainWindowHandle, IntPtr.Zero, "Edit", null);
//Setting a value to the calculator
SendMessage(pntr, WM_SETTEXT, 0, "1234567");
//Buffer voor the text to be read out
StringBuilder Buff = new StringBuilder(256);
//Buffer stays empty...why???
GetWindowText(pntr.ToInt32(), Buff, Buff.Capacity);
//Dont know what to fill in for nIDDlgItem...
//Spy++ gives me everytime a different handle. The const 414 isnt correct
either (Buff stays empty)
//When filling in the Edit class handle then also Buff stays empty.
GetDlgItemTextA(hwndCalc, ????, Buff, Buff.Capacity);
Thank you in advance
I am trying to interact with the windows calculator.
I want to open the calculator for the user so the user can work with it.
When the user is done (or during) working with calculator I need the
(displayed)value of the calcultor back in my textbox.
I have no problem starting calculator or even put values in calculator.
I just cant get the value out of the Edit class of the calculator.
Any tips or idea's for me?
Here is my code (so far)
//Opening the calculator
Process p =Process.Start("calc.exe");
//Calculator Handle
hwndCalc = p.MainWindowHandle.ToInt32();
//Get the Handle of the Edit class (textbox of the calculator)
IntPtr pntr = FindWindowEx(p.MainWindowHandle, IntPtr.Zero, "Edit", null);
//Setting a value to the calculator
SendMessage(pntr, WM_SETTEXT, 0, "1234567");
//Buffer voor the text to be read out
StringBuilder Buff = new StringBuilder(256);
//Buffer stays empty...why???
GetWindowText(pntr.ToInt32(), Buff, Buff.Capacity);
//Dont know what to fill in for nIDDlgItem...
//Spy++ gives me everytime a different handle. The const 414 isnt correct
either (Buff stays empty)
//When filling in the Edit class handle then also Buff stays empty.
GetDlgItemTextA(hwndCalc, ????, Buff, Buff.Capacity);
Thank you in advance