keybd_event,PostMessage,SendMessage 都不能发送CTRL组合键 VB

PrivateSubCommand1_Click()DimhwndAsLonghwnd=131850BringWindowToTop(hwnd)SetForeground... Private Sub Command1_Click()
Dim hwnd As Long
hwnd = 131850
BringWindowToTop (hwnd)
SetForegroundWindow (hwnd)

keybd_event 17, 0, 0, 0 ' press =
keybd_event 34, 0, 0, 0 ' press =
keybd_event 34, 0, KEYEVENTF_KEYUP, 0 ' release =
keybd_event 17, 0, KEYEVENTF_KEYUP, 0 ' release =
End Sub

Private Sub Command2_Click()
Dim hwnd As Long
hwnd = 131850
BringWindowToTop (hwnd)
SetForegroundWindow (hwnd)

PostMessage hwnd, WM_KEYDOWN, VK_CONTROL, &H1D0001
PostMessage hwnd, WM_KEYDOWN, VK_NEXT, 0
PostMessage hwnd, WM_KEYUP, VK_NEXT, 0
PostMessage hwnd, WM_KEYUP, VK_CONTROL, &HC01D0001 '释放Ctrl键
End Sub

Private Sub Command3_Click()
Dim hwnd As Long
hwnd = 131850
BringWindowToTop (hwnd)
SetForegroundWindow (hwnd)

SendMessage hwnd, WM_KEYDOWN, VK_CONTROL, 0
SendMessage hwnd, WM_KEYDOWN, VK_NEXT, 0
SendMessage hwnd, WM_KEYUP, VK_NEXT, 0
SendMessage hwnd, WM_KEYUP, VK_CONTROL, 0
End Sub
展开
 我来答
闪星2
推荐于2016-04-02 · TA获得超过3007个赞
知道大有可为答主
回答量:2898
采纳率:58%
帮助的人:1052万
展开全部
完成一次按键盘操作分为两个动作,按下——弹起,你再看下你的代码
更多追问追答
追问
KEYDOWN  KEYUP
追答

这是一个用keybd_event 发送组合键Ctrl+Z的小实例

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式