473,722 Members | 2,325 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to capture all keystrokes to my application

I'm trying to implement a macro feature in my application by recording
and playing back keystrokes. At first I thought it would be enough to
catch KeyDown in my main form, but I soon realized that I needed to
catch keystrokes in menues and other forms in my app as well.

I realize I can implement a keyboard hook that catches keystrokes
globally, but I only want the keystrokes that are sent to my
application.

Any suggestions on how to accomplish that?

/Gunnar
Jul 7 '06 #1
3 5052

This is verry easy

just set the keypreview property of your form to true now you catch all
keystrokes on that form with the form`s key events

if this is not enough for you ,, you can also implement a messagefilter
interface

i have once posted an example as an alternative of subclassing the
webbrowser control you can easily convert this to catch and process all
Windows messages
in this situation you wil receive every message sent to the window ( moving
, minimizing , mouse moves , keypress etc etc )
you can find this code here http://www.freevbcode.com/ShowCode.Asp?ID=5635

although i think it is a bit overdone in this situation
regards

Michel Posseth MCP


<Gunnar Syrenschreef in bericht
news:u3******** ******@TK2MSFTN GP05.phx.gbl...
I'm trying to implement a macro feature in my application by recording
and playing back keystrokes. At first I thought it would be enough to
catch KeyDown in my main form, but I soon realized that I needed to
catch keystrokes in menues and other forms in my app as well.

I realize I can implement a keyboard hook that catches keystrokes
globally, but I only want the keystrokes that are sent to my
application.

Any suggestions on how to accomplish that?

/Gunnar

Jul 7 '06 #2
Well, Michel, since I need to catch the keystrokes for all forms and
all menues, KeyPreview doesn't do it - that was my first idea. I guess
I'll see if I can adapt your code to suit my purpose.

Thanks,
/Gunnar

Michel Posseth [MCP] wrote:
>
This is verry easy

just set the keypreview property of your form to true now you catch
all keystrokes on that form with the form`s key events

if this is not enough for you ,, you can also implement a
messagefilter interface

i have once posted an example as an alternative of subclassing the
webbrowser control you can easily convert this to catch and process
all Windows messages in this situation you wil receive every message
sent to the window ( moving , minimizing , mouse moves , keypress etc
etc ) you can find this code here
http://www.freevbcode.com/ShowCode.Asp?ID=5635

although i think it is a bit overdone in this situation
regards

Michel Posseth MCP


<Gunnar Syrenschreef in bericht
news:u3******** ******@TK2MSFTN GP05.phx.gbl...
I'm trying to implement a macro feature in my application by
recording and playing back keystrokes. At first I thought it would
be enough to catch KeyDown in my main form, but I soon realized
that I needed to catch keystrokes in menues and other forms in my
app as well.

I realize I can implement a keyboard hook that catches keystrokes
globally, but I only want the keystrokes that are sent to my
application.

Any suggestions on how to accomplish that?

/Gunnar


--

Jul 7 '06 #3
"Gunnar" wrote:
Well, Michel, since I need to catch the keystrokes for all forms and
all menues, KeyPreview doesn't do it - that was my first idea. I guess
I'll see if I can adapt your code to suit my purpose.
Hello Gunnar,

If you need to monitor keyboard input across all forms in your application,
then the IMessageFilter method suggested in the other message is the way to
go.

We offer a .NET component FREE for non-commercial use that will do this for
you:

http://www.mini-tools.com/goto/input

--
Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com

Jul 10 '06 #4

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

Similar topics

3
9014
by: Wayne | last post by:
I have a console application (ssh2.exe) that requires keystrokes to be sent to it after activating. I have worked that it needs to be started in it own thread, but capturing the process and sending the keystrokes escapes me at the moment. Is there any material online that describes the process of sending keystrokes to a console app?
5
2727
by: Lucas Tam | last post by:
Hi all, Has anyone done this before? Send client side keystrokes to an application from a webpapge? This maybe more of a Javascript question. In short, I have an application on the client's desktop that needs to communicate with an ASP.NET application. The only interface into the application are keystrokes and DDE.
4
1361
by: VB Programmer | last post by:
I have a telnet application with a GUI. When I hit ESC, CTRL-Z, etc... I want it to perform some custom actions. How can I capture these keystrokes?
6
996
by: wael | last post by:
Hello everyone, Can someone please explain to me how spywares work? I would like to know how to capture all key strokes in any active application, also, getting the contents of chat programs like Yahoo Messenger? And before anyone is going to start flaming me, it is totally for my own personal information and not for any evil purpose.
1
1799
by: Tor Inge Schulstad | last post by:
Hi group! I want to make a windows service application that counts all the keystrokes a user does on the computer. Can anyone give me a hint on how i can detect those keystrokes when they are in another application then the counting application itself? __ Thanks in advance
0
1360
by: abcd | last post by:
Is there a way to capture key strokes on a system using python (other than pyHook)? can wxPython capture keystrokes for the system (not just, say a text box)? thanks
4
13084
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
I know how to capture a keypress for a windows application, but how would I go about doing it for a windows service? Rather than having a form in focus all the time, I would prefer to have something running in the background. There are option such as having the form invisible (opacity set to zero) and settings it's location as -200, -200 so that it isn't on the screen, but this isn't the ideal solution.
8
9641
by: Larry Smith | last post by:
Hi there, Can someone enlighten me on how to trap a keystroke in my "PropertyGrid" override. I see functions or properrites at the control or form level called: OnKeyDown OnKeyPress OnKeyUp OnPreviewKeyDown
4
4685
by: Uriel88 | last post by:
Hello, I am working with developing an application that uses the Netmon 3.2 API. Currently they have a PInvoke wrapper to access unmanaged C++ DLL functions. Basically what I am attempting to do is rewrite an example application (written in C++ and provided in their documentation) in C#. Everything compiles fine and executes, but I have no .cap file at the end of the run. Some things that may be wrong: the ADAPTER_INDEX is not correct OR...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9382
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2601
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.