vb SendMessage 如何模拟键盘填写?

2024-12-20 07:54:59
推荐回答(1个)
回答1:

Private Const WM_SETTEXT = &HC
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub Command1_Click()
Dim w As Long
w = SendMessage(Text1.hwnd, WM_SETTEXT, ByVal 0&, ByVal "王小明")
If w = 0 Then
MsgBox "失败"
Else
MsgBox "成功"
End If
End Sub