Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2007

Tip: Looking for answers? Try searching our database.

Key Stroke capture

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doug - 15 Jun 2007 19:06 GMT
In a VSTO project I want to be able to capture every keystroke and be given
control in my C# code so I can make a decision on what to do.

Such as somebody hits the space bar I want to insert a "Happy face".  Or if
someone selects and hits the delete key, I get to intercept the delete and
decide what to do if anything.

Any help is appreciated.

Doug
Cindy M. - 16 Jun 2007 10:28 GMT
Hi Doug,

> In a VSTO project I want to be able to capture every keystroke and be given
> control in my C# code so I can make a decision on what to do.
>  
> Such as somebody hits the space bar I want to insert a "Happy face".  Or if
> someone selects and hits the delete key, I get to intercept the delete and
> decide what to do if anything.

The Word object model doesn't provide this. You'd need to work over the
Windows API.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
Doug - 18 Jun 2007 00:39 GMT
Hi Cindy,

Thanks for the reply.

I am not familiar with the technique using Windows API.  Do you have some
links to any examples?

I appreciate the help.
Doug

> Hi Doug,
>
[quoted text clipped - 18 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
Cindy M. - 18 Jun 2007 11:11 GMT
Hi Doug,

> I am not familiar with the technique using Windows API.  Do you have some
> links to any examples?

No, I haven't, I'm sorry. The only people I've ever known who've managed to
do this successfully have been programming using C++. And they haven't
shared the details, once they've figured it out...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
Klaus Linke - 18 Jun 2007 17:11 GMT
> Hi Doug,
>
[quoted text clipped - 5 lines]
> do this successfully have been programming using C++. And they haven't
> shared the details, once they've figured it out...

I've tried a while ago. IIRC, the problem was to not interfere with Word's
handling of the input (which would make say the spell checker fail).
On another forum, Rory suggested:
"My admittedly brief reading on the subject seems to indicate that if you
use the CallNextHookEx function, it will then simply pass the keystroke on
down the line so it will be processed normally after you have registered
it."

Haven't ever gotten it to work, but maybe CallNextHookEx may turn something
up on Google?

Klaus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.