It might just be because I am too tired to figure out what I am doing wrong. I am attempting to use the SendMessage API to simulate keystrokes. Any suggestions? I will sleep on this and check this thread tomorrow.
Code:
'Declaration
Public Declare Auto Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
'Constants
Public Const WM_KEYDOWN As Integer = &H100
Public Const WM_KEYUP As Integer = &H101
Public Const WM_CHAR As Integer = &H102
'TypeKeys Function
'Why does this not work? Freaking tired.
Public Sub TypeKeys(ByVal hWND As IntPtr, ByVal sText As String, ByVal iWait As Integer)
Try
For i = 1 To sText.Length
Call SendMessage(hWND, WM_KEYDOWN, Asc(Mid(sText, i, 1)), 0)
Call SendMessage(hWND, WM_CHAR, Asc(Mid(sText, i, 1)), 0)
Call SendMessage(hWND, WM_KEYUP, Asc(Mid(sText, i, 1)), 0)
Next i
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Edit:
I currently think as of this moment:
Call SendMessage(hWND, WM_KEYDOWN, Asc(Mid(sText, i, 1)), 0)
>>Asc(Mid(sText, i, 1))<<
Is the problem. I am just too tired to figure out how to convert that value into an acceptable parameter in order to execute the SendMessage method.
Also:
It might also be the API declaration itself that is the problem.
Another Also:
I think I will have to read up on this method.