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

  • SEARCH
  • Home
  • 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 8056887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:51:11+00:00 2026-06-05T08:51:11+00:00

I have a thread executing certain things and right at the end it’s supposed

  • 0

I have a thread executing certain things and right at the end it’s supposed to bind my F key as a global hotkey, I’ve been unable to get this to work, any insight as to what I’m doing wrong OR if RegisterHotKey is not functioning cause of my thread?

[DllImport("user32.dll", SetLastError = true)]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, System.Windows.Input.ModifierKeys fsModifiers, Keys vk);

[DllImport("user32.dll", SetLastError = true)]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);

private const int WmHotKey = 0x0312;

private void onLoad()
{
   //RegisterHotKey(this.Handle, 0, System.Windows.Input.ModifierKeys.None, Keys.F); // This works
}

private void OnSeparateThread()
{
   // This gets called by a separate thread, in the full version of the code more stuff
   // happen here, which does get executed.
   RegisterHotKey(this.Handle, 0, System.Windows.Input.ModifierKeys.None, Keys.F); // Does not bind
}

protected override void WndProc(ref Message m)
{
   if (m.Msg == WmHotKey)
   {
      MessageBox.Show("Test me!");
   }
   base.WndProc( ref m );
}

Edit: Naturally I’m not binding both of these at the same time, one is always commented out.

  • 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-05T08:51:12+00:00Added an answer on June 5, 2026 at 8:51 am

    (Originally a comment, but it does answer the question as posed):

    From MSDN, RegisterHotKey:

    This function cannot associate a hot key with a window created by another thread.

    So, simple answer is no.

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

Sidebar

Related Questions

I have a backgroundWorker thread running. At the end I update the UI, minimize
how to stop executing code in thread if takes to long. I have few
I have problem with my multithread application. When at one thread executing synchronous popen()
Suppose I have thread 1, the main window UI thread and thread 2, a
Is if almost always required to have thread syncing (i.e. use of mutex, semaphores,
I have several thread pools and I want my application to handle a cancel
I have a thread in Ruby. It runs a loop. When that loop reaches
I have a thread running in the background. How do i send it messages
I have a thread that does the following: 1) Do some work 2) Wait
I have a thread with return type DWORD in C but it is then

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.