Skip to content

Commit b18e380

Browse files
committed
Updated readme
1 parent 1d288f3 commit b18e380

File tree

1 file changed

+44
-27
lines changed

1 file changed

+44
-27
lines changed

README.md

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ but additionally gives you the possibility to navigate the screen based on image
4040

4141
A huge **"Thank you!"** goes out to all sponsors who make open source a bit more sustainable!
4242

43-
[<img src="https://avatars.githubusercontent.com/u/17616211?v=4" width="75" alt="Reiss Cashmore" />](https://github.com/Reiss-Cashmore)
44-
[<img src="https://avatars.githubusercontent.com/u/1794527?v=4" width="75" alt="Chet Corcos" />](https://github.com/ccorcos)
45-
[<img src="https://avatars.githubusercontent.com/u/4453806?v=4" width="75" alt="Patrick Flor" />](https://github.com/senorflor)
46-
[<img src="https://avatars.githubusercontent.com/u/7562803?v=4" width="75" alt="Ian" />](https://github.com/iwiedenm)
47-
48-
<hr/>
49-
50-
[<img src="https://github.com/nut-tree/nut.js/raw/develop/.gfx/sponsors/mighty.svg" height="75" alt="Mighty browser logo"/>](https://www.mightyapp.com)
51-
5243
# Demo
5344

5445
Check out this demo video to get a first impression of what nut.js is capable of.
@@ -102,46 +93,72 @@ It's work in progress and will undergo constant modification.
10293

10394
## Screen
10495

105-
- [x] Find an image on screen (requires an additional provider package like e.g. [nut-tree/template-matcher](https://www.npmjs.com/package/@nut-tree/template-matcher))
106-
- [x] Find all image occurrences on screen
107-
- [x] Wait for an image to appear on screen (requires an additional provider package like e.g. [nut-tree/template-matcher](https://www.npmjs.com/package/@nut-tree/template-matcher))
10896
- [x] Retrieve RGBA color information on screen
109-
- [x] Hooks to trigger actions based on images (requires an additional provider package like e.g. [nut-tree/template-matcher](https://www.npmjs.com/package/@nut-tree/template-matcher))
11097
- [x] Highlighting screen regions
98+
- [x] Find a single or multiple occurrences of an image on screen (requires an additional provider package like e.g. [nut-tree/template-matcher](https://www.npmjs.com/package/@nut-tree/template-matcher))
99+
- [x] Wait for an image to appear on screen (requires an additional provider package like e.g. [nut-tree/template-matcher](https://www.npmjs.com/package/@nut-tree/template-matcher))
100+
- [x] Find a single or multiple occurrences of text on screen (\*)
101+
- [x] Wait for a piece of text to appear on screen (\*)
102+
- [x] Find a single or multiple windows on screen (\*)
103+
- [x] Wait for a window to appear on screen (\*)
104+
- [x] Hooks to trigger actions based on detected text, images or windows (\*)
105+
106+
(\*) Requires an additional provider package, visit [nutjs.dev](https://nutjs.dev) for more info
111107

112108
## Integration
113109

114110
- [x] Jest
115111
- [x] Electron
112+
- [x] Custom log integration
116113

117114
# Sample
118115

119-
The following snippet shows a valid `nut.js` example:
116+
The following snippet shows a valid `nut.js` example (using multiple addons):
120117

121118
```js
122119
"use strict";
123120

124121
const {
125122
mouse,
126-
left,
127-
right,
128-
up,
129-
down,
123+
screen,
124+
singleWord,
125+
sleep,
126+
useConsoleLogger,
127+
ConsoleLogLevel,
130128
straightTo,
131129
centerOf,
132-
Region,
130+
Button,
131+
getActiveWindow,
133132
} = require("@nut-tree/nut-js");
133+
const {
134+
preloadLanguages,
135+
Language,
136+
LanguageModelType,
137+
configure,
138+
} = require("@nut-tree/plugin-ocr");
139+
140+
configure({ languageModelType: LanguageModelType.BEST });
141+
142+
useConsoleLogger({ logLevel: ConsoleLogLevel.DEBUG });
143+
144+
screen.config.autoHighlight = true;
145+
screen.config.ocrConfidence = 0.8;
134146

135-
const square = async () => {
136-
await mouse.move(right(500));
137-
await mouse.move(down(500));
138-
await mouse.move(left(500));
139-
await mouse.move(up(500));
140-
};
147+
function activeWindowRegion() {
148+
return getActiveWindow().then((activeWindow) => activeWindow.region);
149+
}
141150

142151
(async () => {
143-
await square();
144-
await mouse.move(straightTo(centerOf(new Region(100, 100, 200, 300))));
152+
await preloadLanguages([Language.English], [LanguageModelType.BEST]);
153+
await sleep(5000);
154+
const result = await screen.find(singleWord("@nut-tree/nut-js"));
155+
await mouse.move(straightTo(centerOf(result)));
156+
await mouse.click(Button.LEFT);
157+
await screen.waitFor(singleWord("Native"), 15000, 1000, {
158+
providerData: { partialMatch: true },
159+
});
160+
const content = await screen.read({ searchRegion: activeWindowRegion() });
161+
console.log(content);
145162
})();
146163
```
147164

0 commit comments

Comments
 (0)