vb怎样用sendmessage WM_KEYDOWN 发送特殊按键(发送到桌面)??
vb怎样用sendmessageWM_KEYDOWN发送特殊按键??可以发送到任何已经在系统中运行的程序。不过要发送的按键非常特殊,keycode为170到180,(也就...
vb怎样用sendmessage WM_KEYDOWN 发送特殊按键?? 可以发送到任何已经在系统中运行的程序。 不过要发送的按键非常特殊,keycode为170到180,(也就是多媒体键盘上的特殊键,比如音量增加、减少,停止,播放等等),该如何实现? 又或者,用vb编程,怎样可以实现多媒体键盘上的音量加/减,等等功能? 不一定是发送模拟键盘按键的方式,也可以是其它方式,只要可以实现就行了。 (我的键盘上本身没有多媒体按键,不过却有两个根本没有用的特殊按键,所以,想把那两个按键改为其它作用,比如控制音量。那两个按键的keycode分别为255和124.)
展开
展开全部
虽然不是用 sendmessage 但是解决了你的问题 Option Explicit Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Const KEYEVENTF_KEYUP = &H2 Private Sub Command1_Click() '静音 'keybd_event &HAD, MapVirtualKey(&HAD, 0), 0, 0 'Sleep 100 'keybd_event &HAD, MapVirtualKey(&HAD, 0), KEYEVENTF_KEYUP, 0 '音量减小 'keybd_event &HAE, MapVirtualKey(&HAE, 0), 0, 0 'Sleep 100 'keybd_event &HAE, MapVirtualKey(&HAE, 0), KEYEVENTF_KEYUP, 0 '音量增大 keybd_event &HAF, MapVirtualKey(&HAF, 0), 0, 0 Sleep 100 keybd_event &HAF, MapVirtualKey(&HAF, 0), KEYEVENTF_KEYUP, 0 End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询