Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aabuhijleh/electron-selected-text
Get selected text from any application
https://github.com/aabuhijleh/electron-selected-text
clipboard electron robotjs selection
Last synced: 2 days ago
JSON representation
Get selected text from any application
- Host: GitHub
- URL: https://github.com/aabuhijleh/electron-selected-text
- Owner: aabuhijleh
- License: mit
- Created: 2020-10-25T08:41:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-03T07:36:00.000Z (about 4 years ago)
- Last Synced: 2024-12-27T13:47:08.078Z (about 1 month ago)
- Topics: clipboard, electron, robotjs, selection
- Language: TypeScript
- Homepage:
- Size: 94.7 KB
- Stars: 29
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Electron Selected Text
> Get selected text from any application using Electron's [clipboard](https://www.electronjs.org/docs/api/clipboard) and [robotjs](https://github.com/octalmage/robotjs)
For [Electron 9 and later](https://github.com/electron/electron/issues/18397), this module should only be used in the main process because [robotjs is not context aware](https://github.com/octalmage/robotjs/issues/580)
## Install
```
$ npm install electron-selected-text
```## Usage
```ts
import { app } from "electron";
import { getSelectedText, registerShortcut } from "electron-selected-text";const printSelectedText = (selectedText) => {
console.log(`Selected Text: ${selectedText}`);
};getSelectedText().then(printSelectedText);
app.whenReady().then(() => {
const ret = registerShortcut("F6", printSelectedText);if (!ret) {
console.warn("registration failed");
}
});
```