VB设置多个全局热键,帮忙修改
http://zhidao.baidu.com/link?url=vQVutNGs0uZ4GsTIbf88H3_IPE8EIgS1wy7NUgZlggjphjUW3w29...
http://zhidao.baidu.com/link?url=vQVutNGs0uZ4GsTIbf88H3_IPE8EIgS1wy7NUgZlggjphjUW3w29hEZpTSnn11_CNMV2R3moW-DlKd16JK-vza
利用这个上面的代码,我是新手,真心看不懂改不了 展开
利用这个上面的代码,我是新手,真心看不懂改不了 展开
3个回答
2014-03-25
展开全部
'主窗体代码如下:
Option Explicit
'程序启动时注册功能热键F12
Private Sub Form_Load()
preWinProc = GetWindowLong(Me.hWnd, GWL_WNDPROC)
SetWindowLong Me.hWnd, GWL_WNDPROC, AddressOf WndProc
RegisterHotKey Me.hWnd, 1, MOD_ALT, vbKeyF12 '按下ATL+F12
RegisterHotKey Me.hWnd, 2, MOD_CONTROL, vbKeyF12 '按下CTRL+F12
RegisterHotKey Me.hWnd, 3, MOD_SHIFT, vbKeyF12 '按下SHIFT+F12
RegisterHotKey Me.hWnd, 4, MOD_WIN, vbKeyF12 '按下WINDOWS键+F12
RegisterHotKey Me.hWnd, 5, 0, vbKeyF12 ’直接按F12
RegisterHotKey Me.hWnd, 6, MOD_ALT OR MOD_CONTROL, vbKeyF12 '按下ALT+CTRL+F12键
End Sub
'当程序被关闭时,取消已经注册的热键
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong Me.hWnd, GWL_WNDPROC, preWinProc
UnregisterHotKey Me.hWnd, 1 '取消系统级热键,释放资源
UnregisterHotKey Me.hWnd, 2 '取消系统级热键,释放资源
UnregisterHotKey Me.hWnd, 3 '取消系统级热键,释放资源
UnregisterHotKey Me.hWnd, 4 '取消系统级热键,释放资源
UnregisterHotKey Me.hWnd, 5 '取消系统级热键,释放资源
UnregisterHotKey Me.hWnd, 6 '取消系统级热键,释放资源
End Sub
'添加一个标准模块,代码如下
Option Explicit
'在窗口结构中为指定的窗口设置信息
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
'从指定窗口的结构中取得信息
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
'运行指定的进程
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'向系统注册一个指定的热键
Public Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal ID As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
'取消热键并释放占用的资源
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal ID As Long) As Long
'上述五个API函数是注册系统级热键所必需的,具体实现过程如后文所示
'常数
Public Const MOD_ALT = &H1
Public Const MOD_CONTROL = &H2
Public Const MOD_SHIFT = &H4
Public Const MOD_WIN = &H8Public Const WM_HOTKEY = &H312
Public Const GWL_WNDPROC = (-4)
'定义系统的热键,原中断标示,被隐藏的项目句柄
Public preWinProc As Long, MyhWnd As Long, uVirtKey As Long
'热键拦截过程
Public Function WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_HOTKEY Then '如果拦截到热键标志常数
HotkeyPressed wParam '执行隐藏鼠标所指项目
End If
'如果不是热键,或者不是我们设置的热键,交还控制权给系统,继续监测热键
WndProc = CallWindowProc(preWinProc, hWnd, Msg, wParam, lParam)
End Function
'最关键的项目隐藏过程
Public Sub HotkeyPressed(ByVal id As Long)
MsgBox "按下了第" & id & "个热键"
End Sub
展开全部
80分不错.
还有楼上的太弱了.
百度知道也不敢点.还来干什么.
追问
哈哈
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
窗体热键需要设置:
keyPreviey = T....
--------------------------
谁敢随便去你的连接?
keyPreviey = T....
--------------------------
谁敢随便去你的连接?
更多追问追答
追问
额这个不是百度知道的连接么
不过我自己已经解决了。你叫我个哥哥,我就把分给你,么么哒
追答
我是50后,是你的爷爷!好心帮你,你竟然.........
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询