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 展开
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 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询