Shoutbox

VB Keypress help - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: VB Keypress help (/showthread.php?tid=58685)

VB Keypress help by DJeX on 04-23-2006 at 11:10 PM

Ok I made a program that will double press W when the Up arrow was pressed once. I made it for a game. I tested it in Notepad and It works great. But when I go to use it in the game it does not work at all. Could any one explain to me why it don't work?

Heres my program:

code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyUp) Then
SendKeys "{W}"
SendKeys "{W}"
End If
End Sub

RE: VB Keypress help by Adeptus on 04-23-2006 at 11:53 PM

Your game probably uses the DirectInput API.  That would be my default expectation for most modern 3D games.

http://msdn.microsoft.com/library/default.asp?url...nput/html/diov.asp

quote:
Apart from providing services for devices not supported by the Microsoft Win32 API, Microsoft DirectInput gives faster access to input data by communicating directly with the hardware drivers rather than relying on Microsoft Windows messages.
SendKeys() stuffs the Windows message loop, which sits at a higher level than DirectInput, so they are never seen by your game.

Unfortunately, I don't know off the top of my head how you would go about simulating keys so they are recognized by DirectInput. 
RE: VB Keypress help by matty on 04-24-2006 at 12:19 AM

http://allapi.net/apilist/keyb_event.shtml


RE: VB Keypress help by DJeX on 04-24-2006 at 01:31 AM

quote:
Originally posted by Adeptus
Your game probably uses the DirectInput API.  That would be my default expectation for most modern 3D games.

http://msdn.microsoft.com/library/default.asp?url...nput/html/diov.asp


SendKeys() stuffs the Windows message loop, which sits at a higher level than DirectInput, so they are never seen by your game.

Unfortunately, I don't know off the top of my head how you would go about simulating keys so they are recognized by DirectInput.

Humm ok. Well I found everything I need to know about DirectInput except how to send a keypress to a DirectX program (the game).

quote:
Originally posted by Matty
http://allapi.net/apilist/keyb_event.shtml

Humm but wouldn't that be the same as SendKeys() ? I don't see how that uses DirectInput in any way.

EDIT: I tryed that Matty and still no luck.

RE: VB Keypress help by rav0 on 04-24-2006 at 01:36 AM

I don't thing that it's the same as SendKeys, just from looking. Try it :).

Since DirectInput is meant to be as fast as possible, and uses the device drivers, it might need to be done at a driver level. You could also try memory hacking DirectX. Both these options make it a lot more complicated though.