Today, the inspector needs to provide an automatic application installation function, so he does not know how to write the parameters when writing sendmessage/postmessage.
If you are familiar with SDK programming, you must be clear about MSG, wparam, and lparam.
And other parameters, of course, it will also be easy to write, it is nothing more than findwindow, find1_wex, postmessage and other physical activity. The following code is tested by myself:
1. Test Procedure
Create a blank dialog box and add the message to the "OK" button:
Void cmsgboxdlg: onok () <br/>{< br/> // todo: add extra validation here <br/> MessageBox ("test mouse click successful! "); <Br/>}
2. VC simulated button
The above project is the button we need to simulate and the main program, and we will create a new dialog box to test the simulated button:
Void ctestdlg: onok () <br/>{< br/> // todo: add extra validation here <br/> hwndhwnd1, hwnd2; <br/> hwnd1 = :: findwindow (null, _ T ("msgbox"); <br/> If (! Hwnd1) <br/>{< br/> MessageBox ("run the program msgbox.exe first! "); <Br/> return; <br/>}< br/> hwnd2 =: find1_wex (hwnd1, null, _ T (" button "), null ); <br/> If (! Hwnd2) <br/>{< br/> MessageBox ("No/" OK/"button found! "); <Br/> return; <br/>}< br/> uint nctrlid =: getdlgctrlid (hwnd2); <br/>: postmessage (hwnd2, wm_command, (wparam) (bn_clicked <16 | nctrlid), (lparam) hwnd2); <br/>: postmessage (hwnd2, wm_mousemove, mk_lbutton, makelong (0, 0 )); <br/>: postmessage (hwnd2, wm_lbuttondown, mk_lbutton, makelparam (); <br/>: postmessage (hwnd2, wm_lbuttonup, mk_lbutton, makelparam )); <br/>}
3. program running effect:
You don't need to upload the Code. If you are interested, check it out!