Simulate a Key Press
Alright. Before you spam me with "Use SendKeys.Send()", please understand, I have already tried it and it does not fill my needs.
So I'm playing a game (Allods) and I'm trying to use my xb360 controller with it. Problem is, the game doesn't want to take the keys from the controller. However, if i press a key on the keyboard, and then try the controller, it works just fine.
So my solution was so make a program that spams the unused J key so i can openly use my controller. This is the code i tried, which does it's job successfully for spamming the J key, but does not work in game. It'll work in chat and such, but still does not open up controller functionality.
Source Code:
Therefor, forum, i'm asking if any of you know an alternate way to "spam" the j key besides sendkeys.send.
Much Appreciation,
Gwen Travolta
So I'm playing a game (Allods) and I'm trying to use my xb360 controller with it. Problem is, the game doesn't want to take the keys from the controller. However, if i press a key on the keyboard, and then try the controller, it works just fine.
So my solution was so make a program that spams the unused J key so i can openly use my controller. This is the code i tried, which does it's job successfully for spamming the J key, but does not work in game. It'll work in chat and such, but still does not open up controller functionality.
Source Code:
Code:
Public Class Form1
Public Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Long) As Integer
Dim already As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
Timer2.Enabled = False
Dim start As DateTime = Now.AddMilliseconds(500)
Do
Application.DoEvents()
Loop Until Now > start
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim hotkey1 As Boolean = GetAsyncKeyState(Keys.F7)
Dim hotkey2 As Boolean = GetAsyncKeyState(Keys.F8)
If hotkey1 = True And already = 0 Then
already = 1
If Timer2.Enabled = True Then
Timer2.Enabled = False
ElseIf Timer2.Enabled = False Then
Timer2.Enabled = True
End If
ElseIf hotkey1 = False And already = 1 Then
already = 0
End If
If hotkey2 = True Then
Application.Exit()
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
SendKeys.Send("j")
End Sub
End Class
Much Appreciation,
Gwen Travolta