这个问题好解决。
procedure TForm1.Button1Click(Sender: TObject);
var
hwin:THandle;
begin
hwin:= FindWindow('SciCalc','计算器');
if hwin<> 0 then
begin
SendMessage(hwin,WM_COMMAND,MAKEWPARAM(125,BN_CLICKED),0); // 1
Sleep(500);
SendMessage(hwin,WM_COMMAND,MAKEWPARAM(126,BN_CLICKED),0); // 2
Sleep(500);
SendMessage(hwin,WM_COMMAND,MAKEWPARAM(127,BN_CLICKED),0); // 3
Sleep(500);
SendMessage(hwin,WM_COMMAND,MAKEWPARAM(92,BN_CLICKED),0); // +
Sleep(500);
SendMessage(hwin,WM_COMMAND,MAKEWPARAM(125,BN_CLICKED),0); // 1
Sleep(500);
SendMessage(hwin,WM_COMMAND,MAKEWPARAM(126,BN_CLICKED),0); // 2
Sleep(500);
SendMessage(hwin,WM_COMMAND,MAKEWPARAM(127,BN_CLICKED),0); // 3
Sleep(500);
SendMessage(hwin,WM_COMMAND,MAKEWPARAM(112,BN_CLICKED),0); // =
end;
end;
模拟按下123+123=这几个键,其它按键的编码自己用spy抓一下。方法是:抓消息,然后按下计算器的按键,看消息队列里面WM_COMMAND为BN_CLICKED的ID是多少。例如:除号是90,乘号是91,加号是92,减号是93 。。。