&H 十六进制代码代表哪些键?

发布于 2024-10-31 19:44:30 字数 1912 浏览 1 评论 0原文

编辑:我发现一篇文章准确列出了我需要的内容: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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲墙角沉默 2024-11-07 19:44:30

在您链接的 MSDN 线程中,有一个指向 虚拟按键代码
此外,请检查系统。 Windows.Forms.Keys 枚举。

请注意, RegisterHotKey 方法采用以下参数:hWnd、id、fsModifiers 和 vk。 VK 是放置 VirtualKey 代码的地方。关于 fsModifiers:

必须按下的键
与指定的键的组合
uVirtKey 参数以便
生成 WM_HOTKEY 消息。这
fsModifiers 参数可以是
以下值的组合:
MOD_ALT(0x0001),MOD_CONTROL
(0x0002), MOD_NOREPEAT (0x4000),
MOD_SHIFT(0x0004),MOD_WIN(0x0008)。

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:

The keys that must be pressed in
combination with the key specified by
the uVirtKey parameter in order to
generate the WM_HOTKEY message. The
fsModifiers parameter can be a
combination of the following values:
MOD_ALT (0x0001), MOD_CONTROL
(0x0002), MOD_NOREPEAT (0x4000),
MOD_SHIFT (0x0004), MOD_WIN (0x0008).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文