vb的PostMessage问题求教
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Sub Command1_Click()
Dim a ,c As Long
Dim b, d As String
a = FindWindow(vbNullString, "逆战") //窗口名可以更改为其他窗口名
c = MapVirtualKey(vbKeyG, 0)
MsgBox a
MsgBox c
b = &H0 & c & &H1
PostMessage a, WM_KEYDOWN, vbKeyG, b
d = &H0 & c & &H1
PostMessage a, WM_KEup, vbKeyG, d
End Sub
我的问题是用FindWindowEx,查不出窗口的子窗口或者操作控件,但是在游戏聊天中可以实现自动输入,另外PostMessage的lParam参数设置有问题吗?我这样设置也可以模拟,设为0&也可以。另外如何查找此窗口的子窗口或者操作控件?求高手答疑