I think the problem is that you aren't changing focus to the game window. So your program is sending the spaces to the vb.net program you wrote instead of to the game.
You'll need to do something to change focus to the game window. Check out this question as it has the information you need about using the Win32 API to change which window has focus.
EDIT:
Per your request, here's how you'd work it into your code. Please note that all the information you needed to write this code was in the link I provided. Please read the sources that are provided when someone answers your questions in the future. I left copious comments to help you understand what each line does.
Imports System.Runtime.InteropServices 'Needed to import the Win32 API functions
Public Class Form1
'Make sure the programTitle const is set to the _EXACT_ title of the
'program you are trying to set focus to or this won't work.
Private Const programTitle As String = "Title of program"
Private zero As IntPtr = 0 'Required for FindWindowByCaption first parameter
'Import the SetForegroundWindow Function
<DllImport("user32.dll")> _
Private Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
'Import the FindWindowByCaption Function, called as a parameter to SetForegroundWindow
<DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowByCaption( _
ByVal zero As IntPtr, _
ByVal lpWindowName As String) As IntPtr
End Function
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'Call SetForegroundWindow whenever you want to send keys to the specified window.
SetForegroundWindow(FindWindowByCaption(zero, programTitle))
SendKeys.Send(TextBox1.Text) 'Sends the message you typed in the textbox1
SendKeys.Send(" ") 'presses the SPACE key from your keyboard
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Interval = TextBox2.Text
Timer1.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Interval = TextBox2.Text
Timer1.Enabled = False
End Sub
End Class
Please note: I tested this code and verified that it can set window focus and send the space key and any other key as it should. If this code doesn't work for you, then you have the wrong name in the programTitle
constant. For example, if I wanted to set focus to this notepad window:

and if I set programTitle
to "Notepad"
trying to get it to send the keys to the notepad window, this wont work. That's because "notepad" is only a part of the title. To get it to work, programTitle
should be set to "Untitled - Notepad"
.