📄 unit1.~pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,ActiveX,ComObj,AgentObjects_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
ListBox1: TListBox;
Label1: TLabel;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button8: TButton;
Button10: TButton;
Edit1: TEdit;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
private
{ Private declarations }
thelist:TStringList;
public
{ Public declarations }
procedure Clicked(Sender: TObject; const CharacterID: WideString; Button: Smallint;
Shift: Smallint; x: Smallint; y: Smallint);
end;
var
Form1: TForm1;
I2:IAgentCtlEx;
IMyAgent:IAgentCtlCharacters;
I1:IAgentCtlCharacterEx;
IEvent:_AgentEvents;
implementation
{$R *.DFM}
procedure TForm1.Clicked(Sender: TObject; const CharacterID: WideString; Button: Smallint;
Shift: Smallint; x: Smallint; y: Smallint);
begin
ShowMessage('u clicked it');
end;
procedure GetAnimationNames(IChar:IAgentCtlCharacterEx;Ts:TStrings);
var
pEnum:IEnumVARIANT;
vAnimationName:OLEVAriant;
dwRetrived:DWord;
hRes:HResult;
p1:IAgentCtlAnimationNames;
begin
p1:=(IChar.AnimationNames) As IAgentCtlAnimationNames;
pEnum:=p1.enum As IEnumVARIANT;
if Ts.Count<>0 then
begin
Ts.Clear;
end;
While True do
begin
hRes:=pEnum.Next(1,vAnimationName,dwRetrived);
if (hRes<>S_OK) then
Break;
ts.Add(vAnimationName);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
OleInitialize(nil);
OleCheck(CoCreateInstance(CLASS_Agent,nil,CLSCTX_ALL,IID_IAgentCtlEx,I2));
I2.Connected:=True;
IMyAgent:=I2.Get_Characters;
IMyAgent.Load('genie','genie.acs');
I1:=IMyAgent.Get_Item('genie');
GetAnimationNames(I1,thelist);
listbox1.items.Assign(thelist);
I1.Show(FALSE);
Label1.Caption:=Label1.Caption+'共'+IntToStr(ListBox1.items.Count)+'个';;
I1.Set_LanguageID($0409);
I1.Set_SoundEffectsOn(TRUE);
I1.Speak('Hello! I am here!','');
Button1.Enabled:=false;
Button2.Enabled:=True;
Button3.Enabled:=True;
Button4.Enabled:=True;
Button5.Enabled:=True;
Button8.Enabled:=True;
Button10.Enabled:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
thelist:=TStringList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
thelist.Clear;
thelist.Free;
if IMyAgent<>nil then
IMyAgent.Unload('Genie');
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
I1.Stopall('');
I1.Play(listbox1.Items[Listbox1.itemindex]);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
ICmdWin:IAgentCtlCommandsWindow;
begin
ICmdWin:=I2.Get_CommandsWindow;
ICmdWin.Set_Visible(True);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
Ibal:IAgentCtlBalloonEx;
begin
Ibal:=I1.Balloon;
Ibal.Set_FontSize(14);
I1.Speak(Edit1.Text,'');
end;
procedure TForm1.Button4Click(Sender: TObject);
var
Iinput:IAgentCtlSpeechInput;
begin
IInput:=I2.Get_SpeechInput;
if IInput.Installed then
ShowMessage('The Speech Recon is Installed in the machine')
else
ShowMessage('The SR Engine is not Installed in the machine');
end;
procedure TForm1.Button5Click(Sender: TObject);
var
IPropSheet:IAgentCtlPropertySheet;
begin
IPropSheet:=I2.Get_PropertySheet;
IPropSheet.Set_Visible(TRUE);
end;
procedure TForm1.Button8Click(Sender: TObject);
var
ICommands:IAgentCtlCommandsEx;
ICommand:IAgentCtlCommand;
begin
ICommands:=I2.Characters.Item['Genie'].Get_Commands;
Icommand:=ICommands.Add('Action1','Menu1','Voice1',TRUE,TRUE);
ICommand.Enabled:=true;
Icommand:=ICommands.Add('Action2','Menu2','Voice2',TRUE,TRUE);
ICommand.Enabled:=true;
Icommand:=ICommands.Add('Action3','Menu3','Voice3',TRUE,TRUE);
ICommand.Enabled:=true;
Button8.Enabled:=false;
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
I2.ShowDefaultCharacterProperties(100,100);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -