Jump to content
  • Advertisement
Sign in to follow this  

I need some help guys

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing a macro like program that runs in another program with Visual Basic .NET 2003 Professional and for some reason i am unable to find a way to read the keystrokes using the API or .NET Framework so the macro can be shut off. EX( If i hit the "Insert" key or any combination like "control" + Insert" it would shut it off) See my program's form does not have the focus so i am sure i will have to use API or .NET Framework. Could anyone please give me some help because i would really be greatful. Thanks -Robert-

Share this post


Link to post
Share on other sites
Advertisement
Where can i get information on how to use a system-wide hook? Is this the same thing as using the windows API? I am going to simplify my question.

Simply Put:
"I want to be able to tell when a key is pressed, even when my program does not have the focus, and respond to that keypress. I am using VB .NET 2003."

That is why i think there is an API function to do this. The API can generate mouse_clicks and whatnot. I am just guessing that there has to be an API function to read when a key is pressed so that my computer program can respond to that keypress.

The reason i said maybe the .Net Framework can do this is because by using the Cursor.Pos of the .NET framework i can move the mouse cursor on my screen.
Example:
Cursor.Position = New Point(32,32)

The above code moves my mouse cursor to the the pixel location of x = 32 y = 32

I would have to guess that the .NET framework is linking to the API to do this. Because in visual basic 6.0 you had to write API at the top of your form before you could do this. But now it is as simple as Cursor.Position.

If i can move the mouse cursor cursor around using the .NET framework isn't there a .NET framework statement that will allow me to detect any keys that are being pressed, regardless of if my form has the focus or not, and handel that event?

I may indeed have to learn more of the .NET framework. The .NET Framework is huge library of thousands of classes that aid in application development and i do not know every aspect of it. If you could tell me what .NET Framework namespace contains the class that i need i would appreciate it. Or if the .NET framework does not contain the class i need could you tell me what API statement will get the task done?
Thanks.

Share this post


Link to post
Share on other sites
I wrote a keylogger/macro program before, and a global dll with a keyboard hook is the way to do it. I don't think that microsoft has made a point of porting everything from Win32 API to .NET, just the stuff related to the typical dialog/forms/controls stuff.

You will end up getting a windows message with LPARAM and WPARAM in your callback for the keyboard. If I could rememer the details id mention them here, but i forgot. Anyhow, one of those parameters will have your virtual key id, and the ctrl/alt/ect... modifiers.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!