Global Key Event Capute in C# on Vista

A

Alex Maghen

Hi - Sorry if I'm in the wrong forum. Trying to find the right place.

Back on XP, I had downloaded and messed with a C# wrapper library which
allowed me to globally capture keypress events (meaning, allowed me to
respond to keyboard key-presses even when my application was not "in front."
Now on Vista, that application of mine no longer works. And it's been so long
that I don't really remember what I had done there.

Is the a clean CE class or something for handling this that will work
properly on Vista too that someone knows of? And/or can someone guess why my
application won't work properly on Vista?

Much appreciated.

Alex
 
L

Linda Liu[MSFT]

Hi Alex,

What's the Win32 API function used in the C# wrapper library to capture
global key event?

I suggest that you use the SetWindowsHookEx function to install a hook
procedure to monitor keystroke messages.

I found a good article in the codeproject web site which discusses how to
install global system hooks in .NET and introduces a reusable class library.

You may visit the following link for more information:
http://www.codeproject.com/KB/system/globalsystemhook.aspx

I have run the demo application provided by the above article on Windows
Vista and it works well when monitoring keystroke messges.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex Maghen

Linda -

Thanks for this. I am having a little trouble building it and I'd appreciate
your help. I have downloaded and attempted to open the Solution (VS 2008).
The first time I opened it, it went through the Upgrade process on the
Projects, etc. and that went Ok. When I tried to run it, I got some errors
and now I can't remember what they were. Then I just tried reopening the
Solution and I'm getting an error when I try to open it:

"... SystemHookCore.vcproj cannot be opened because its project type
(.vcproj) is not supported by this version of Visual Studio."

I think that this is because I didn't install C++ with my VS installation,
right? I supposed I need this just in order to build and run the project? I
am only interested in using the Managed code in C#, but I supposed I need C++
to build the libraries?

You assistance is much appreciated.

Thanks.

Alex
 
L

Linda Liu[MSFT]

Hi Alex,

Thank you for your prompt response!

Since the sample solution provided in the article include a VC++ class
library project, you need to install VC++ with your VS installation to
build the VC++ project properly.

You can add the feature of VC++ in the VS setup from Control
Panel->Programs and Features.

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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