Key Stroke capture

D

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.

Any help is appreciated.

Doug
 
C

Cindy M.

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 :)
 
D

Doug

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
 
C

Cindy M.

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 :)
 
K

Klaus Linke

Cindy M. said:
Hi Doug,

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...


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top