关于用postmessage模拟键盘不弹起的问题?
程序代码:
Option Explicit Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Const WM_KEYDOWN = &H100 Private Const WM_KEYUP = &H101 Private Const WM_CHAR = &H102 Private Sub Form_Click() Dim a As Long a = PostMessage(Text1.hwnd, WM_KEYDOWN, vbKeyA, 0&) a = PostMessage(Text1.hwnd, WM_KEYUP, vbKeyA, 0&) End Sub
运行后,一直输入aaaa,为毛