Hi, I am programming a VSTO add-in for Microsoft Word and I have problems with "OnTextInput" and "OnTextComposition" callbacks. I just need to intercept what the user is writing inside the body of the Word document, but I can't get the callbacks working. Maybe it could be a problem of initialization, related to the window handle. I've tried to obtain the HWND in many ways:
Hi, I am programming a VSTO add-in for Microsoft Word and I have problems with "OnTextInput" and "OnTextComposition" callbacks. I just need to intercept what the user is writing inside the body of the Word document, but I can't get the callbacks working. Maybe it could be a problem of initialization, related to the window handle. I've tried to obtain the HWND in many ways:
1)
InputMethod.Initialize(Process.GetCurrentProcess().MainWindowHandle, true);
2)InputMethod.Initialize((IntPtr)Application.ActiveWindow.Hwnd, true);
3)InputMethod.Initialize((IntPtr)Application.Windows[0].Hwnd, true);
3)InputMethod.Initialize(GetFocus(), true);
None of these is working. What am I doing wrong?