Hello,

I need to write a program that runs along with an emulator. The goal of my program is to intercept certain keystrokes before the emulator gets them, and then send the emulator back some different keystrokes.

I want the program to use as few CPU resources as possible, as this will kill the performance of the emulator. I need the program to be active enough to not miss a keypress, but that is it, no more active than that.

I believe the emulator was wrote in VB. Is this an impossible task. Can someone tell me how to do this, or at least point me in the right direction.

I appreciate any help.

Thanks.

Recommended Answers

All 3 Replies

Here is some code for VB to code it in the KeyPress event handler:
In this code there is a Text Box called txtFindCall

To allow the Form's Key events be executed,
set the KeyPreview property to "True".

Find the Ascii value for your keys there are tables for this
Use the Ascii code to check for the key or keys actually PRESSED
Then set the event or key presses you want to actually happen within the If-Then block.
Where I have coded, "cmdFind_Click"

Private Sub txtFindCall_KeyPress(KeyAscii As Integer)
 
If KeyAscii = 13 Then
   cmdFind_Click
   Exit Sub
End If
 
End Sub

Ok, I have done some research, and found out the emulator uses DirectInput. So I believe I will need to hook the keystrokes, but I really have no idea how to do that.

I will need to hook the keystrokes, then, I will also need to inject keystrokes back into DirectInput.

I have read some articles on this, but they were all pretty intense. Is this a somewhat easy task, or is it pretty difficult to do.

If someone could give me some code to get me started, or point me in the direction of a good example, I would appreciate it.

Thank you.

Member Avatar for iamthwee

Ok, I have done some research, and found out the emulator uses DirectInput. So I believe I will need to hook the keystrokes, but I really have no idea how to do that.

I will need to hook the keystrokes, then, I will also need to inject keystrokes back into DirectInput.

I have read some articles on this, but they were all pretty intense. Is this a somewhat easy task, or is it pretty difficult to do.

If someone could give me some code to get me started, or point me in the direction of a good example, I would appreciate it.

Thank you.

Writing a global key hook program ain't simple. That's fo'sho.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.