{"id":18245673,"url":"https://github.com/rubinders/nodehotkey","last_synced_at":"2025-04-04T14:31:07.701Z","repository":{"id":48003465,"uuid":"172887725","full_name":"RubinderS/NodeHotKey","owner":"RubinderS","description":"This is an autohotkey like library built for NodeJS.","archived":false,"fork":false,"pushed_at":"2022-12-06T19:31:29.000Z","size":152,"stargazers_count":11,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-18T10:00:40.829Z","etag":null,"topics":["autohotkey","automation","clipboard","hotkey","hotstring","keyboard","macro","macros","mouse","nodehotkey","robot","robot-js"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/RubinderS.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}},"created_at":"2019-02-27T09:46:02.000Z","updated_at":"2023-06-15T05:12:44.000Z","dependencies_parsed_at":"2023-01-23T12:20:17.303Z","dependency_job_id":null,"html_url":"https://github.com/RubinderS/NodeHotKey","commit_stats":null,"previous_names":["rubinder25/nodehotkey"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubinderS%2FNodeHotKey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubinderS%2FNodeHotKey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubinderS%2FNodeHotKey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubinderS%2FNodeHotKey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubinderS","download_url":"https://codeload.github.com/RubinderS/NodeHotKey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247193941,"owners_count":20899399,"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":["autohotkey","automation","clipboard","hotkey","hotstring","keyboard","macro","macros","mouse","nodehotkey","robot","robot-js"],"created_at":"2024-11-05T09:22:14.092Z","updated_at":"2025-04-04T14:31:07.410Z","avatar_url":"https://github.com/RubinderS.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub](https://img.shields.io/github/license/rubinder25/NodeHotKey.svg?style=flat-square)\n![GitHub package.json version](https://img.shields.io/github/package-json/v/Rubinder25/NodeHotKey.svg?style=flat-square)\n\n# NodeHotKey\nhttps://github.com/Rubinder25/NodeHotKey  \nhttps://www.npmjs.com/package/nodehotkey  \nThis is an autohotkey like library for NodeJs\n\n## Features\n\n1. Make global Macros and assign hotkeys to trigger them\n2. Make global hotstrings to expand text as you type it\n3. Catch global keyboard/mouse events in your code\n4. Operate keyboard, mouse and clipboard from code\n# Usage\n## Install\n`npm install nodehotkey --save`  \nfollow this page to install dependencies for robot-js on your platform: http://getrobot.net/docs/usage.html\n\n## import\n`import { NodeHotKey } from 'nodehotkey';`\n## Initialize the object\n```javascript\nlet nhk = new NodeHotKey({});\n```\nCurrently, we are passing an empty object. A Macro Config object can be passed to the constructor in order to create AutoHotkey like macros.\nPlease refer to the next section for this.\n\n## Macro\nMacros are pre-defined steps that can be triggered by either pressing hotkeys or typing hotstrings. These can be defined as JavaScript objects.\n### A sample macro looks like this\n```javascript\nlet macroConfig = {\n    'Name of the Macro': {\n\t\thotkeys: [kc._CONTROL, kc._E],\n\t\tsteps: [\n\t\t\t{ type: 'This Macro can be triggered by pressing CTRL+E\\n' },\n\t\t\t{ type: \"Wait for 3 secs then press ','  \" },\n\t\t\t{ wait: 3000 },\n\t\t\t{ click: kc._COMMA },\n\t\t\t{ func: tools =\u003e { \n\t\t\t\t    tools.type('Run JavaScript functions by pressing hotkeys'); \n\t\t\t\t} \n\t\t\t}\n\t\t]\n\t}\n}\n```\nwe can then pass this macroConfig to constructor of NodeHotKey like this:-\n```javascript\nlet nhk = new NodeHotKey(macroConfig);\nnhk.startListening();\n```\n\nFor more sample Marco configs  check out **[MacroSamples_NodeHotKey](https://github.com/Rubinder25/MacroSamples_NodeHotKey)**.\n## Events\n```javascript\nnhk.on(nhk.eventTypes.keyPressed, (eventData) =\u003e {\n    console.log('KeyPressed ', eventData.keyCode);\n});\n```\n## Functions\nfollowing are the utility functions present in the package:-\n```javascript\nimport { pressKey, releaseKey, click,\n        type, paste, wait, setClipboardText, \n        getClipboardText, matchCurrentWindowTitle } from 'nodehotkey'; \n```\n## Putting it all together\n\n```javascript\nimport { NodeHotKey, pressKey,releaseKey, KEYCODES as kc } from 'nodehotkey';\n\n// press key\npressKey(kc._A);\nreleaseKey(kc._A);\n\nlet macroConfig = {\n    'Name of the Macro': {\n        hotkeys: [kc._CONTROL, kc._E],\n        steps: [\n            { type: 'This Macro can be triggered by pressing CTRL+E\\n' },\n            { type: \"Wait for 3 secs then press ','  \" },\n            { wait: 3000 },\n            { click: kc._COMMA },\n            { func: tools =\u003e { \n                        tools.type('Run JavaScript functions by pressing hotkeys'); \n                    } \n            }\n        ]\n    }\n}\n\nlet nhk = new NodeHotKey(macroConfig);\n\nnhk.startListening();\n\nnhk.on(nhk.eventTypes.keyPressed, (eventData) =\u003e {\n    console.log('KeyPressed ', eventData.keyCode);\n});\n\n// nhk.stopListening(); // terminates the program\n```\n## Sample Macros\nhttps://github.com/Rubinder25/MacroSamples_NodeHotKey\n\n\u003e email: mail2rubinder@gmail.com\n\n## License\nMIT\n\n**Note:** currently Node V10 is not supported\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubinders%2Fnodehotkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubinders%2Fnodehotkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubinders%2Fnodehotkey/lists"}