Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9105897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:12:39+00:00 2026-06-17T02:12:39+00:00

Hello I am trying to use RegisterHeyKeys in VB.NET however I got it to

  • 0

Hello I am trying to use RegisterHeyKeys in VB.NET however I got it to work with 2 hotkeys I tried just adding in the third and it’s giving a too many arguments. This is probably something really simple and I’m also a nub so go easy. lol. Any help would be greatly appreciated.

Here is the code so far:

Public Const MOD_CONTROL As Integer = &H11
Public Const MOD_SHIFT As Integer = &H10
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

Private Sub Form1_Load(ByVal sender As System.Object, _
                    ByVal e As System.EventArgs) Handles MyBase.Load
    RegisterHotKey(Me.Handle, 100, MOD_CONTROL, MOD_SHIFT, Keys.D2)
    RegisterHotKey(Me.Handle, 200, MOD_CONTROL, MOD_SHIFT, Keys.D3)
    RegisterHotKey(Me.Handle, 300, MOD_CONTROL, MOD_SHIFT, Keys.D4)
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:12:40+00:00Added an answer on June 17, 2026 at 2:12 am

    The problem as I see it is you have added two modifiers MOD_CONTROL and MOD_SHIFT and seperated them with a comma saying that you have five parameters to the function even though it only takes four. Try Oring together your Modifers like this. You also should verify your modifier keys with the Documentation they appear to not be correct.

    Private Sub Form1_Load(ByVal sender As System.Object, _
                        ByVal e As System.EventArgs) Handles MyBase.Load
        RegisterHotKey(Me.Handle, 100, MOD_CONTROL Or MOD_SHIFT, Keys.D2)
        RegisterHotKey(Me.Handle, 200, MOD_CONTROL Or MOD_SHIFT, Keys.D3)
        RegisterHotKey(Me.Handle, 300, MOD_CONTROL Or MOD_SHIFT, Keys.D4)
    End Sub
    

    From the documentation it states(emphasis mine):

    fsModifiers [in]
    Type: UINT

    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.

       Value                        Meaning
    
    MOD_ALT 0x0001         Either ALT key must be held down.
    
    MOD_CONTROL 0x0002     Either CTRL key must be held down.
    
    MOD_NOREPEAT 0x4000   Changes the hotkey behavior so that the keyboard auto-repeat does not yield multiple hotkey notifications. 
                          Windows Vista and Windows XP/2000:  This flag is not supported.
    MOD_SHIFT 0x0004      Either SHIFT key must be held down.
    
    MOD_WIN 0x0008        Either WINDOWS key was held down. These keys are labeled with the Windows logo. Keyboard shortcuts
                          that involve the WINDOWS key are reserved for use by the operating system
    

    Here is a Working example of your program.

    Public Const MOD_CONTROL As Integer = &H2
    Public Const MOD_SHIFT As Integer = &H4
    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
    
    Private Sub Form1_Load(ByVal sender As System.Object, _
                        ByVal e As System.EventArgs) Handles MyBase.Load
        RegisterHotKey(Me.Handle, 100, MOD_CONTROL Or MOD_SHIFT, Keys.D2)
        RegisterHotKey(Me.Handle, 200, MOD_CONTROL Or MOD_SHIFT, Keys.D3)
        RegisterHotKey(Me.Handle, 300, MOD_CONTROL Or MOD_SHIFT, Keys.D4)
    End Sub
    
    Protected Overrides Sub DefWndProc(ByRef m As System.Windows.Forms.Message)
        MyBase.DefWndProc(m)
        If m.Msg = WM_HOTKEY Then
            Select Case CType(m.WParam, Integer)
                Case 100
                    NotifyIcon1.Text = "Hello"
                    NotifyIcon1.ShowBalloonTip(2000, "", NotifyIcon1.Text, ToolTipIcon.Info)
                Case 200
                    NotifyIcon1.Text = "World"
                    NotifyIcon1.ShowBalloonTip(2000, "", NotifyIcon1.Text, ToolTipIcon.Info)
                Case 300
                    NotifyIcon1.Visible = False
                    If Not Visible Then Visible = True
            End Select
        End If
    End Sub
    
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.Hide()
        NotifyIcon1.Icon = Me.Icon
        NotifyIcon1.Visible = True
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I've got a bit of a problem. I'm trying to use WMI to
Hello: Just a quick question.. I hope. I am trying to use this program
Hello I am trying to use regular expressions in a java program. I would
Hello I am trying to use the SimpleDateFormatter to parse the date Wed, 30
Hello I am trying to use a NSPopUpButtonCell inside an NSTableView. Basically when you
Im trying to use the string::find method to determine if the string hello (with
Hello Stackoverflowers, I'm trying to use a button, that first goes to another excel
Hello there Stack Exchange, I'm trying to use a Raspberry Pi to make a
I'm trying to use Qt Creator, but it is not working. My hello world
I am trying to use the webpy server and it works for the hello

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.