&H 十六进制代码代表哪些键?
编辑:我发现一篇文章准确列出了我需要的内容:http://msdn.microsoft.com/en-us/library/ms646309(v=vs.85).aspx
感谢您的帮助!
原文:
我想知道 &H
十六进制代码代表什么键盘键?
例如,我发现 &H1
是 ALT 键,&H2
是 CONTROL 键,&H3
是同时按住 ALT 和 CONTROL 键。 &H10
是 Shift 键,它出现了。我这样问是因为我需要找出我正在设计的程序需要注册热键。用户可以选择隐藏它,我想确保他们可以通过按热键再次显示它,但我需要弄清楚十六进制键是什么才能使用我找到的代码。
这是我找到的代码的一部分:
Public Const MOD_ALT As Integer = &H1 'Alt key
Public Const WM_HOTKEY As Integer = &H312
<DllImport("User32.dll")> _
Public Shared Function RegisterHotKey(ByVal hwnd As IntPtr, _
ByVal id As Integer, ByVal fsModifiers As Integer, _
ByVal vk As Integer) As Integer
End Function
<DllImport("User32.dll")> _
Public Shared Function UnregisterHotKey(ByVal hwnd As IntPtr, _
ByVal id As Integer) As Integer
End Function
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
Dim id As IntPtr = m.WParam
Select Case (id.ToString)
Case "100"
MessageBox.Show("You pressed ALT+D key combination")
Case "200"
MessageBox.Show("You pressed ALT+C key combination")
End Select
End If
MyBase.WndProc(m)
End Sub
这会在加载表单时注册热键:
RegisterHotKey(Me.Handle, 100, &H3, Keys.D)
RegisterHotKey(Me.Handle, 200, Keys.Alt, Keys.C)
This 是我在 MSDN 论坛上查看的主题 - 我从特色答案中复制了代码。
我已经在 Google 上进行了彻底的搜索,并且在 StackOverflow 上进行了搜索,但我找不到任何东西。
某处是否有十六进制代码列表,或说明或其他内容?
谢谢!
EDIT: I found an article that lists exactly what I needed: http://msdn.microsoft.com/en-us/library/ms646309(v=vs.85).aspx
Thanks for your help!
Original:
I'm wondering what keyboard keys are represented by the &H
hex codes?
For example, I've found that &H1
is the ALT key, &H2
is the CONTROL key, and &H3
is both the ALT and CONTROL keys together. &H10
is the Shift key, it appears. I'm asking because I need to find out for a program I'm designing that needs to register a hotkey. The user has the option to hide it, and I want to make sure that they can show it again by pressing a hotkey, but I need to figure out what the hex keys are to use the code that I found.
Here's part of the code I found:
Public Const MOD_ALT As Integer = &H1 'Alt key
Public Const WM_HOTKEY As Integer = &H312
<DllImport("User32.dll")> _
Public Shared Function RegisterHotKey(ByVal hwnd As IntPtr, _
ByVal id As Integer, ByVal fsModifiers As Integer, _
ByVal vk As Integer) As Integer
End Function
<DllImport("User32.dll")> _
Public Shared Function UnregisterHotKey(ByVal hwnd As IntPtr, _
ByVal id As Integer) As Integer
End Function
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
Dim id As IntPtr = m.WParam
Select Case (id.ToString)
Case "100"
MessageBox.Show("You pressed ALT+D key combination")
Case "200"
MessageBox.Show("You pressed ALT+C key combination")
End Select
End If
MyBase.WndProc(m)
End Sub
And this registers the hotkeys when the form loads:
RegisterHotKey(Me.Handle, 100, &H3, Keys.D)
RegisterHotKey(Me.Handle, 200, Keys.Alt, Keys.C)
This is the thread I was looking at on the MSDN forums -- I copied the code from the featured answer.
I've done a thorough Google search and I've searched here on StackOverflow, and I can't find anything.
Is there maybe a list of the hex codes somewhere, or instructions or something?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您链接的 MSDN 线程中,有一个指向 虚拟按键代码。
此外,请检查系统。 Windows.Forms.Keys 枚举。
请注意, RegisterHotKey 方法采用以下参数:hWnd、id、fsModifiers 和 vk。 VK 是放置 VirtualKey 代码的地方。关于 fsModifiers:
In that MSDN thread you've linked there is a link to Virtual Key Codes.
In addition, check the System.Windows.Forms.Keys enumeration.
Notice that the RegisterHotKey method takes the following arguments: hWnd, id, fsModifiers and vk. VK is where you place the VirtualKey code. Regarding fsModifiers: