Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any way to handle Key press event of already opened word application to handle the idle status and to prompt a message box?

Word dosent have any specific Key Press events.. :(
Posted
Updated 15-Oct-16 19:38pm

Word handles it's own key press events. Why would you want to add your own ? Surely it depends what part of word has focus, too, I mean, if I press 2 in the text area, I just want to enter a 2, not have you hijack it.
 
Share this answer
 
Comments
ashok1042 1-Feb-12 1:24am    
Thanks for your response Christian!!

I need to handle the document's idle status, i mean for who long the document has been idle. So thought of adding a timer and reseting it on every key press and mouse click event.. if the time reaches a certain limit For eg, 20 mins. I want to display a message box saying. "This Document is idle for 20 minutes.. It will automatically close after 5 mins.."
Christian Graus 1-Feb-12 1:27am    
A quick google gave me http://support.microsoft.com/kb/302817 which lists all the events word supports. I don't see any that I think will help you, the document changed event is when you change the active document, not when a document is changed.
Microsoft Word VSTO doesn't contain KEYPRESS events but you can make it happen with some other logics. Check out the code snippet at Detecting text changes in Word 2016 from VSTO add-in - Stack Overflow.
 
Share this answer
 
You can use Hooks for keypress event, to get the value of pressed key. It will be a generic WinForms Application and you would be able to get info of events on any open application(including MS Word).

Visit these links, they will surely help you out.
MSDN help page on Hooks

An easy implementation of Hooks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900