Hi everyone,
I understand this topic is little old, but I just saw it and would like to submit a solution.
The mistake comes from here:
hwndButton = FindWindowEx(hwndDialog, IntPtr.Zero, "Button", "2");
In the calc version of WINDOWS 7 is different.
These are more than 1 control with class "#32770", which is the problem. This code selects the first one, and this is wrong, as the buttons are in the second.
A possible solution would be:
IntPtr hwnd = (IntPtr)FindWindow(null, "Calculator");
IntPtr hwndFrame = FindWindowEx((IntPtr)hwnd, IntPtr.Zero, "CalcFrame", string.Empty);
IntPtr hwndDialog = FindWindowEx(hwndFrame, IntPtr.Zero, "#32770", string.Empty);
IntPtr hwndDialog2 = FindWindowEx(hwndFrame, hwndDialog, "#32770", string.Empty);
IntPtr hwndButton = FindWindowEx(hwndDialog2, IntPtr.Zero, "Button", "5");
Cheers,
B&W