Author: Zhang Jianjun of the PLA Artillery Academy, Hefei City, Anhui Province branch of PICC Tongling Han Ying
Collection: 9CBS Program Big Camp Warrior ATYZY (smiling)
---- Microsoft Agent is a proxy software development technology issued by Microsoft in September 1997, and later integrated into Internet Explorer 4.0 Plus and later, the current version is 2.0, support Simplified Chinese. As a software agent tool, Agent has a very interactive manner interactive manner composed of menus, buttons, prompt boxes, etc., with its powerful interaction, distinctive human characteristics, beautiful operation interface and simple unified programming method. Big influence, with broad application prospects in multimedia creations, web applications, education software, software help systems and auxiliary tools.
I. Brief introduction to Microsoft Agent Technology
---- Agent's meaning is "agent", so the name, the main role of such agency software is to provide an operational interface that is easy to understand and use, accepts the user's instructions, instead of the user to complete some of the complexity Cumbersome work or help users. Scientific research shows that from the perspective of human machine engineering, more user-friendly colors are given to computers or programs, such as support speech synthesis output information, speech recognition input instructions, smart tips, animation, etc., can fully improve the effectiveness of human-machine interaction and Easy to use.
---- We know that there is a proxy software called Office Assistant in the Office 97 help system, with humorous animated characters, such as "big eye holder", can propose some depending on the user's operation step "intelligent" Suggestions or help information. Compared with the Office assistant, the Agent function is more powerful and manifested in:
The Office Assistant is fully blocked with the background behind the traditional opaque rectangular window; the Agent animation character is a "alwaysontop" window, only the character part is partially blocked, the rest is transparent.
The Office Assistant only allows all component calls of Office 97, and the Agent animation characters can be called by any Windows program;
Agent supports text balloons and input prompts that output text to a cartoon text balloon while output speech. If the computer system is installed in the computer system, when the user presses the input key, such as the Scroll Lock button, an input command window appears below the Agent person, indicating that it is "listening" the user's voice command.
Agent provides animated characters such as Genie, Merlin, Bobby and Peedy, not only with beautiful and humorous movements, but also through sound cards, microphones and users.
Second, Microsoft Agent installation method
---- Agent is an ActiveX control, its server program (C: /Windows/msAgent/agentsvr.exe) runs on the WIN95 / 98 / NT operation platform, providing services for other calling agents. The client can be a use of applications developed by VB, C , Delphi, VFP, PB, or Visual Script, Java Script scripting language code in the HTML file.
Install the Agent core component Msagent.exe.
Install Lernout & Hauspie Truvoice Text-to-Speech Engine (complete English from text synthetic voice, current version only supports English) CGram.exe.
Install Microsoft Command and Control Speech Engine (providing voice recognition feature, current version only supports English) ActCNC.exe.
Agent animated character human data file. Agent supports a single-structure role file (.acs, role data and animation data exists in the same file), also supports separation structural role files (.acf, role data existing in .acf, animation data exists in .aca). Based on local hard drives and network applications can use .acs files, web-based HTML files will be automatically called when accessing in the browser, and is used to usage .acs files. ---- The above file can be downloaded from http://www.microsoft.com//workshop/imedia/agent/default.asp.
Third, Microsoft Agent programming points
---- 1, add agent control in Delphi
---- Select Menu Component in Delphi IDE, Import ActiveX Control - Select Microsoft Agent Control 2.0 (Version 2.0) in the list box under Import ActiveX, click Button Install - Click the button OK in the Install dialog. Click on the button yes in the Confirm dialog. Click the button OK in the dialog. At this point, the Agent control is added to the Delphi component board ActiveX page.
---- 2, adjust the Agent control in Delphi
---- (1) Creating Project1 in Delphi IDE (containing Form1), place the Agent1 on Form1 (Name property is MyAgent), button1.
---- (2) define the variable.
Var PEEDY: IAGENTCTLCHARACTEREX; Request1, Request2: iAgentctLRequest; ---- (3) The main properties, methods, events.
---- 1Characters attribute and load, unload method: initialize the Agent, load animation data, uninstall the animated characters
---- Request1: = myagent.characters.Load ('peedy', 'c: /windows/system/peedy.acs'); ---- peedy: = myagent.characters.Character ('peedy'); --- Myagent.Characters.unload ('peedy');
---- 2SHOW and HIDE Method: Show, hide the Agent animation. The parameter FAST represents the movie character display, hidden speed. FAST is 0 indicates that Agent is flying, flying out, FAST is 1 means Agent directly, disappears, no animation process.
---- peedy.show (0); ---- peedy.hide (1);
---- 3Stopall, STOP method: Stop all actions. ---- peedy.stopall (''); ---- peedy.stop (request);
---- 4Connected Property: Is Agent to connect to a Microsoft Agent server. ---- myagent.connected: = true;
--- 5Get_Height, Get_Width, SET_HEIGHT, SET_WIDTH Method: Get the height, width of the Agent animation character.
AgentHight: = peedy.get_Height; agentwidth: = peedy.get_width; peedy.set_height (Round (AgentHeight / 2)); peedy.set_width (Round (AgentWidth / 2)); ---- 6Moveto method: parameter x, y Agent animation people move the coordinate, parameter speed represents the speed of movement. ---- peedy.moveto (Screen.width-peedy.get_width) Div 2, (Screen.height-peedy.get_height) Div 2, 2);
---- 7INTERRUPT method: Interrupt the animation of the specified role. In dozens of animation actions, there is a kind of action that is a kind of suffix "ING", such as "Processing", "Searching", "Reading", "Writing", once executed, you must by call another animated person's Interrupt Method can be interrupted. The role cannot be interrupted, otherwise it will result in an exception.
Request1: = Robby ('Reading'); peedy.interrupt (Request1); ---- 8wait method: Coordinating animation actions between multiple different animation characters, such as waiting for Srobby's current action, peedy Another action.
Request1: = Robby.Play ('read'); peedy.wait (request1); peedy.play ('search'); ---- ⑨play method: Perform the specified animation action, parameter animation is a constant, indicating animation type . Agent provides dozens of predefined actions, just call these constants directly when developing software. The following is a brief introduction to some of the commonly used constants are for programming purposes only.
---- Action Type Chinese Invention Action Type Chinese Invention Action Type Chinese Invention
Acknowledge admit LookDown looking down Sad sad Alert warning LookDownBlink looking down blink Search Announce looking statements LookUp to watch StartListening start listening to Blink blink blink LookUpBlink looking down StopListening stop listening Confused confused LookLeft look left Suggest recommended Congratulate Congratulations to blink to the left to see LookLeftBlink surprised Decline surprised to see the right to refuse LookRight think think DontRecognize does not recognize the right to see LookRightBlink wink Wave waving explain explain MoveDown move down Write down MoveUp writing GestureDown posture calculated move upward Processing ...... GestureUp up to the right posture MoveRight reading reading ...... GESTURELEFT moves to left postching MoveLeft to move searching ... GestureRight to right posture pleased Writing Writing Writing ... GetAttTent gets Note Read Read Greet Greeting RESTPOSE Recovery Initial Status Request: = peedy.play ('search'); ---- ⑩SPEAK Method: Agent uses the voice synthesis output function to support English synthesis engine, simply enter the English string, and the agent can pass the sound card and the speaker ". The current version of Agent does not have to support Chinese speech synthetic function, so "can only play Chinese in the form of .WAV file. The Chinese sentence you want to say is pre-recorded in advance, stored in .wav form, call it in the program. The parameter text represents the text displayed in the text balloon, the parameter URL represents the path to the .wav file. ---- Peedy.Speak ('Hey, friends, you are good, now I will help you!', 'C: / New folder / Help.wav');
---- peedy.speak ('do you like my help? If so, please send me an email! Thank you!', '');
---- ⑾commands.add method: Add a custom voice recognition command for the agent in the Button1Click event, the parameter const name indicates the identity of the voice command, the parameter caption indicates that the command is displayed in the input command window, the parameter Voice indicates the command. Corresponding statement. When the user issues a voice command through the microphone, triggered the Command event of the Agent, so we can additionally write a process to complete the speech recognition.
Procedure tForm1.Button1Click (Sender: TOBJECT); Begin Peedy.commands.add ('delphi', 'Run Delphi', 'delphi', true, true); peedy.commands.add ('Visual Basic', 'Run VB' , 'Vb', true, true); peedy.show (0); peedy.speak ('what can I do for you, sir?', '); End; ---- ⑷, press F9 running program. The above programs were debugged in Delphi3.0 / 4.0, Windows95 / 98 / NT Simplified Chinese version.