{"id":19670038,"url":"https://github.com/native-bindings/xdotool","last_synced_at":"2025-04-29T00:31:23.102Z","repository":{"id":36460907,"uuid":"223843031","full_name":"native-bindings/xdotool","owner":"native-bindings","description":"C++ bindings for Node.js to handle X11 using the full power of libxdo.","archived":false,"fork":false,"pushed_at":"2023-05-07T09:08:15.000Z","size":317,"stargazers_count":12,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-24T11:12:45.809Z","etag":null,"topics":["libxdo","nodejs","x11","xdotool","xlib","xorg"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/native-bindings.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2019-11-25T02:06:13.000Z","updated_at":"2023-12-30T14:45:07.000Z","dependencies_parsed_at":"2024-04-11T16:23:17.142Z","dependency_job_id":null,"html_url":"https://github.com/native-bindings/xdotool","commit_stats":null,"previous_names":["native-bindings/xdotool"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/native-bindings%2Fxdotool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/native-bindings%2Fxdotool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/native-bindings%2Fxdotool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/native-bindings%2Fxdotool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/native-bindings","download_url":"https://codeload.github.com/native-bindings/xdotool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224142852,"owners_count":17262884,"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":["libxdo","nodejs","x11","xdotool","xlib","xorg"],"created_at":"2024-11-11T17:03:48.270Z","updated_at":"2024-11-11T17:03:48.814Z","avatar_url":"https://github.com/native-bindings.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xdotool\n\nC++ bindings for Node.js to handle X11 using the full power of libxdo.\n\n## Installation\n\n```\nyarn add xdotool\n```\n\n## Examples\n\n### Key logging\n\nA few lines of code and you're able to spy what key strokes are being pressed on the keyboard:\n\n```ts\nconst bindings = new XdoToolBindings();\nconst kbd = new KeyboardAsync(bindings);\nwhile(true) { // Keeps printing until you kill the process\n    const buffer = Buffer.from(await kbd.queryKeymap(), 0, 32);\n    for(let j = 0; j \u003c 32; j++) {\n        for(let h = 0; h \u003c 8; h++) {\n            if(buffer[j] \u0026 (1 \u003c\u003c h)) {\n                const keycode = j * 8 + h;\n                const keysym = kbd.keycodeToKeysym(keycode);\n                console.log(kbd.keysymToString(keysym));\n            }\n        }\n    }\n}\n```\n\n### Activate window\n\nIn the example below we look for windows with the name of `Visual Studio Code`. If any valid match is found, we focus it.\n\n```ts\nimport { XdoToolAsync, XdoToolBindings } from 'xdotool';\n\n// Activate Visual Studio Code window\nfunction activateVisualStudioCodeWindow() {\n    const xdo = new XdoToolAsync(new XdoToolBindings());\n    const windows = await xdo.searchWindows({\n        winclassname: 'Visual Studio Code'\n    });\n    for(const w of windows) {\n        if(!(await xdo.windowHasProperty(w, '_NET_WM_DESKTOP'))) {\n            continue;\n        }\n        await xdo.activateWindow(w);\n        break;\n    }\n}\n```\n\n### Screenshot\n\nOur X11-based screenshooter is only capable of returning raw 8-bit RGB image format data at the moment but it is very fast and memory efficient. Getting a screenshot is super simple:\n\n```ts\nimport { ScreenshooterAsync, XdoToolBindings } from 'xdotool';\nimport { promises as fs } from 'fs';\n\nasync function screenshot() {\n    const xdo = new XdoToolBindings();\n    const screenshooter = new ScreenshooterAsync(xdo);\n    const arrayBuffer = await screenshooter.getImage();\n    fs.writeFile(`${__dirname}/screenshot_${new Date()}.rgb`, Buffer.from(arrayBuffer));\n}\n```\n\nFor obvious reasons, the `ArrayBuffer` returned by `screenshooter.getImage` is reused on every call. So, unless you create a new instance of screenshooter, if you try to keep the reference, it'll be changed if you're calling this method elsewhere at the same time.\n\n## Requirements\n\n- Boost\n- CMake\n- libx11\n- xdotool","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnative-bindings%2Fxdotool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnative-bindings%2Fxdotool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnative-bindings%2Fxdotool/lists"}