Also, i done up a macro that is able to work, however, i am unhappy because this is a very "stupid" and inefficient way of doing it.
What i did was to go down the windows manually.
````
main_view = FindWindowEx(hwindow2, 0&, "Calcframe", vbNullString) 'whole calculator view
sub_view = FindWindowEx(main_view, 0&, "#32770", vbNullString) ' 1st 32770 (Dialog)
sub_view2 = FindWindowEx(main_view, sub_view, "#32770", vbNullString) '2nd 32770 (Dialog)
button1 = FindWindowEx(sub_view2, 0&, "Button", vbNullString) 'MC button on calculator
button2 = FindWindowEx(sub_view2, button1, "Button", vbNullString) ' Backspace button on calculator
button3 = FindWindowEx(sub_view2, button2, "Button", vbNullString) 'number button 7 on calculator
button4 = FindWindowEx(sub_view2, button3, "Button", vbNullString) 'number button 4 on calculator
button5 = FindWindowEx(sub_view2, button4, "Button", vbNullString) 'number button 1 on calculator
button6 = FindWindowEx(sub_view2, button5, "Button", vbNullString) 'number button 0 on calculator
button7 = FindWindowEx(sub_view2, button6, "Button", vbNullString) 'MR button on calculator
button8 = FindWindowEx(sub_view2, button7, "Button", vbNullString) 'CE button on calculator
button9 = FindWindowEx(sub_view2, button8, "Button", vbNullString) 'number button 8 on calculator
button10 = FindWindowEx(sub_view2, button9, "Button", vbNullString) 'number button 5 on calculator
button11 = FindWindowEx(sub_view2, button10, "Button", vbNullString) 'number button 2 on calculator
button12 = FindWindowEx(sub_view2, button11, "Button", vbNullString) 'MS button on calculator
button13 = FindWindowEx(sub_view2, button12, "Button", vbNullString) 'C button on calculator
button14 = FindWindowEx(sub_view2, button13, "Button", vbNullString) 'number 9 button on calculator
button15 = FindWindowEx(sub_view2, button14, "Button", vbNullString) 'number 6 button on calculator
button16 = FindWindowEx(sub_view2, button15, "Button", vbNullString) 'number 3 button on calculator
button17 = FindWindowEx(sub_view2, button16, "Button", vbNullString) '. button on calculator
button18 = FindWindowEx(sub_view2, button17, "Button", vbNullString) 'M+ button on calculator
button19 = FindWindowEx(sub_view2, button18, "Button", vbNullString) '+_ button on calculator
button20 = FindWindowEx(sub_view2, button19, "Button", vbNullString) '/ button on calculator
button21 = FindWindowEx(sub_view2, button20, "Button", vbNullString) '* button on calculator
button22 = FindWindowEx(sub_view2, button21, "Button", vbNullString) '- button on calculator
button23 = FindWindowEx(sub_view2, button22, "Button", vbNullString) '+ button on calculator
button24 = FindWindowEx(sub_view2, button23, "Button", vbNullString) 'M- button on calculator
button25 = FindWindowEx(sub_view2, button24, "Button", vbNullString) 'sqaure root button on calculator
button26 = FindWindowEx(sub_view2, button25, "Button", vbNullString) '% button on calculator
button27 = FindWindowEx(sub_view2, button26, "Button", vbNullString) '1/X button on calculator
button28 = FindWindowEx(sub_view2, button27, "Button", vbNullString) '= button on calculator
'Calculate 74+21=95
Call SendMessage(button3, BM_CLICK, 0, ByVal0&) 'click button 7 on calculator
Call SendMessage(button4, BM_CLICK, 0, ByVal0&) 'click button 4 on calculator
Call SendMessage(button23, BM_CLICK, 0, ByVal0&) 'click + on calculator
Call SendMessage(button11, BM_CLICK, 0, ByVal0&) 'click button 2 on calculator
Call SendMessage(button5, BM_CLICK, 0, ByVal0&) 'click button 1 on calculator
Call SendMessage(button28, BM_CLICK, 0, ByVal0&) 'click = on calculator
````
As you can see, although this works, there are a lots of feedbacks.
1) This will only work in the normal view, if you change it to programmer or scientific view. It should not work.
2) What if there are 1000 or more buttons ? (Write a program to loop to write the lines or use excel to concatenate to write the lines???)
3) How do we identify each button after writing the code ? (Manually use spy++ to highlight every window to know which button it is???)
I am sure that the developers of Microsoft saw this issue ages back and would have came up with a solution. Therefore, if anyone knows the legit "correct" way of doing it. Any help is kindly and deeply appreciated and i am sure many others would be able to use this thread to start learning.
Dear
@Jaafar Tribak ,
The control ID does not seem to change with the view and therefore programming it with Control ID seems to be the legit "correct" way.
Do you have an example of how to write a code with a control ID so i can experiment further?