How to use Microsoft Agent in C#

谷歌Gemini模型免费API调用全攻略:从注册到实战(附代码示例) 本文详细介绍了如何免费调用谷歌Gemini模型的API,从注册获取API密钥到实战应用的全过程。内容涵盖环境准备、基础API调用、多模态处理、高级功能及生产环境实践,帮助开发者高效利用Gemini模型进行代码生成和复杂任务处理。附有代码示例,适合AI开发者和技术爱好者。 阅读详情

http://www.codeproject.com/csharp/UseMsAgentCSharp.asp

 

Introduction

Microsoft Agent is a technology used to add interactive animated characters to windows application or web page; these characters act according to the user input via speech recognition engine, and also they can speak and tell the user something via text-to-speech engine. Microsoft provides programmers four characters

  • A-Peddy
  • B-Genie
  • C-Merlin
  • D-Robby.

Each character has its own set of animation

Background

I’ve searched well so many sites for code that I can use MS agent to provide help to end user. After searching the C# books , I’ve found some nice code that helped me to create this simple Application . Hope it can help as a basic architecture.

Using the code

At first you should simply open VS.NET and then at the File menu click on New, Project. From the New Project Dialog Box, choose the Windows Application template project and name it WindowsApplication1 like shown below:

After you create the windows add a button to it and name it speak and add a RichTextBox and name it talk , you should add to it Microsoft Agent component , to do that click on the Customize toolbox from tool menu then the following Dialog will appear

Select Microsoft Agent control 2.0 and click ok. Now in your tool box at the end of it you will find a new item added to it “Microsoft Agent”. Drag this item and drop it in your application, after drop “Microsoft Agent” the .Net will generate a new object from type AxAgentObjects.AxAgent as the following

namespace WindowsApplication1
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
           private AxAgentObjects.AxAgent axAgent1;
           /// <summary>
           /// Required designer variable.
           /// </summary>
           private System.ComponentModel.Container components = null;
 
           public Form1()
           {
                   //
                   // Required for Windows Form Designer support
                   //
                   InitializeComponent();
 
                   //
                   // TODO: Add any constructor code 
                   // after InitializeComponent call
                   //
           }

Now create object of type AgentObjects.IAgentCtlCharacter and name this object speaker ,now at the load function write the following

private void Form1_Load(object sender, System.EventArgs e)
           {
                   try
                   {                          
 
       //load the character  in the axAgent1 object -- 
      //axAgent1 can load more than one character
                    this.axAgent1.Characters.Load("Robby" , "robby.acs");   
 
      //give the speaker object the character to show it
                           this.speaker = this.axAgent1.Characters["robby"];
                           this.speaker.Show(0);
                   }
                   catch(FileNotFoundException)   //if the character not found
                   {
                           MessageBox.Show("Invalid charater location");
                   }
           }

In the speak button click function write the following code

private void speak_Click(object sender, System.EventArgs e)
           {
                   if(this.talk.Text != "")
             this.speaker.Speak(this.talk.Text , null);
                   else 
                      this.speaker.Speak("what should i say", null);
           }

In the speaker objects you will find some useful function that help you to control the character such as :

//MoveTo( int x , int y , objectspeed speed);
//Play(string animation);   
// this function make the character to play some animation 
 //The possible animations that the character can play it are
/******************
RestPose, Wave, DontRecognize, Uncertain, Decline,Sad, 
StopListening, GetAttention, GetAttentionReturn,Blink, Idle3_2, 
Surprised,Congratulate_2,Reading,Announce,Read ,ReadReturn,Idle2_2  ,
Writing ,Write ,WriteReturn ,Congratulate ,Confused ,Suggest ,MoveRight, 
MoveLeft,Idle2_1,  MoveUp, MoveDown, 
StartListening, WriteContinued, DoMagic1, 
DoMagic2,Idle1_1,  LookDown, LookDownBlink, LookDownReturn, LookLeft, 
LookLeftBlink, LookLeftReturn,Idle1_3,  LookRight, LookRightBlink, 
LookRightReturn, LookUp, LookUpBlink,LookUpReturn,Idle1_2,
ReadContinued, Pleased, GetAttentionContinued, Process, Search, 
Think,Idle1_4,Greet,Idle3_1,GestureUp,GestureDown,GestureLeft,
GestureRight,Show,Hide,Hearing_4,Hearing_1,Hearing_2,Hearin,
Alert,Explain,Processing,Thinking,Searching,Acknowledge
*********************/

The full code

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
 
namespace WindowsApplication1
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
           private AxAgentObjects.AxAgent axAgent1;
           private AgentObjects.IAgentCtlCharacter speaker;
           private System.Windows.Forms.Button speak;
           private System.Windows.Forms.RichTextBox talk;
           /// <summary>
           /// Required designer variable.
           /// </summary>
        private System.ComponentModel.Container components = null;
 
           public Form1()
           {
                   //
                   // Required for Windows Form Designer support
                   //
                   InitializeComponent();
 
                   //
                   // TODO: Add any constructor code after 
                   // InitializeComponent call
                   //
           }
 
        /// <summary>
           /// Clean up any resources being used.
           /// </summary>
           protected override void Dispose( bool disposing )
           {
                   if( disposing )
                   {
                           if (components != null) 
                           {
                                  components.Dispose();
                           }
                   }
                   base.Dispose( disposing );
           }
 
           #region Windows Form Designer generated code
           /// <summary>
           /// Required method for Designer support - do not modify
           /// the contents of this method with the code editor.
           /// </summary>
           private void InitializeComponent()
           {
                   System.Resources.ResourceManager resources = 
              new System.Resources.ResourceManager(typeof(Form1));
                   this.axAgent1 = new AxAgentObjects.AxAgent();
                   this.speak = new System.Windows.Forms.Button();
                   this.talk = new System.Windows.Forms.RichTextBox();
         ((System.ComponentModel.ISupportInitialize)
                 (this.axAgent1)).BeginInit();
                   this.SuspendLayout();
                   // 
                   // axAgent1
                   // 
                   this.axAgent1.Enabled = true;
                   this.axAgent1.Location = new System.Drawing.Point(0, 232);
                   this.axAgent1.Name = "axAgent1";
                   this.axAgent1.OcxState = 
                       ((System.Windows.Forms.AxHost.State)
                        (resources.GetObject("axAgent1.OcxState")));
                   this.axAgent1.Size = new System.Drawing.Size(32, 32);
                   this.axAgent1.TabIndex = 0;
                   // 
                   // speak
                   // 
                   this.speak.Location = new System.Drawing.Point(192, 176);
                   this.speak.Name = "speak";
                   this.speak.Size = new System.Drawing.Size(168, 48);
                   this.speak.TabIndex = 1;
                   this.speak.Text = "speak";
                   this.speak.Click += 
                     new System.EventHandler(this.speak_Click);
                   // 
                   // talk
                   // 
                   this.talk.Location = new System.Drawing.Point(24, 24);
                   this.talk.Name = "talk";
                   this.talk.Size = new System.Drawing.Size(328, 136);
                   this.talk.TabIndex = 2;
                   this.talk.Text = "";
                   // 
                   // Form1
                   // 
                   this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
                   this.ClientSize = new System.Drawing.Size(376, 270);
                   this.Controls.AddRange(new System.Windows.Forms.Control[] {
                         this.talk,
                         this.speak,
                         this.axAgent1});
                   this.Name = "Form1";
                   this.Text = "Form1";
                   this.Load += new System.EventHandler(this.Form1_Load);
                   ((System.ComponentModel.ISupportInitialize)
                         (this.axAgent1)).EndInit();
                   this.ResumeLayout(false);
 
           }
           #endregion
 
           /// <summary>
           /// The main entry point for the application.
           /// </summary>
           [STAThread]
           static void Main() 
           {
                   Application.Run(new Form1());
           }
 
           private void Form1_Load(object sender, System.EventArgs e)
           {
                   try
                   {                          
                    this.axAgent1.Characters.Load("Robby" , "robby.acs");    
//load the character  in the axAgent1 object  
// -- axAgent1 can load more than one character
 
                 this.speaker = this.axAgent1.Characters["robby"];     
                     //give the speaker object the character to show it
                           this.speaker.Show(0);
                   }
         catch(FileNotFoundException)   //if the charater not found  
                       // using IO 
                   {
                           MessageBox.Show("Invalid charater location");
                   }
           }
 
           private void speak_Click(object sender, System.EventArgs e)
           {
                   if(this.talk.Text != "")
             this.speaker.Speak(this.talk.Text , null);
 
                   else 
                           this.speaker.Speak("what should i say", null);
 
           }
    }
}
 

Tip

You should download the TTS “text-to-speech ” engine on your computer to make the character talk. To download the engine see

About Ahmed jamil Kattan


Ahmed J. Kattan student in Jordan University of Science and Technology computer science department 4th level, I have written
several applications and designed multiple algorithms. My favorite languages are C++ and C#.

see www.geocities.com/ahmed_gk to view Ahmed J. Kattan 's online CV.

Click here to view Ahmed jamil Kattan's online profile.


Other popular C# Programming articles:

Linux系统下SAPGUI安装包选择与避坑指南 本文详细介绍了在Linux系统下选择和安装SAPGUI安装包的策略与避坑指南。重点解析了不同版本安装包的关键区别,特别是Linux版必须包含linux-lib.jar和linux64-lib.jar文件,避免误用Mac或Windows版导致的兼容性问题。文章还提供了针对Ubuntu、RHEL等不同Linux发行版的安装实战指南,以及常见报错的解决方案,帮助用户顺利完成SAPGUI的安装与配置。 阅读详情

相关推荐

手把手教你用Python+GDAL处理0.5米吉林一号卫星影像(附代码)

本文详细介绍了如何使用Python和GDAL处理吉林一号0.5米高分辨率卫星影像,包括环境配置、数据预处理、分辨率融合、植被指数计算及地物分类等关键步骤。通过实战代码示例,帮助开发者高效处理大尺寸遥感数据,解决资源崩溃和算法选择问题,提升遥感影像分析能力。

weixin_30892037的博客 126

Microsoft Agent Framework/C#:了解Workflows的几种不同模式

最近有空的时候在学习Microsoft Agent Framework,在这个框架中目前Workflows分为了Sequential、Concurrent、Handoffs以及Groupchat四种模式,今天让我们来了解一下这四种不同的模式。

2501_93908980的博客 1188

别再为CAD和GIS数据对不上而头疼了!一份完整的ArcGIS for AutoCAD坐标系定义与数据套合指南

本文详细介绍了如何通过ArcGIS for AutoCAD插件解决CAD与GIS数据坐标系不匹配的问题,实现数据的精准套合。文章从坐标系冲突分析、插件核心功能解析到五步标准化工作流,提供了完整的解决方案,帮助工程师和设计师提升跨平台协作效率。

weixin_42531886的博客 216

How to run an existing SQL Server Agent Job from C#

If you want to execute an existing Microsoft SQL Server Agent Job in C# you an use the following function: The function uses SQL authenticat

Burgess_Liu的专栏 1677

网络系统实现技术之IPX与SPX

IPX/SPXNovell NetWare网络Novell公司为适应网络发展,将主机网络转换为PC网络,开发了Novell NetWare网络系统。该系统中基于客户机/服务器模式。以普通PC机做为客户机,以性能强大的服务器做为服务器,为客户机提供文件服务、数据库服务及其他服务。与前面的SNA模型一样,Novell NetWare也早于OSI模型,所以不能与OSI模型严格对应,但也有很明

成片的大树 9164

HDR视频技术之七:逆色调映射

HDR 技术说是继 4K 之后视频领域的又一次重大技术突破,不仅提高图像的动态范围,同时也提供了更宽的色域,并提升了画面在高光和暗部的细节信息,带给观看者更加真实的视觉体验。但作为 HDR 产业链的核心,内容短缺的问题仍然是 HDR 普及和成熟的重要限制因素。众多电视厂商将 HDR 技术作为其产品规划中的重要技术,主要是在硬件方面进行提升。而由于 HDR 内容制作对于设备要求较高,对采集、调色、显示等多方面都需要较高的质量要求,内容制作的复杂度和周期长等因素,导致了 HDR 内容的匮乏。

多媒体开发者 2422

第2课:探索AI Agent框架

能力说明现实例子个性化AI分析用户行为和偏好,提供个性化推荐Netflix根据你的观看历史推荐电影自动化和效率AI自动执行重复任务、简化工作流程客服聊天机器人处理常见咨询,让人工客服专注复杂问题增强用户体验通过语音识别、NLP等智能功能改善体验Siri理解并响应语音命令这些功能确实很好,但它们还不够。在AI Agent的语境中,“实时学习”并非指Agent在运行过程中重新训练模型(那需要大量的计算资源和时间)。记住用户的历史反馈和偏好调整自己的行为策略在后续交互中应用之前学到的经验💡。

qq_33537936的博客 228

企业微信群机器人Webhook配置全攻略:从创建到发送消息的完整流程

本文详细介绍了企业微信群机器人Webhook的配置流程,从创建机器人到获取Webhook地址,再到发送各类消息的完整步骤。通过Python代码示例展示了文本、Markdown等消息类型的发送方法,并提供了性能优化建议和常见问题排查技巧,帮助企业高效实现自动化消息推送。

weixin_29208327的博客 6822

Microsoft Agent Tutorial Chapter 1

Microsoft Agent Tutorial Chapter 1 Author: AbstractvbDate: 4/22/2000 6:53:44 PMID: 83Microsoft Agent Version 2 Needed.This starts a beginner level and shows how to load the control, use speech out

sonicdater的专栏 1065

图像拼接(Image Stitching)

图像拼接(Image Stitching):是一项计算机视觉技术,它将多张重叠的图像合并为一张更大、无缝的全景图或广角视图。该技术广泛应用于全景摄影、地图制作、医学影像处理、计算机视觉及增强现实(AR)等领域。

📷 图像处理践行者 | 传统算法 · 深度学习 · 多模态 | 分享实战经验与技术洞见,探索从像素到智能的无限可能。 2504

基于STM32、HAL库的IP5356M_DBZ_CA快充协议芯片简介及驱动程序设计

IP5356M_BATTERY_LEVEL_25 = 1, /* 电池电量25% */IP5356M_CHARGE_STATE_CHARGE_DONE = 4, /* 充电完成 */IP5356M_CHARGE_STATE_FAST = 2, /* 快速充电 */IP5356M_CHARGE_STATE_NONE = 0, /* 无充电 */IP5356M_CHARGE_STATE_PRE = 1, /* 预充电 *//* 延时1秒 */

corlin6688的博客 1417

MAF快速入门(23)通过C#类定义Skills

MAF快速入门(23)通过C#类定义Skills

寒冰屋的专栏 65

华为OD机试 C++【TLV解析】

这里的valueOffset指的是value在整串消息里的起始位置(从0开始数)。这表示tag是15(十六进制的0F),length是4,接着的8个字符是value的内容。你收到了一串由两端设备传递的TLV格式的消息,现在你需要根据这串消息生成一个对应的(tag, length, valueOffset)列表。tag是15,对应的数据长度为4,value从第3个字节开始,所以偏移量为2。第二行:一个数字n,表示我们给出的tag的数量(0 < n < 1000)。第一行:一串消息,长度不超过10000。

wtswts1232的博客 482

[MAF预定义的AIContextProvider-10]TodoProvider:用TodoList驱动Agent的任务执行

该文介绍了一种解决大型语言模型(LLM)执行多步骤复杂任务时注意力涣散问题的方法——使用TodoList机制。通过创建TodoList记录任务步骤,并在每完成一步后标记状态,可有效避免步骤遗漏或重复。文章以自动化部署为例,展示了如何通过TodoProvider和四个工具函数(PullLatestCode、BuildDockerImage等)实现可靠的多步骤部署流程。代码示例演示了Agent如何严格按TodoList顺序执行,并在每步完成后调用标记功能,最终输出清晰的部署结果和状态报告,显著提升了复

JaydenAI的博客 513

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

.NET+AI | Agent | MAF 会话历史存储全解析,从三大主流 AI API 讲起,不仅 Know What,而且讲清 Why and How

.NET+AI | Agent | MAF 会话历史存储全解析,从三大主流 AI API 讲起,不仅 Know What,而且讲清 Why and How

寒冰屋的专栏 64

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Windows本地AI Agent开发实战:从环境搭建到系统集成

AI Agent(智能体)作为以大语言模型(LLM)为核心,具备规划、记忆和工具调用能力的智能系统,正推动着下一代人机交互范式的变革。其核心原理在于通过感知、思考、行动、观察的循环,自主完成复杂任务,超越了传统单轮对话的Chatbot。这一技术价值在于将AI从单纯的对话能力升级为可执行、可协作的自动化工作流,极大地提升了信息处理与任务执行的效率。在应用场景上,AI Agent广泛适用于自动化办公、智能数据分析、个性化服务助手及多系统集成等领域。本文聚焦于在Windows环境下,如何克服开发环境异构、系统权限

weixin_33889665的博客 439

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

[MAF预定义ChatClient中间件-01]LoggingChatClient:在LLM调用前后输出日志

LoggingChatClient是一个用于记录LLM调用的中间件,继承自DelegatingChatClient。它会在调用前后输出日志,记录输入输出内容、时间戳等信息,支持通过日志级别控制输出详细程度。演示代码展示了如何将其与OpenAIClient集成,在Debug级别记录调用状态,在Trace级别还会输出完整的请求响应内容,便于调试和监控Agent行为。

JaydenAI的博客 699

GPT-5.5智能体:从机械执行到自主决策的范式重构

智能体(Agent)是大模型落地生产的核心形态,其本质是将自然语言目标转化为可执行、可验证、可容错的自动化流程。传统智能体依赖外部框架实现工具调用、记忆管理和显式规划,存在语义鸿沟、状态失忆与路径僵化等根本缺陷。GPT-5.5 通过原生支持目标导向推理闭环(Goal→Plan→Execute→Observe→Reflect→Revise),实现了内生状态压缩、隐式目标流形与树状博弈式目标分解,使智能体具备真正的自主性——不仅选择动作,更能理解动因、应对失败、自证结果。这一升级直接支撑agentic RAG、

weixin_30607659的博客 440

大型CAx(CAD/CAE/CAPP/CAM)工业软件开发中的关键组件

通过对FreeCAD、SALOME等多款代码的分析研究,发现这些软件在架构设计、模块实现等方面,存在许多相似(同)的技术思想。因此,有必要对这些共性、主流的技术予以总结分析。

国产CAx(CAD/CAE/CAM)软件研发 1万+

2018-2-13-win10-UWP-RSS阅读器

title author date CreateTime categories win10 UWP RSS阅读器 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17:23:3 +0800 Win10 UWP 今天在win10.me看到一个...

lindexi 998

开源项目选型决策地图:从665个仓库精准定位1个可用方案

开源项目选型不是简单搜索‘GitHub 开源项目’,而是围绕真实工程需求展开的系统性决策过程。其核心在于理解项目存活能力、技术层级适配性与团队技术栈匹配度。实用工具类项目常陷于Star数陷阱,需验证CI/CD真实性、依赖锁定完整性、Issue响应质量及最小可行示例可运行性;AI相关项目则存在API消费者、模型服务、训练三层鸿沟,误判层级将导致集成失败。本文基于665篇结构化开源项目分析,提炼出‘需求穿透法’——通过定义最小可行问题(MVP)、绘制技术栈坐标系、执行三问过滤,实现从海量资源中精准识别高存活率、

adr5970的博客 312

微软技术日报 11-09:.NET 8 与 9 明日同时停止支持,注册表编辑器出了 WinUI 3 版

今天这四条消息的共同点是收口。.NET 8 和 9 的支持期到点,注册表编辑器的新界面只放在仓库里给人看,GitHub 把一类危险触发器按住默认,微软在安全报告里把防线从地址黑名单挪到行为。收口并不等于关门。.NET 10 还在支持期里,被按住的触发器可以用策略按文件放回来,实验室里的样例随时可能变成产品。区别在于这些动作要有人签字,不再是默认开着。如果今天只做一件事,去看一眼构建机上的 .NET 版本。明天之后,8 和 9 的漏洞补丁不会再来了。

海盗Sharp的博客 294

设置ODBC的自定义类CSetODBC

何志丹一,功能描述用于配置数据源用户名及密码.1,可以得到连接串,此串可用于CMyRecordset(派生于CRecordset)的GetDefaultConnect(),也可以用干CDataBase类OpenEx.2,如果用户配置正确,只需要配置一次,相关信息记录在文件.3,可以指定存储信息的文件名.因为有可能几个程序共用一个数据源.4,用户可以重新配置数据5,可以得到当前数据的类型.6

闻缺陷则喜何志丹 3110

微软技术日报 2026-11-05:安装器变现链被拆开、OneLake 托管 MCP、Agent 365 进 Gartner 象限

把这几条放在一起看,共同点是把已经铺开的东西补上治理。安装器那条最直白。用户自己点开的程序,装完还会往回连,落地的东西藏在计划任务里、Program Files 里,用户不知道。微软给的检测思路也是往这个方向走的,看临时目录、看回调、看 SYSTEM 任务,而不是追域名。OneLake 那条是给 agent 补路标。以前每种 item 类型都要维护一份端点清单,现在让服务自己报出来。好处是 agent 不用猜,代价是判断责任转移到了客户端,技能要不要加载得自己决定,标签也不能当成授权。

海盗Sharp的博客 1352

微软技术周报 11-02~11-09:VS Code 混装 Claude 与 Codex、EF Core 11 静默改行为、.NET 11 倒计时

11 月 6 日,Power Platform 通过消息中心通知管理员,Copilot Studio、Power Automate 和 Power Apps 里所有跑在 Anthropic Claude、xAI Grok 以及旧版 GPT 上的 prompt,12 月 2 日自动迁移到 GPT-6 系列,档位价格不变,模型选择收窄到一条产品线。效果是这样的:让 Claude 评审一个 Copilot chat 写出的方案,或者把同样的任务交给 Codex,两边并排跑在同一个会话里。更要紧的是下周的时间线。

海盗Sharp的博客 391

微软常用运行库合集免费下载安装教程(附运行库安装包)微软运行库安装图文教程

系统装完后出现“丢失xxx.dll”错误,多因缺少微软运行库所致。微软常用运行库合集将2005至2022年主流版本打包,一键安装,覆盖绝大多数软件依赖。无需判断版本,全选安装即可,装完建议重启。该合集可重复安装,不冲突,且与系统自带组件共存。适用于刚装系统的用户,能有效解决软件打不开、闪退等问题。

kk_net8899的博客 164
上一篇: Remote Scripting
下一篇: Client Callbacks in ASP.NET 2.0
colderboy
博客等级 码龄26年 1粉丝 3原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值