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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:09:16+00:00 2026-06-01T06:09:16+00:00

In a C# Console app, pressing the Pause key freezes the display output. Can

  • 0

In a C# Console app, pressing the Pause key freezes the display output. Can I disable that?

I was hoping for a handler like the Console.CancelKeyPress event that handles Ctrl+C input.

  • 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-01T06:09:17+00:00Added an answer on June 1, 2026 at 6:09 am

    Every once in a while a request comes up for hooking keys from a console program. The standard events like CTRL_C_EVENT and CTRL_CLOSE_EVENT do not include the Pause-event. I’ve tried doing so using a background thread, but I don’t seem to manage. However, there’s a not-so-hard workaround: use an extra process.

    Download this easy-to-use global keyboard hook for C#. Then, when you open that project, take the following code and put it in the Form1.cs:

    public partial class Form1 : Form {
    
        globalKeyboardHook globalKeyboardHook = new globalKeyboardHook();
    
        public Form1() {
            InitializeComponent();
        }
    
        private void Form1_Load(object sender, EventArgs e) {
            globalKeyboardHook.HookedKeys.Add(Keys.Pause);
            globalKeyboardHook.KeyDown += new KeyEventHandler(globalKeyboardHook_KeyDown);
            globalKeyboardHook.KeyUp += new KeyEventHandler(globalKeyboardHook_KeyUp);
        }
    
        void globalKeyboardHook_KeyUp(object sender, KeyEventArgs e)
        {
            // remove this when you want to run invisible
            lstLog.Items.Add("Up\t" + e.KeyCode.ToString());
    
            // this prevents the key from bubbling up in other programs
            e.Handled = true;
        }
    
        void globalKeyboardHook_KeyDown(object sender, KeyEventArgs e)
        {
            // remove this when you want to run without visible window
            lstLog.Items.Add("Down\t" + e.KeyCode.ToString());
    
            // this prevents the key from bubbling up in other programs
            e.Handled = true;
        }
    }
    

    Then, the rest becomes trivial:

    1. Change your program to start the above program and than run normally
    2. Try to type the pause key
    3. It’ll be caught by the other program
    4. Your program will NOT be paused.

    I tried the above myself and it works.

    PS: I don’t mean that there isn’t a possible way straight from a Console program. There may very well be, I just didn’t find it, and the above global keyhook library didn’t work from within a Console application.

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

Sidebar

Related Questions

I have a console app that must disable or enable some operations when output
I've got a console app that loads up a datatable; I'd like to export
In a console app, an ascii spinner can be used, like the GUI wait
With the application Utilities/Console.app, I can see the console output of applications. Is there
I have a console app that needs to display the state of items, but
My console app traps SIGINT so it can exit gracefully. Pressing CTRL + C
I have a console app that performs a lengthy process. I am printing out
For an C# console app like this is it better to use xcopy or
I have console app A that references another console app B. B app has
I have a console app that's geared to be automatically ran as a Scheduled

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.