这是indexloc提供的服务,不要输入任何密码
Skip to content

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

@Robertocrotti98

Description

@Robertocrotti98

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions