My application never has the focus but I needed to assign hotkey functions.

While playing in a Direct-X Game I need my app to catch my 4 different hotkeys being pressed and to perform a function.

I tried the System Wide Hotkey API stuff but thats no good for Dx games, so I got the Direct X Method of assigning keys to functions but it won't work either.

I've tried this code outside of the game with MsgBoxs and it works great, but when I try in the game it doesn't......

I know people make game cheats that use hotkeys, this works the same way but this is a message program not a cheat.



Please Help me, Heres my code:

In the Form:
Dim dx7 As New DirectX7
Dim state As DIKEYBOARDSTATE
Dim iKey As Integer
Dim dinput As DirectInput
Dim keys(255) As String
Dim dev As DirectInputDevice

Private Sub Form_Load()
tmrKey.Interval = 50
Set dinput = dx7.DirectInputCreate()
Set dev = dinput.CreateDevice("GUID_SysKeyboard")
dev.SetCommonDataFormat DIFORMAT_KEYBOARD
dev.Acquire
End Sub

Private Sub tmrKey_Timer()
dev.GetDeviceStateKeyboard state
For iKey = 0 To 255
If state.Key(iKey) <> 0 Then
End If
Next

If state.Key(67) <> 0 Then mtdpxf.Display -1, (Actions.F9Value.text)
If state.Key(68) <> 0 Then mtdpxf.Display -1, (Actions.F10Value.text)
If state.Key(87) <> 0 Then mtdpxf.Display -1, (Actions.F11Value.text)
If state.Key(88) <> 0 Then mtdpxf.Display -1, (Actions.F12Value.text)
DoEvents

End Sub