如何用VB注册一个全局热键? 20
我想做一个没有“广告”的鼠标点击器,让那些广告都去见佛祖。。。上帝也行..我玩魔兽争霸的,有时候给队友钱的数量比较大,要点好几十次鼠标...我想做一个鼠标点击器、按下F3...
我想做一个没有“广告”的鼠标点击器,让那些广告都去见佛祖。。。上帝也行..
我玩魔兽争霸的,有时候给队友钱的数量比较大,要点好几十次鼠标...
我想做一个鼠标点击器、按下F3开启关闭鼠标点击。
目前已经做好了,只差如何注册一个热键能在魔兽争霸里用有效的。
懂得帮下忙、、3Q 展开
我玩魔兽争霸的,有时候给队友钱的数量比较大,要点好几十次鼠标...
我想做一个鼠标点击器、按下F3开启关闭鼠标点击。
目前已经做好了,只差如何注册一个热键能在魔兽争霸里用有效的。
懂得帮下忙、、3Q 展开
4个回答
展开全部
'类名 clsRegHotKey
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsRegHotKey"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type Msg
hwnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Const PM_REMOVE = &H1
Private Const WM_HOTKEY = &H312
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
'************************************************************
Enum ShiftKeys
AltKey = &H1
CtrlKey = &H2
ShiftKey = &H4
End Enum
Private bCancel As Boolean
Private clshwnd
Public Event HotKeysDown()
'注册热键,等候按键消息
Sub RegeditHotKeys(ByVal hwnd As Long, ByVal ShiftKey As ShiftKeys, ByVal ComKey As KeyCodeConstants)
RegisterHotKey hwnd, &HBFFF&, ShiftKey, ComKey '注册热键
clshwnd = hwnd
bCancel = False
Dim Message As Msg
Do While Not bCancel
WaitMessage '等候按键消息
'判断消息
If PeekMessage(Message, hwnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
RaiseEvent HotKeysDown '引发事件
End If
DoEvents
Loop
End Sub
'取消热键注册
Sub UnRegeditHotKeys()
bCancel = True
UnregisterHotKey clshwnd, &HBFFF&
End Sub
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsRegHotKey"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type Msg
hwnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Const PM_REMOVE = &H1
Private Const WM_HOTKEY = &H312
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
'************************************************************
Enum ShiftKeys
AltKey = &H1
CtrlKey = &H2
ShiftKey = &H4
End Enum
Private bCancel As Boolean
Private clshwnd
Public Event HotKeysDown()
'注册热键,等候按键消息
Sub RegeditHotKeys(ByVal hwnd As Long, ByVal ShiftKey As ShiftKeys, ByVal ComKey As KeyCodeConstants)
RegisterHotKey hwnd, &HBFFF&, ShiftKey, ComKey '注册热键
clshwnd = hwnd
bCancel = False
Dim Message As Msg
Do While Not bCancel
WaitMessage '等候按键消息
'判断消息
If PeekMessage(Message, hwnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
RaiseEvent HotKeysDown '引发事件
End If
DoEvents
Loop
End Sub
'取消热键注册
Sub UnRegeditHotKeys()
bCancel = True
UnregisterHotKey clshwnd, &HBFFF&
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看看魔兽争霸里有热键设定的功能没有。如果有的话,直接加。没有的话,没办法。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
魔兽里应该有热键设置
更多追问追答
追问
魔兽的热键无法兼容我写的exe程序好不好?
追答
那可就有难度了,你得知道魔兽热键的接口
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
牛人
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询