procedure TForm1.Button1Click(Sender: TObject); //----用SendKeys方法-----
var
aHandle:THandle;
i:integer;
s1:string;
begin
shellexecute(aHandle,'open','c:/MSU.exe',nil,'',sw_shownormal);
timedelay(1000);
Wnd := FindWindow(nil,'MXIC Speech Utility');
if Wnd <> 0 then
begin
SetForegroundWindow(Wnd);
for i:=1 to 16 do //--16个下箭头--
begin
keybd_event(VK_down, MapVirtualKey(VK_down, 0), 0, 0);
keybd_event(VK_down, MapVirtualKey(VK_down, 0), KEYEVENTF_KEYUP, 0);
timedelay(100);
end;
timedelay(1000);
keybd_event(VK_Tab, MapVirtualKey(VK_Tab, 0), 0, 0); //--1个tab
keybd_event(VK_Tab, MapVirtualKey(VK_Tab, 0), KEYEVENTF_KEYUP, 0);
timedelay(1000);
SendKeys('c:/14.bin',false,1);
timedelay(1000);
for i:=1 to 2 do //--2个tab
begin
keybd_event(VK_Tab, MapVirtualKey(VK_Tab, 0), 0, 0);
keybd_event(VK_Tab, MapVirtualKey(VK_Tab, 0), KEYEVENTF_KEYUP, 0);
timedelay(500);
end;
SendKeys('c:/14.wav',false,1);
timedelay(1000);
for i:=1 to 4 do //--4个tab
begin
keybd_event(VK_Tab, MapVirtualKey(VK_Tab, 0), 0, 0);
keybd_event(VK_Tab, MapVirtualKey(VK_Tab, 0), KEYEVENTF_KEYUP, 0);
timedelay(500);
end;
timedelay(1000);
keybd_event(VK_Return, MapVirtualKey(VK_Return, 0), 0, 0);
keybd_event(VK_Return, MapVirtualKey(VK_Return, 0), KEYEVENTF_KEYUP, 0);
end;
end;