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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:05:13+00:00 2026-05-13T21:05:13+00:00

I asked a question earlier about keyhooks in vb.net. My current issue is such:

  • 0

I asked a question earlier about keyhooks in vb.net.

My current issue is such:

I have created a program which should perform a certain action whenever a certain group of keys is pressed at the same time. The program must be able to run in the background, or in the system tray or something. Essentially, this should work like the KeyDown event on a form, except the form in this case is everything.

I’m not certain if there is a way to do this directly from within the .net API, but if there is I certainly have not found it.

  • 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-13T21:05:13+00:00Added an answer on May 13, 2026 at 9:05 pm

    That doesn’t require a keyboard hook, you’ll want to register a hot key. Much easier to implement and much less demanding of system resources. Here’s an example, it restores the form to the foreground if it was minimized. Note that you can register more than one key:

    Imports System.Runtime.InteropServices
    Imports System.ComponentModel
    
    Public Class Form1
      Private Const cHotKeyId As Integer = 0
    
      Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        '--- Register Ctrl + Shift + U as a hot key
        If Not RegisterHotKey(Me.Handle, cHotKeyId, MOD_CONTROL + MOD_SHIFT, Keys.U) Then
          Throw New Win32Exception()
        End If
        MyBase.OnLoad(e)
      End Sub
    
      Protected Overrides Sub OnFormClosing(ByVal e As System.Windows.Forms.FormClosingEventArgs)
        UnregisterHotKey(Me.Handle, cHotKeyId)
        MyBase.OnFormClosing(e)
      End Sub
    
      Protected Overrides Sub WndProc(ByRef m As Message)
        Console.WriteLine(m.ToString())
        If (m.Msg = WM_HOTKEY AndAlso m.WParam = CType(cHotKeyId, IntPtr)) Then
          Me.Visible = True
          If Me.WindowState = FormWindowState.Minimized Then Me.WindowState = FormWindowState.Normal
          SetForegroundWindow(Me.Handle)
        End If
        MyBase.WndProc(m)
      End Sub
    
      '--- P/Invoke declarations
      Private Const WM_HOTKEY As Integer = &H312
      Private Const MOD_ALT As Integer = &H1
      Private Const MOD_CONTROL As Integer = &H2
      Private Const MOD_SHIFT As Integer = &H4
      Private Declare Function RegisterHotKey Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal id As Integer, ByVal fsModifier As Integer, ByVal vk As Integer) As Boolean
      Private Declare Function UnregisterHotKey Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal id As Integer) As Boolean
      Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hWnd As IntPtr) As Boolean
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked an earlier question which was definitely helpful and let me know about
I asked a question earlier about which method for saving would be better, I
I asked a question earlier about which language to use for an AI prototype.
Ok, I asked a question earlier about Flex and ADO.NET Data Services but didn't
I asked a question earlier about why left joins in Linq can't use defined
I asked a question earlier about ESBs written in Erlang or Java, and there
This is related to this question I asked earlier about syntax highlighting user-defined blocks
Earlier today, I asked a question about the way Python handles certain kinds of
I asked this question earlier. I am intrigued by std::set but I have another
I asked a question earlier about how to go through a directory structure 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.