VB.NET新手求助 在WIN7 64位系统下 向其它窗口发送组合键中[ALT]不起作用 求解!!!!
PublicClassForm1PrivateDeclareAutoFunctionPostMessageLib"user32"(ByValhwndAsInteger,B...
Public Class Form1
Private Declare Auto Function PostMessage Lib "user32 " (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Const WM_SYSKEYDOWN = &H104 '按下系统功能键
Private Const WM_SYSKEYUP = &H105 '弹起系统功能键
Private Const WM_KEYDOWN = &H100 '普通键按下
Private Const WM_KEYUP = &H101 '普通键抬起
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Hwnd=012345678
PostMessage(Hwnd, WM_SYSKEYDOWN, 18, 0) '按下ALT键
PostMessage(Hwnd, WM_KEYDOWN, 67, 0) '按下C键
PostMessage(Hwnd, WM_KEYUP, 67, 0) '弹起C键
PostMessage(Hwnd, WM_SYSKEYUP, 18, 0) '弹起ALT键
End Sub
End Clas
句柄Hwnd是通过SPy++直接获取的.单独执行普通按键的时候没有问题 一旦变成组合键后 ALT始终没有被执行,求高手指点 展开
Private Declare Auto Function PostMessage Lib "user32 " (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Const WM_SYSKEYDOWN = &H104 '按下系统功能键
Private Const WM_SYSKEYUP = &H105 '弹起系统功能键
Private Const WM_KEYDOWN = &H100 '普通键按下
Private Const WM_KEYUP = &H101 '普通键抬起
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Hwnd=012345678
PostMessage(Hwnd, WM_SYSKEYDOWN, 18, 0) '按下ALT键
PostMessage(Hwnd, WM_KEYDOWN, 67, 0) '按下C键
PostMessage(Hwnd, WM_KEYUP, 67, 0) '弹起C键
PostMessage(Hwnd, WM_SYSKEYUP, 18, 0) '弹起ALT键
End Sub
End Clas
句柄Hwnd是通过SPy++直接获取的.单独执行普通按键的时候没有问题 一旦变成组合键后 ALT始终没有被执行,求高手指点 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询