{"id":15043219,"url":"https://github.com/nosolosoftware/win-control","last_synced_at":"2025-04-14T20:31:29.399Z","repository":{"id":38193804,"uuid":"289878269","full_name":"nosolosoftware/win-control","owner":"nosolosoftware","description":"Windows manipulation made easy for node.js","archived":false,"fork":false,"pushed_at":"2022-06-09T13:41:07.000Z","size":41,"stargazers_count":30,"open_issues_count":6,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T09:03:32.891Z","etag":null,"topics":["automation","automation-ui","nodejs","windows"],"latest_commit_sha":null,"homepage":"","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/nosolosoftware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-24T09:00:58.000Z","updated_at":"2024-11-13T17:13:43.000Z","dependencies_parsed_at":"2022-08-19T05:31:44.647Z","dependency_job_id":null,"html_url":"https://github.com/nosolosoftware/win-control","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosolosoftware%2Fwin-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosolosoftware%2Fwin-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosolosoftware%2Fwin-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosolosoftware%2Fwin-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nosolosoftware","download_url":"https://codeload.github.com/nosolosoftware/win-control/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248955561,"owners_count":21189164,"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":["automation","automation-ui","nodejs","windows"],"created_at":"2024-09-24T20:48:43.075Z","updated_at":"2025-04-14T20:31:28.805Z","avatar_url":"https://github.com/nosolosoftware.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# win-control\nwin-control aims at managing currently opened windows from nodejs, wrapping the native windows API.\n\nThis module is exclusively compatible with Windows.\n\n## Usage\n\nInstall with yarn/npm\n```\nyarn add win-control\n```\nThen, library can be imported as follows.\n\n```javascript\nconst {Window} = require('win-control')\n\n// Set a window as foreground using the process identifier\nWindow.getByPid(PID).setForeground()\n```\n\n## Documentation\n\n### Window.getByPid(PID)\nSearch a windows by the PID of the process\n\n* `pid` `{number}` PID of the process owning the window.\n\nReturns `undefined` if PID doesn't have an associated window, or an instance of [Window](#class-window).\n\n### Window.getForeground()\nGet current foreground window.\n\nReturns an instance of [Window](#class-window).\n\n### Window.getByClassName(className)\nSearch a windows by the class name of the window\n\n* `className` `{string}` Classname of the window to look for.\n\nReturns `undefined` if it could not be found, or an instance of [Window](#class-window).\n\n### Window.getByTitle(title)\nSearch a windows by the title of the window, the coincidence must be exact\n\n* `title` `{string}` Classname of the window to look for.\n\nReturns `undefined` if it could not be found, or an instance of [Window](#class-window).\n\n***\n\n### Class: Window\n\n#### Constructor: new Window(hwnd)\n\n* `hwnd` `{number}` Identifier of the window to be managed.\n\n#### #getParent()\n\nRetrieves an instance of [Window](#class-window) with the specified window's parent or owner. It may returns `undefined` if class has not any parent.\n\n#### #getAncestor(kindOfAncestor)\n\nRetrieves an instance of [Window](#class-window) with the specified ancestor. It may returns `undefined` if class has not the specified ancestor.\n\n* `kindOfAncestor` see [AncestorFlags](#ancestorflags)\n\n#### #getProcessInfo()\n\nReturns an object with information of the process who owns the window.\n\nThe object has the following properties.\n* `windowText` `{string}` Window's title bar.\n* `pid` `{number}` PID of the process who owns the window.\n* `path` `{string}` Process's path who owns the window.\n\n#### #getPid()\n\nReturns a `number` with the PID of the owner of the window.\n\n#### #getClassName()\n\nReturns a `string` with the window's class name.\n\n#### #getTitle()\n\nReturns a `string` with the window's title bar (if it has one).\n\n#### #exists()\n\nReturns a `boolean` indicating if the window still exists\n\n#### #isVisible()\n\nReturns a `boolean` indicating if the window is visible\n\n#### #getDimensions()\n\nRetrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.\n\nThe returned object has the following properties\n\n* `left` `{number}` x-coordinate of the upper-left corner of the rectangle.\n* `right` `{number}` x-coordinate of the lower-right corner of the rectangle.\n* `top` `{number}` y-coordinate of the upper-left corner of the rectangle.\n* `bottom` `{number}` y-coordinate of the lower-right corner of the rectangle.\n\n#### #getHwnd()\n\nReturns the hwnd of the current instance.\n\n#### #moveRelative(dx, dy, dw, dh)\n\nChanges the position and dimensions of the specified window\n\n* `dx` `{number}` new position of the left side relative to current\n* `dy` `{number}` new position of the top side relative to current\n* `dw` `{number}` new width of the window relative to current\n* `dh` `{number}` new height of the window relative to current\n\nReturns a `boolean` indicating if the operation has succeeded\n\n#### #setShowStatus(state)\n\nSets the specified window's show state.\n\n* `state` See [WindowStates](#windowstates)\n\nReturns a `boolean` indicating if the operation has succeeded\n\n#### #setPosition(hwndInsertAfter, x, y, cx, cy, uFlags)\n\nChanges the size, position, and Z order of the window.\n\n* `hwndInsertAfter` `{number}` A HWND to precede the positioned window in the Z order or a value of [HWND](#hwnd)\n* `x` `{number}`: new position of the left side of the window.\n* `y` `{number}`: new position of the top of the window.\n* `cx` `{number}`: new width in pixels.\n* `cy` `{number}`: new height in pixels.\n* `uFlags`: the window sizing and positioning flags. See [SWP](#swp)\n\nReturns a `boolean` indicating if the operation has succeeded\n\n#### #setForeground()\n\nBrings the current window into the foreground and activates the window.\n\n#### #close()\n\nCloses current window.\n\n## SWP\n\nExposed as:\n\n```javascript\nrequire('win-control').SWP\n```\n\nWith the following properties\n\n* `NOSIZE`: retains the current size (ignores the cx and cy parameters).\n* `NOMOVE`: retains the current position (ignores X and Y parameters).\n* `NOZORDER`: retains the current Z order.\n* `NOREDRAW`: does not redraw changes. If this flag is set, no repainting of any kind occurs.\n* `NOACTIVATE`: does not activate the window.\n* `DRAWFRAME`: draws a frame around the window.\n* `FRAMECHANGED`: applies new frame styles set.\n* `SHOWWINDOW`: displays the window.\n* `HIDEWINDOW`: hides the window.\n* `NOCOPYBITS`: discards the entire contents of the client area.\n* `NOOWNERZORDER`: does not change the owner window's position in the Z order\n* `NOREPOSITION`: same as the NOOWNERZORDER flag.\n* `NOSENDCHANGING`: prevents the window from receiving the WM_WINDOWPOSCHANGING message\n* `DEFERERASE`: prevents generation of the WM_SYNCPAINT message.\n* `ASYNCWINDOWPOS`: if the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window.\n\n\n## HWND\n\nExposed as:\n\n```javascript\nrequire('win-control').HWND\n```\n\nWith the following properties\n\n* `BOTTOM`: places the window at the bottom of the Z order.\n* `NOTOPMOST`: places the window above all non-topmost windows (that is, behind all topmost windows).\n* `TOP`: places the window at the top of the Z order.\n* `TOPMOST`: places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.\n\n## AncestorFlags\n\nExposed as:\n\n```javascript\nrequire('win-control').AncestorFlags\n```\n\nWith the following properties\n\n* `PARENT`: retrieves the parent window.\n* `ROOT`: retrieves the root window by walking the chain of parent windows.\n* `ROOTOWNER`: retrieves the owned root window by walking the chain of parent and owner windows.\n\n## WindowStates\n\nExposed as:\n\n```javascript\nrequire('win-control').WindowStates\n```\n\nWith the following properties\n\n* `HIDE`: hides the window and activates another window.\n* `SHOWNORMAL`: activates and displays a window\n* `SHOWMINIMIZED`: activates the window and displays it as a minimized window.\n* `MAXIMIZE`: maximizes the specified window.\n* `SHOWMAXIMIZED`: activates the window and displays it as a maximized window.\n* `SHOWNOACTIVATE`: displays a window in its most recent size and position.\n* `SHOW`: activates the window and displays it in its current size and position.\n* `MINIMIZE`: minimizes the specified window and activates the next top-level window in the Z order.\n* `SHOWMINNOACTIVE`: displays the window as a minimized window.\n* `SHOWNA`: displays the window in its current size and position\n* `RESTORE`: activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position\n* `SHOWDEFAULT`: sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.\n* `FORCEMINIMIZE`: minimizes a window, even if the thread that owns the window is not responding.\n\n## Examples\n\nFor more information on uses, please see [example](example/index.js).\n\n## Contributing\n\nBug reports and merge requests are welcome on Github at\nhttps://github.com/nosolosoftware/win-control using\n[GitHub Flow](https://guides.github.com/introduction/flow/index.html). This project is intended to\nbe a safe, welcoming space for collaboration, and contributors are expected to adhere to the\n[Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## Versioning\n\n**win-control** uses [Semantic Versioning 2.0.0](http://semver.org)\n\n## Generating a new version\n\nIn order to publish a new version you need to define `NODE_PRE_GYP_GITHUB_TOKEN` as environmental variable.\n\n* Bump version at package.json\n* yarn node-pre-gyp clean configure build package\n* yarn node-pre-gyp-github publish --release\n* npm publish\n\n## License\n\nCopyright (c) 2019-2020 NoSoloSoftware Network S.L. - Released under [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosolosoftware%2Fwin-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnosolosoftware%2Fwin-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosolosoftware%2Fwin-control/lists"}