{"id":14963697,"url":"https://github.com/bracozs/globalhotkeysrx","last_synced_at":"2025-07-11T07:40:59.166Z","repository":{"id":250396534,"uuid":"834357963","full_name":"BracoZS/GlobalHotKeysRX","owner":"BracoZS","description":"Simple C#  Library for creating global hotkeys.","archived":false,"fork":false,"pushed_at":"2024-11-05T18:58:20.000Z","size":100,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T04:28:43.158Z","etag":null,"topics":["csharp","desktop","global","hotkeys","net8","windowless","windows","wpf"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/GlobalHotkeysRX","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BracoZS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"Braco_ZS","open_collective":null,"ko_fi":"bracozs","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2024-07-27T03:34:52.000Z","updated_at":"2025-02-19T20:09:47.000Z","dependencies_parsed_at":"2024-07-30T23:57:08.783Z","dependency_job_id":"7ac6f8d4-afa1-48d7-b36a-dd832e2de553","html_url":"https://github.com/BracoZS/GlobalHotKeysRX","commit_stats":null,"previous_names":["bracozs/globalhotkeysrx"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BracoZS/GlobalHotKeysRX","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BracoZS%2FGlobalHotKeysRX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BracoZS%2FGlobalHotKeysRX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BracoZS%2FGlobalHotKeysRX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BracoZS%2FGlobalHotKeysRX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BracoZS","download_url":"https://codeload.github.com/BracoZS/GlobalHotKeysRX/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BracoZS%2FGlobalHotKeysRX/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264757253,"owners_count":23659314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","desktop","global","hotkeys","net8","windowless","windows","wpf"],"created_at":"2024-09-24T13:32:00.804Z","updated_at":"2025-07-11T07:40:59.135Z","avatar_url":"https://github.com/BracoZS.png","language":"C#","funding_links":["https://patreon.com/Braco_ZS","https://ko-fi.com/bracozs","https://www.patreon.com/Braco_ZS","https://ko-fi.com/A0A4G6LKI"],"categories":[],"sub_categories":[],"readme":"﻿# GlobalHotKeysRX\n\nSimple C# library for creating system-wide hotkeys. It allows you to implement keyboard shortcuts to perform specific actions in your application, regardless of the active window.\nYou can use it in background/windowless applications.\n\nIt supports combinations of:\n\n-Modifier keys: Alt, Control, Shift, Win (up to 3 at a time).\n\n-Keys, listed at [Virtual-Key Codes](https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes).\n\n## [Nuget Package](https://www.nuget.org/packages/GlobalHotkeysRX) \u003ca href=\"https://www.nuget.org/packages/GlobalHotkeysRX\"\u003e\u003cimg src=\"https://api.nuget.org/v3-flatcontainer/globalhotkeysrx/2.0.0/icon\" width=\"32\" height=\"32\"/\u003e\u003c/a\u003e\n\n##  Usage\n\nImport library\n```\nusing GlobalHotKeysRX;\n```\n\nInitialization\n```\n// default constructor\nGlobalHotkeys appHotkeys = new GlobalHotkeys();\n\n// or you can call it with one or more 'Hotkey' parameters.\nGlobalHotkeys appHotkeys = new GlobalHotkeys(\n  new Hotkey(Modifier.Shift, VKey.P, myFunction),             \n  new Hotkey(Modifier.Alt, VKey.S, () =\u003e {/* code */})   // lambda expression\n  new Hotkey(Modifier.Control, VKey.Y)\n);\n\n```\n\u003e *Use the  `|`  operator to combine/add modifiers. For example, combine `Control` + `Alt` to get `AtlGr`\n\u003e\n\u003e `new Hotkey(Modifier.Control | Modifier.Alt, VKey.P, myFunction)  // AltGr + P`\n\u003e \n\u003e *By using 'Modifiers.NoRepeat' with another modifier, the application will only receive another WM_HOTKEY message when the key is released and then pressed again while a modifier is held down.\n\u003e\n\u003e `new Hotkey(Modifier.Shift | Modifier.NoRepeat, VKey.P, myFunction)`\n\u003e\n\n\u003e\n\u003e### * If you are in a **Windows Form** proyect\n\u003eyou need to specify the handle, either in constructor...\n\u003e\n\u003e`GlobalHotkeys appHotkeys = new GlobalHotkeys(this.Handle);` \n\u003e\n\u003e...or through the ClientHandle property\n\u003e\n\u003e`appHotkeys.ClientHandle = this.Handle;`\n\u003e\n\u003eAlso you must add this to the form\n\u003e\n\u003e```\n\u003e protected override void WndProc(ref Message m)\n\u003e{\n\u003e    if(m.Msg == WinApi.WM_HOTKEY)\n\u003e        appHotkeys.OnWinFormMessage(m);  // Replace by your own instance name\n\u003e\n\u003e    // (Optional) Stops any default or additional processing of the message.\n\u003e    m.Result = (IntPtr)1;\n\u003e\n\u003e    base.WndProc(ref m);\n\u003e}\n\u003e```\n\n\nAdding a hotkey after initialization\n```\nappHotkeys.Add(Modifier.Win, VKey.NUM_0);\n\n// or\nvar htk = new Hotkey(Modifier.Win, VKey.NUM_0, myFuntion);\nappHotkeys.Add(htk);   \n\nvoid myFunction()\n{\n    // code when a hotkey occurs...\n}\n```\nRemoving\n```\nappHotkeys.Remove(Modifier.Shift, VKey.Z);\n\n// or\nappHotkeys.Remove(htk);\n```\nSubscribe to hotkeys\n```\nappHotkeys.HotkeyPressed += AppHotkeys_HotkeyPressed;\n// ...\npublic void AppHotkeys_HotkeyPressed(object sender, HotkeyEventArgs e)\n{\n  MessageBox.Show($\"Hotkey {e.Modifier} + {e.Key} was pressed!\");\n}\n```\nCleaning up resources\n```\nappHotkeys.Dispose();\n```\nSimplest way 🙂 (wpf)\n```\nGlobalHotkeys ghk = new GlobalHotkeys(new Hotkey(Modifier.Shift, VKey.V, () =\u003e { /*code*/ }));\n```\n\n### Known issues\n\nThis library uses Win32 API. Typically, [RegisterHotKey](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerhotkey) fails if the keystrokes specified for the hot key have already been registered for another hot key. However, some pre-existing, default hotkeys registered by the OS (such as PrintScreen, which launches the Snipping tool) may be overridden by another hot key registration when one of the app's windows is in the foreground.\n\n[![Patreon](https://img.shields.io/badge/Support_on_patreon-ECEFF1?style=for-the-badge\u0026logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAABxklEQVR4nO2WPWvbQBiAr6VEKNAxUEinbh2SmIZg%2BSOW7Uh3siXLli6aQ6Fbp06FLulUSqBD5uQfZEwyJ3RsofQnhCYdQu6kk9MO7ZA3KBDoUDfSnbfqgWcTvI%2Feg5MQKin5A%2F2ZacxUutGt%2BoL5GP0D4YZPUkLfjgn9lDr0PCXhr5TQ07FDD8Zk%2FQVEkY6KoC119rRKF27NIv72HETRjMD0g8A3A2GimJ4mhIZTDbjw%2FYfCDj6mOIQ8ChxeCSt4M5UA2Ny8L6xgP7UDKO5oQzkgsYLnwgpAztHlDzN6JB0ACN0T1vBEWCOQd7glHZBaA0OsDUFN%2FyR7EamApOO%2FEl0fVGVdd14qIG4PtpKOD6qKNW9FbgNt713SHoCyZr8iuQHvZdL2QNVx05mTCmCt%2FtPE9EDJlvd14vA89wBfdb%2FELRdk5S33NVIMIPFqH%2BTsnX1f9maVAjJ4o7cdN3tQRN7s%2FU7q%2FQ66Cy1HAJjmA9ZwdnjDgXySn6yO6Z3Di3yOM1jD3uB1fMbrBCZaw0dx1VlEedEKBGR8Mwyd1ex1XsO7rIaPuYE%2FMwMfMsN%2Bz6p2Nfdg2YCpo5UBS%2F%2F7EegFf8tLStAUuAZWoCwNWjXb3wAAAABJRU5ErkJggg%3D%3D\u0026logoSize=auto)](https://www.patreon.com/Braco_ZS)\n[![Ko-fi](https://img.shields.io/badge/Support_me_on_Ko--fi-29B6F6?style=for-the-badge\u0026logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC90lEQVR4nO2YS0gUcRyAt6hTUdClSwQFnYIOBem6rm9dXxWYHoIOkolEUHQLO5nPOkTmoSJQjEgsekDH8pE9PBSEFVRQpmLszJblY7dVV%2FeLeSyuNfuYcWz3MB%2F82MP%2BZ%2Fi%2B4T%2B7s2uzWVhYWFhYWCQZQCXQB3xJwHwGXgL3gFPADr3y0kHJxCLQBeyKN2CE5GQGOBJLfh3JTRA4Fi1gPclPAHAmY8A3oEWdVuBFlLXvJVfDAfOfPjJz4zpTF1vwdrQTGPm69GYwyNzrV0y3tTLZ1ID3ZicLohDPaQc1fJxqmBYVhgK8nR14DpXiOViizIFi%2BdX34D4EAkw2NyIWFSAW5ivjypPXzD4b0B0gAewB5jTWP7TpDfD3PFmSl8RLi%2BQRSwrl%2BVV7dknelYdYkKtMfg6eYhcLY2O6AySAdo31bpvegImTJxRxVV4WL3YpE0FczMtGzM2SZ%2BryJaMBRyMcszHugKDfH1s8JB8SV%2BWFnEyE7AwmaqqNBpRHOGaDroDQVlkmHn7VJfGwqy6Lq%2FJClpOJ6iqjAY0a6%2F26t9CPqkpFPI7tEi4uT2Y6UxeadQcAmwGtj7HnugN83V1xb5dwcSHDgeBMY35oSFcAsAl4HGH9Od0Bwd8%2BvleURRcPyYfEVfmfZ04Tg7fAPnUKgFpgPMJaL7BVd4DE7MDTqPtcFg%2B76kK6XV4bGB3FROoi3SxxfRNPt12JuV0kccGhjL%2B3x0z5Xumhc0UBLC4yWV%2F373aRxUPyqbjTUvDevmWmfB%2BwRVNeV4CE9NjQcH7ZPg8Xdzvs%2BO50myXuB5o0H%2BAMB6j47nYrAY5UhLRU3PYUhJyseJ59YhFUb%2Bx6YHtU8ZUESMz29yPkZuO278dTXkZgeNjIad4AO9XZFvNqmxkgsTA%2Bzsy1qwR9PqOnGNQtbGaACQyaEbBW%2FcmWCPpWHKBGSDdOImgzK6AmAfIBYLdZAWsi%2FAJaTfnjpsj%2FFXIYeAR8WKW%2FEN8BncBe0%2BUtLCwsLCwsbP%2BHPz%2BHGuTTCs7IAAAAAElFTkSuQmCC\u0026logoSize=auto)](https://ko-fi.com/A0A4G6LKI)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbracozs%2Fglobalhotkeysrx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbracozs%2Fglobalhotkeysrx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbracozs%2Fglobalhotkeysrx/lists"}