procedure TForm1.Button1Click(Sender: TObject); const DATAPATH = 'genie.acs'; //角色文件名 var Genie: IAgentCtlCharacterEx; LoadRequest: IAgentCtlRequest; begin LoadRequest:= Agent1.Characters.Load('Genie', DATAPATH); Genie:= IAgentCtlCharacterEx(Agent1.Characters['Genie']); Genie.LanguageID:=$409; Genie.Commands.Add('Instructions', '&Instructions', '(how do I order [a pizza]|[give me] [(some|the) instructions])',false,true); Genie.Commands['Instructions'].ConfidenceText := 'Didn''t understand your request.'; Genie.Commands['Instructions'].Confidence := -60; Genie.Show(true); Genie.MoveTo(300,300,500); *********************************************
TAgent有一个OnCommand事件,接管这个事件即可。具体参看MSDN http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msagent/agentstartpage_7gdh.asp例子: procedure TForm1.Button1Click(Sender: TObject); begin Genie.Commands.Add('1', 'Yes', '', True, True); Genie.Commands.Add('2', 'No', '', True, True); end;procedure TForm1.Agent1Command(Sender: TObject; const UserInput: IDispatch); begin if IAgentCtlUserInput(UserInput).Name = '1' then begin ShowMessage('Yes'); end else if IAgentCtlUserInput(UserInput).Name = '2' then begin ShowMessage('No'); end end;
TAgent有一个OnCommand事件,你可以接管这个事件。具体参看MSDN http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msagent/agentstartpage_7gdh.asp例子:procedure TForm1.Button1Click(Sender: TObject); begin Genie.Commands.Add('1', 'Yes', '', True, True); Genie.Commands.Add('2', 'No', '', True, True); end;procedure TForm1.Agent1Command(Sender: TObject; const UserInput: IDispatch); begin if IAgentCtlUserInput(UserInput).Name = '1' then begin ShowMessage('Yes'); end else if IAgentCtlUserInput(UserInput).Name = '2' then begin ShowMessage('No'); end end;
const
DATAPATH = 'genie.acs'; //角色文件名
var
Genie: IAgentCtlCharacterEx;
LoadRequest: IAgentCtlRequest;
begin
LoadRequest:= Agent1.Characters.Load('Genie', DATAPATH);
Genie:= IAgentCtlCharacterEx(Agent1.Characters['Genie']);
Genie.LanguageID:=$409;
Genie.Commands.Add('Instructions', '&Instructions', '(how do I order [a pizza]|[give me] [(some|the) instructions])',false,true);
Genie.Commands['Instructions'].ConfidenceText := 'Didn''t understand your request.';
Genie.Commands['Instructions'].Confidence := -60;
Genie.Show(true);
Genie.MoveTo(300,300,500);
*********************************************
procedure TForm1.Button1Click(Sender: TObject);
begin
Genie.Commands.Add('1', 'Yes', '', True, True);
Genie.Commands.Add('2', 'No', '', True, True);
end;procedure TForm1.Agent1Command(Sender: TObject;
const UserInput: IDispatch);
begin
if IAgentCtlUserInput(UserInput).Name = '1' then begin
ShowMessage('Yes');
end
else if IAgentCtlUserInput(UserInput).Name = '2' then begin
ShowMessage('No');
end
end;
begin
Genie.Commands.Add('1', 'Yes', '', True, True);
Genie.Commands.Add('2', 'No', '', True, True);
end;procedure TForm1.Agent1Command(Sender: TObject;
const UserInput: IDispatch);
begin
if IAgentCtlUserInput(UserInput).Name = '1' then begin
ShowMessage('Yes');
end
else if IAgentCtlUserInput(UserInput).Name = '2' then begin
ShowMessage('No');
end
end;