© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
47 replies
Owen

❔ Issue with GlobalMouseKeyHook / Global Hotkeys.

I am using: https://github.com/gmamaladze/globalmousekeyhook in one of my C# console applications to receive keypresses when the console is out of focus.
This works in one of my applications - but when attempting to use the same code in a new project, the key presses are not detected at all.

Not sure what the problem could be here. Any ideas?
Here's the implementation i'm using in both programs.
    using Gma.System.MouseKeyHook;
    
    public class CreateHotkeyEvent
    {
        public static void Do()
        {
            Hook.GlobalEvents().KeyPress += (sender, e) =>
            {
                if (e.KeyChar == ')')
                {
                    Console.WriteLine("stop");
                    ConsoleExtensions.ChangeRunningState();
                }
                else if(e.KeyChar == '(')
                {
                    Console.WriteLine("hide");
                    ConsoleExtensions.ShowHideWindow();
                }
            };
        }
    }
    using Gma.System.MouseKeyHook;
    
    public class CreateHotkeyEvent
    {
        public static void Do()
        {
            Hook.GlobalEvents().KeyPress += (sender, e) =>
            {
                if (e.KeyChar == ')')
                {
                    Console.WriteLine("stop");
                    ConsoleExtensions.ChangeRunningState();
                }
                else if(e.KeyChar == '(')
                {
                    Console.WriteLine("hide");
                    ConsoleExtensions.ShowHideWindow();
                }
            };
        }
    }
GitHub
GitHub - gmamaladze/globalmousekeyhook: This library allows you to ...
This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background. - GitHub - gmamaladze/globalmousekeyhook: This libra...
GitHub - gmamaladze/globalmousekeyhook: This library allows you to ...
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Recording hotkeys
C#CC# / help
4y ago
❔ Managing `global.json` with JebBrains Rider?
C#CC# / help
4y ago