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 6839621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:44:27+00:00 2026-05-26T23:44:27+00:00

I have been working on a C# WinForms application that registers several hot keys

  • 0

I have been working on a C# WinForms application that registers several hot keys using the well-discussed GlobalAddAtom and RegisterHotKey PInvoke methods. The program starts in minimized mode and runs in the system tray. Each time one of the hot key messages are received, the program captures the data about which key was pressed and hands it off to another object for processing. This has worked relatively well for a while now, but every now and then there is some strange behavior. Things like the same message processed multiple times or some messages missed altogether.

After adding some extensive logging I discovered that if the user held down the hot key combination (Win + C for example) for a little longer than normal, or just plain held it down, then new hot key messages were being received in the message loop before the previous message had finished processing.

Now, the way I see it, a message is received on the UI thread (even though it’s hidden) and processed by a blocking call to an instance of a different class. If that’s true, then how can another message come into the same function that is currently processing the first message? This is where my lack of Win32 understanding makes me scratch my head.

It seems to me that the second message is received on a different thread. But then if that’s true then what instance of my processing class is it calling into?

Any help figuring this out will be greatly appreciated!

Here’s a simplified example. This code…

protected override void WndProc(ref Message m)
{
    switch (m.Msg)
    {
        case MultipleClipboardsDialog.WM_HOTKEY:
            HotKey hotKey = new HotKey(m.LParam);
            Log.Debug("About to process hot key " + hotKey.ToString());
            this.Processor.ProcessHotKey(hotKey);
            Log.Debug("Finished processing hot key " + hotKey.ToString());
            break;

        default:
            base.WndProc(ref m);
            break;
    }
}

…produces output like this.

About to process hot key Win + C
About to process hot key Win + C
About to process hot key Win + C
Finished processing hot key Win + C
  • 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-05-26T23:44:27+00:00Added an answer on May 26, 2026 at 11:44 pm

    The message you are looking for is only generated when the button is released. The way messages are setup in Windows are such that up to three messages are generated for every key-press. Fire up Spy++, and take a look at Notepad. You should be able to see the messages that are generated during normal Windows operations.

    You end up with KeyDown, KeyPressed, and KeyUp messages (or something the equivalent thereof). You’re probably intercepting one or two of those messages (normal operations, and you code around that). You might want to look at Ascii and Virtual Keys as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winforms application i have been working on that runs multiple tests
I have a Winforms application which is working fine.. using a BackgroundWorkerThread to manage
I have a RichTextBox in .NET WinForms. I have been hooking up hot keys
I have been working on winforms using C# in my company for quite a
I have some nice, working edit-undo functionality in my winforms application. It works using
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
I have been working with a string[] array in C# that gets returned from
I have been working on some legacy C++ code that uses variable length structures
I have a WinForms application that uses XNA to animate 3D models in a
I have a winforms application that includes an Administration form (call it 'adminForm') and

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.