Hey guys, i've been trying for the past few days different tutorials and possible solutions to my problem, and i've had no luck. I am trying to get my visual basic program to "press" a key on the keyboard while playing in a game. The code i have works just fine when i'm at the desktop, but when i go into the game it no longer works. The only thing i've gotten to work in the game is moving the mouse, which isn't all i need it to do. I can't get mouse clicks to work either.
So far i've tried using Sendkeys.send("desired key here") and keybd_event all of which work outside the game, but not while i'm playing it.
I use this code for the keybd_event:
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As UInteger, ByVal dwExtraInfo As IntPtr)
Public Declare Auto Function MapVirtualKey Lib "user32" (ByVal wCode As UInteger, ByVal wMapType As UInteger) As UInteger
And this for the mouse_event:
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal dwData As Integer, ByVal dwExtraInfo As IntPtr)
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4