这个问题与如何从Word 2010 Addin(用C#开发)中获取"KeyPress"事件密切相关?(实际上包括来自该问题答案的示例代码),但这特别是关于在Windows 10中运行的Word 2016的Visual Studio(Professional)2015中进行开发.
我正在尝试检测来自VSTO加载项的Word文档中的文本何时更改.我从中了解到
没有事件驱动的方式来做到这一点.Word在文本更改时根本不发送事件.
我看过两个解决方法:
我试图在如何从Word 2010 Addin(用C#开发)中获取"KeyPress"事件的答案中使用代码?,它似乎观察每个keydown事件,除了那些发送到Word 2016.
这是我正在使用的代码,以便于参考.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace KeydownWordAddIn
{
public partial class ThisAddIn
{
private const int WH_KEYBOARD_LL = 13;
private const int WM_KEYDOWN = 0x0100;
private static IntPtr …Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个 office 插件,并且需要使用 C# 在 MS-Word 上捕获 keydown 事件。有人可以给我一个关于如何做到这一点的例子吗?