问题
I need to be able to get all keypress events before they are passed up to the Word document. I want to do special handling of the keys and depending on what mode the add in is in, the keys may or may not be sent to the Word document. I only want the keypress events that belong to the document, I don't want to hook events for popup windows or other dialog boxes.
I have read something about smart tags, but don't know how they work.
If I have to subclass the document window, how can I get the window handle?
回答1:
use SetWindowsHookEx( WH_KEYBOARD_LL, ... to listen to keystrokes.
来源:https://stackoverflow.com/questions/262583/how-to-hook-keypress-event-in-a-word-shared-add-in