473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Keystroke trapping in background?

....newbie warning...

I am looking for a way to trap (and process) keystrokes before they are
passed to the foreground/active application. Something similar to how, for
example, the Alt-Tab key combination switches between applications, without
the apps ever seeing that particular keycode. Also, what is the best way to
pass the majority of keycodes that don't require additional processing on to
the foreground app?

Thanks in advance,

Ed
Jul 21 '05 #1
4 1432
In win32 you could use SetWindowsHookEx to hook WH_KEYBOARD or
WH_KEYBOARD_LL. I'm not sure if there is a .NET equivelent, but you could use
pinvoke.

Tom Wisnowski
MCP MCAD

"Ed B" wrote:
...newbie warning...

I am looking for a way to trap (and process) keystrokes before they are
passed to the foreground/active application. Something similar to how, for
example, the Alt-Tab key combination switches between applications, without
the apps ever seeing that particular keycode. Also, what is the best way to
pass the majority of keycodes that don't require additional processing on to
the foreground app?

Thanks in advance,

Ed

Jul 21 '05 #2
You'll need to setup windows hooks.
Different ways to hook in .NET:
http://www.sys-con.com/dotnet/article.cfm?id=482

More detailed articles with sample:
http://msdn.microsoft.com/msdnmag/is...0/CuttingEdge/
http://msdn.microsoft.com/msdnmag/is...1/CuttingEdge/
hope that helps..
Imran.

"Ed B" <Ed*@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
...newbie warning...

I am looking for a way to trap (and process) keystrokes before they are
passed to the foreground/active application. Something similar to how, for example, the Alt-Tab key combination switches between applications, without the apps ever seeing that particular keycode. Also, what is the best way to pass the majority of keycodes that don't require additional processing on to the foreground app?

Thanks in advance,

Ed

Jul 21 '05 #3
Since you're new I'll give you a complete solution already implemented to
work with C#... Take a look at this:
http://www.codeproject.com/csharp/globalhook.asp

"Ed B" wrote:
...newbie warning...

I am looking for a way to trap (and process) keystrokes before they are
passed to the foreground/active application. Something similar to how, for
example, the Alt-Tab key combination switches between applications, without
the apps ever seeing that particular keycode. Also, what is the best way to
pass the majority of keycodes that don't require additional processing on to
the foreground app?

Thanks in advance,

Ed

Jul 21 '05 #4
Thank You Tom, Imran, And Alex. The information that you provided was very
helpful. I look forward to the upcoming mental anguish of understanding all
of it ;-)

Ed
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Wugi | last post by:
I'm trying to find an equivalent of key-event trapping which is easy in QBasic. Several of my programs build up a geometric figure with two parameter line families, eg with two nested for..next...
7
by: hokieghal99 | last post by:
Does anyone know of a keystroke logger that has been written in Python for Windows machines? I'd like to see such a script and use it as a point of reference for a real-time backup project that I'm...
2
by: Wayne Wengert | last post by:
I want to get the decimal (integer) value of user keystrokes. I am using the following code. chrInput is the character entered (e.g. "M") and "keystroke is DIMed as Short keystroke =...
1
by: Amin Gunawan via .NET 247 | last post by:
I would like to put a combo box in a column of a datagrid. I've seen the samples in the MSDN library of other sources, butall samples didn't catch the 'DOWN/UP' keystroke. It means thatwhen I select...
3
by: windandwaves | last post by:
Hi Gurus Does anyone know how I set the error trapping to option 2 in visual basic. I know that you can go to tools, options and then choose on unhandled errors only, but is there a VB command...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
2
by: Mr Sparkles | last post by:
Heya Everyone, I am currently creating an application audit system that will log how much use an application will be used by employees of my company, and the type of features they use...so I...
2
by: beaker | last post by:
Hello, I'm writing a program (which will be running in the background 99% of the time) and I want to be able to work out how long it has been since the user last used the mouse and/or keyboard. ...
2
by: Captain Nemo | last post by:
I'm still using Office 2000 myself, but some of my clients have Office 2003. I've recently added a piece of code to create an instance of Word, open a document, fill in the blanks and become...
0
by: ionphoenix | last post by:
i to send data or keystroke to a non active emulator or application using vb. its like the input will be done in vb.net but in the background it will input it into the emulator.i need help badly i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.