Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word VSTO - OnTextInput and OnTextComposition callbacks don't fire #19

Open
Robertocrotti98 opened this issue Aug 7, 2024 · 0 comments

Comments

@Robertocrotti98
Copy link

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);
  4. InputMethod.Initialize(GetFocus(), true);

None of these is working. What am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant