|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need to capture all keystrokes to my applicationI'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 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 Syren> schreef in bericht Show quoteHide quote news:u30aXBaoGHA.4040@TK2MSFTNGP05.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 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: Show quoteHide quote > > 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 Syren> schreef in bericht > news:u30aXBaoGHA.4040@TK2MSFTNGP05.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 -- "Gunnar" wrote: Hello Gunnar,> 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. 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
Alternative to using Bitmap
Really stupid looping problem Regex Output to Textbox Startup speed Urgent! Get rowindex - datagrid navigation Q: skipping a For Each How to drag a form around the screen? Custom coordinates Including a document into a project using code... How open other app from within code? |
|||||||||||||||||||||||