SendMessage Me.Text1.hwnd, WM_KEYDOWN, vbKeyA, vbNullString
执行上面的语句为什么文本框Text1没用反应呢?
关于VB中用SendMessage模拟键盘点击问题
答案:2 悬赏:70 手机版
解决时间 2021-02-28 20:36
- 提问者网友:欲望失宠
- 2021-02-27 20:43
最佳答案
- 五星知识达人网友:逃夭
- 2021-02-27 22:17
用keybd_event吧,同样的作用。
参考:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Command1_Click()
Text1.SetFocus
keybd_event vbKeyA, 0, 0, 0
End Sub
vbKeyA是键码常数,对应字符“a”在MSDN里可查看全部。
参考:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Command1_Click()
Text1.SetFocus
keybd_event vbKeyA, 0, 0, 0
End Sub
vbKeyA是键码常数,对应字符“a”在MSDN里可查看全部。
全部回答
- 1楼网友:愁杀梦里人
- 2021-02-27 22:32
Private Const WM_SETFOCUS = &H7
Private Const WM_LBUTTONDOWN = &H201
SendMessage Me.Text1.hwnd, WM_SETFOCUS , vbKeyA, vbNullString
或
SendMessage Me.Text1.hwnd, WM_LBUTTONDOWN, vbKeyA, vbNullString
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯