简体   繁体   English

我可以使用哪些事件来监视在Word中键入的用户?

[英]What events can I use to monitor users typing in Word?

I'm trying to write some code which executes as you type in Word. 我正在尝试编写一些在您键入Word时执行的代码。

Which events should I observe to catch individual words or characters? 我应该观察哪些事件来捕捉单个单词或字符? Ideally I'd rather not observe keystrokes through some dll calls. 理想情况下,我宁愿不要通过某些dll调用来观察击键。 I assumed the Word object model would expose some classes with native VBA events, but the only two event objects: 我假设Word对象模型将公开本地VBA事件的某些类,但是只有两个事件对象:

Word.Document
Word.Application

don't have any events that leap out at me. 没有发生在我身上的任何事件。 ( Document_Change event doesn't seem to do what I want) Document_Change事件似乎不执行我想要的操作)

Is there a native way of executing a code when the text content of the document changes? 当文档的文本内容更改时,是否有本机执行代码的方法?

Word provides no events for capturing the user's typing. Word 没有提供任何事件来捕获用户的键入。

That leaves: 留下:

  • "keyboard hooks" at the Windows API level. Windows API级别的“键盘挂钩”。

  • Or assigning a VBA macro to each and every possible key combination (a KeyBinding ). 或为每个可能的组合键分配一个VBA宏(一个KeyBinding )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM