- procedure TfrmMain.btnSendClick(Sender: TObject);
- var
- hCalc, h1: Cardinal;
- begin
- WinExec('calc', SW_SHOWNORMAL);//运行计算器
- hCalc := FindWindow('SciCalc', nil);
- //查找计算器主窗口句柄,通过Spy++可查看到类名等
- h1 := FindWindowEx(hCalc, 0, 'Button', '9');
- //查找按钮1的句柄,通过Spy++可查看到各种控件及他们的父子、兄弟关系
- SendMessage(hCalc, WM_COMMAND, MakeWParam(GetDlgCtrlID(h1), BN_CLICKED), h1)
- end;
http://blog.csdn.net/yanjiaye520/article/details/7942499