473,385 Members | 1,351 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,385 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 1434
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
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.