在C#中处理MS Word中的按键事件 [英] In C# Handling Key Press event in MS Word

查看:99
本文介绍了在C#中处理MS Word中的按键事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法处理已打开的word应用程序的按键事件来处理空闲状态并提示消息框?



Word dosent有任何特定的按键事件.. :(

推荐答案

Word处理它自己的按键事件。你为什么要添加自己的?当然它取决于单词的哪个部分也有焦点,我的意思是,如果我在文本区域按2,我只想输入2,而不是你劫持它。
Word handles it's own key press events. Why would you want to add your own ? Surely it depends what part of word has focus, too, I mean, if I press 2 in the text area, I just want to enter a 2, not have you hijack it.


Microsoft Word VSTO不包含KEYPRESS事件,但您可以通过其他一些逻辑来实现。请查看检测Word 2016中的文本更改中的代码段VSTO加载项 - 堆栈溢出
Microsoft Word VSTO doesn't contain KEYPRESS events but you can make it happen with some other logics. Check out the code snippet at Detecting text changes in Word 2016 from VSTO add-in - Stack Overflow.


您可以使用Hooks进行按键事件,获取按下键的值。它将是一个通用的WinForms应用程序,你会是能够获得任何打开的应用程序的事件信息(包括MS Word)。



访问这些链接,他们一定会帮到你。

关于挂钩的MSDN帮助页面



轻松实现挂钩
You can use Hooks for keypress event, to get the value of pressed key. It will be a generic WinForms Application and you would be able to get info of events on any open application(including MS Word).

Visit these links, they will surely help you out.
MSDN help page on Hooks

An easy implementation of Hooks


这篇关于在C#中处理MS Word中的按键事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆