Send.keys help...
ok so im trying to send key "o", as i have set this to the fire button in bc2, trying to make a Burst wizard... but sendkeys dose not work. any idears on how i can fix it?, i did try looking around on the web for a API alternative but i have no success.
Code:
Edit.....
so i got it working, Diffrernt code. but now it sends "c" non stop Tryed adding a sleep command but that dose not help.
:code
Code:
Code:
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vbkey As Long) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
SendKeys.Send("{o}")
SendKeys.Send("{o}")
SendKeys.Send("{o}")
Timer1.Enabled = False
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If GetAsyncKeyState(Keys.LButton) And CheckBox1.Checked = True Then
Timer1.Enabled = True
Else : Timer1.Enabled = False
End If
End Sub
Private Sub Tmrchecked_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tmrchecked.Tick
If GetAsyncKeyState(Keys.F1) Then
CheckBox1.Checked = True
Tmrchecked.Enabled = False
Tmrup.Enabled = True
End If
End Sub
Private Sub Tmrup_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tmrup.Tick
If GetAsyncKeyState(Keys.F1) And CheckBox1.Checked Then
CheckBox1.Checked = False
Tmrchecked.Enabled = True
Tmrup.Enabled = False
End If
End Sub
End Class
Edit.....
so i got it working, Diffrernt code. but now it sends "c" non stop Tryed adding a sleep command but that dose not help.
:code
Code:
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vbkey As Long) As Integer
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Private Const WM_CHAR = &H102
Dim windowHandle As Integer = FindWindow(vbNullString, "Untitled - NotePad") '/// assuming you have notepad open.
Dim controlHandle As Integer = FindWindowEx(windowHandle, 0, "Edit", vbNullString)
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
'/////////////////////////////////////////////// send key /////////////////////////////////////////////////////////////////
Private Sub tmrSendkey_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSendkey.Tick
SendMessage(controlHandle, WM_CHAR, Keys.C, 0) '<-- Works
End Sub
'//////////////////////////////////////////////// End timer /////////////////////////////////////////////////////////////////
'//////////////////////////////////////////////// Check Keypress /////////////////////////////////////////////////////////////////
Private Sub tmrkypress_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrkypress.Tick
If GetAsyncKeyState(Keys.U) Then
tmrSendkey.Enabled = True
Sleep(5000)
MsgBox("5")
tmrSendkey.Enabled = False
End If
If GetAsyncKeyState(Keys.W) Then
CheckBox1.Checked = True
If CheckBox1.Checked = True Then
tmrSendkey.Enabled = True
Sleep(2000)
End If
If CheckBox1.Checked And GetAsyncKeyState(Keys.Q) Then
CheckBox1.Checked = False
End If
End If
End Sub
'/////////////////////////////////////////////////// end timer ////////////////////////////////////////////////////////////
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SendMessage(controlHandle, WM_CHAR, Keys.C, 0) '<-- Works
End Sub
End Class


