如何在应用程序内实现交互式教程?

发布于 2024-12-05 15:03:08 字数 219 浏览 0 评论 0原文

我有 Word 的 C# 插件,并且想要实现像游戏通常具有的交互式教程。我想以某种方式突出显示(也许通过圈出)某些视觉元素并显示描述该元素功能的文本框。例如,假设加载项是通用工作流编辑器。我想通过直观地选择元素并解释它们的作用以及他有哪些选项来逐步向用户展示需要做什么。我的第一个问题是:这可以在 C# 中完成吗?我的第二个问题是如何? :) 我想我必须获得所述视觉元素的位置,然后在顶部绘制图像,但我不知道如何做到这一点。

I have C# add-in for Word and would like to implement an interactive tutorial like games usually have. I'd like to somehow highlight (maybe by circling) certain visual elements and display text boxes that describe what the element does. For example, say the add-in is a generic workflow editor. I'd like to show to the user, step by step, what needs to be done by visually selecting elements and explaining what they do and what options (s)he has. My first question is: can this be done in C#? My second question is how? :) I suppose I'd have to get the positions of said visual elements and then draw an image on top but I don't know how that could be done.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故人如初 2024-12-12 15:03:08

令我有点失望的是,甚至 Stack Overflow 社区的任何成员都没有花时间至少对此做出暗示。但这就是生活,我只是想在这里分享我的发现,因为我确信其他人会从中受益。

为了能够进行交互式教程,您需要三件事:

  • 一种根据屏幕坐标查找控件所在位置的方法;
  • 一种通过突出显示控件来将用户指向该控件的方法;或者
    例如,用红线围绕它。
  • 执行默认操作的方法(即:单击按钮)。

换句话说,其想法是拥有某种窗口,其中包含描述控件的文本以及在应用程序中指示控件的某种图形方式。或者,该窗口可以提供类似 ShowMe 按钮的内容,该按钮向用户展示如何通过控制鼠标和键盘来使用该控件。

当控件是由您自己制作并因此可以访问源代码时,这是微不足道的。但是,当对 Word 等黑盒应用程序执行此类操作时,您可以使用 Windows IAccessible 界面。使用您最喜欢的搜索引擎搜索该内容将获得您理解和使用它所需的一切。 IAccessible 允许人们做很多事情,但最重要的是它可以获取控件的位置并且还可以执行默认操作。

整理完这些内容后,下一步就是弄清楚如何以图形方式指出控件。有很多方法可以做到这一点,但在我的例子中,我选择用红色矩形包围它。我通过创建一个不可见的、无边框的窗体,上面有一个空的红色矩形来做到这一点。有了控件的位置和大小,我可以毫无问题地将上述表单放置在控件上。

这样你就得到了。我列出了为任何应用程序制作交互式教程所需的构建块。

I'm a bit disappointed that not even a single member of the Stack Overflow community took the the time to at least give a hint about this. But such is life and I'm just going to share my findings here because I'm certain someone else will benefit from them.

To be able to do an interactive tutorial you need three things:

  • a method to find where a control is located in terms of screen coordinates
  • a method to point the user to the control by highlighting it or
    surrounding it with a red line for example.
  • a method to do its default action (ie: click a button).

In other words, the idea is to have some sort of window with text describing a control and some graphical way of indicating the control in the app. Optionally, the window could provide something like a ShowMe button which shows the user how to use the control by taking control of the mouse and keyboard.

This is trivial when the controls are made by yourself and thus have source code access. However, when doing such a thing for a black box app such as Word you can use the Windows IAccessible interface. Searching for that with your favorite search engine will yield everything you need to understand it and use it. IAccessible allows one to do many things but most importantly it can get a control's position and can also do the default action.

Having sorted out these things the next step is to figure out how to graphically point out the control. There are many ways to do this but in my case I chose to surround it with a red rectangle. I did this by creating an invisible, borderless form with an empty red rectangle on it. Having the control's position and size, I had no problems placing the aforesaid form over the control.

So there you have it. I laid out the building blocks that one needs to make an interactive tutorial for any app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文