vb 给其他程序的文本框发送字符 似乎是sendmassege
2个回答
展开全部
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
'将一个字符串通过PostMessage传送出去
Public Sub subPostString(ahwnd,ByVal strP As String)
Dim intP As Integer
Dim intK As Integer
Dim lngAsc As Long
Dim lngP As Long
Dim strT As String
On Error GoTo errSub
' Debug.Print strP
For intP = 0 To Len(strP) - 1
strT = Mid(strP, intP + 1, 1)
If Asc(strT) <= 0 Then
lngAsc = AscW(StrConv(strT, 128))
If lngAsc < 0 Then
lngAsc = lngAsc + 65536 '2^16
End If
Else
lngAsc = Asc(strT)
End If
lngP = SendMessage(ahwnd, WM_CHAR, lngAsc, 0)
Next intP
Exit Sub
errSub:
End Sub
Private Sub Command1_Click()
subPostString (句柄 ,账号 )
End Sub
'将一个字符串通过PostMessage传送出去
Public Sub subPostString(ahwnd,ByVal strP As String)
Dim intP As Integer
Dim intK As Integer
Dim lngAsc As Long
Dim lngP As Long
Dim strT As String
On Error GoTo errSub
' Debug.Print strP
For intP = 0 To Len(strP) - 1
strT = Mid(strP, intP + 1, 1)
If Asc(strT) <= 0 Then
lngAsc = AscW(StrConv(strT, 128))
If lngAsc < 0 Then
lngAsc = lngAsc + 65536 '2^16
End If
Else
lngAsc = Asc(strT)
End If
lngP = SendMessage(ahwnd, WM_CHAR, lngAsc, 0)
Next intP
Exit Sub
errSub:
End Sub
Private Sub Command1_Click()
subPostString (句柄 ,账号 )
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询