keybd_event,PostMessage,SendMessage 都不能发送CTRL组合键 VB
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
完成一次按键盘操作分为两个动作,按下——弹起,你再看下你的代码