@robinpath/screen
0.1.3Node.jsPublicScreen capture and OCR: screenshots, region capture, window capture, and text extraction
Screen
Screen capture and OCR: take screenshots (full, region, window), extract text from images with tesseract.js, list displays, and compare images
Package: @robinpath/screen | Category: Web | Type: Utility
Authentication
No authentication required. All functions are available immediately.
Use Cases
Use the screen module when you need to:
- Take a full screenshot and save to file -- Use
screen.captureto perform this operation - Capture a specific rectangular region of the screen -- Use
screen.captureRegionto perform this operation - Capture a specific window by its title (falls back to full screen if not found) -- Use
screen.captureWindowto perform this operation - Extract text from an image using OCR (tesseract.js) -- Use
screen.ocrto perform this operation - Extract text from a rectangular region of an image -- Use
screen.ocrRegionto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
capture | Take a full screenshot and save to file | {path, size} |
captureRegion | Capture a specific rectangular region of the screen | {path, size, region: {x, y, width, height}} |
captureWindow | Capture a specific window by its title (falls back to full screen if not found) | {path, size, window, fallback} |
ocr | Extract text from an image using OCR (tesseract.js) | {text, confidence, language} |
ocrRegion | Extract text from a rectangular region of an image | {text, confidence, region: {x, y, width, height}} |
setLanguage | Set the default OCR language (eng, rus, deu, fra, spa, chi_sim, jpn, kor, ron, etc.) | {language, previous} |
listDisplays | List all available displays/monitors | Array of {id, name, width, height, primary} |
compare | Compare two images byte-by-byte to check if they are identical | {identical, image1Size, image2Size, sameSize} |
Functions
capture
Take a full screenshot and save to file
Module: screen | Returns: object -- {path, size}
screen.capture "./screenshot.png"
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | string | Yes | Output file path |
options | object | No | {format?: 'png' |
captureRegion
Capture a specific rectangular region of the screen
Module: screen | Returns: object -- {path, size, region: {x, y, width, height}}
screen.captureRegion "./region.png" 100 100 400 300
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | string | Yes | Output file path |
x | number | Yes | Left position in pixels |
y | number | Yes | Top position in pixels |
width | number | Yes | Region width in pixels |
height | number | Yes | Region height in pixels |
captureWindow
Capture a specific window by its title (falls back to full screen if not found)
Module: screen | Returns: object -- {path, size, window, fallback}
screen.captureWindow "./notepad.png" "Untitled - Notepad"
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | string | Yes | Output file path |
windowTitle | string | Yes | Exact window title to capture |
ocr
Extract text from an image using OCR (tesseract.js)
Module: screen | Returns: object -- {text, confidence, language}
screen.ocr "./screenshot.png"
| Parameter | Type | Required | Description |
|---|---|---|---|
imagePath | string | Yes | Path to the image file |
options | object | No | {language?: string} e.g. 'eng', 'rus', 'deu' |
ocrRegion
Extract text from a rectangular region of an image
Module: screen | Returns: object -- {text, confidence, region: {x, y, width, height}}
screen.ocrRegion "./screenshot.png" 50 50 200 100
| Parameter | Type | Required | Description |
|---|---|---|---|
imagePath | string | Yes | Path to the image file |
x | number | Yes | Left position in pixels |
y | number | Yes | Top position in pixels |
width | number | Yes | Region width in pixels |
height | number | Yes | Region height in pixels |
options | object | No | {language?: string} |
setLanguage
Set the default OCR language (eng, rus, deu, fra, spa, chi_sim, jpn, kor, ron, etc.)
Module: screen | Returns: object -- {language, previous}
screen.setLanguage "deu"
| Parameter | Type | Required | Description |
|---|---|---|---|
language | string | Yes | Tesseract language code |
listDisplays
List all available displays/monitors
Module: screen | Returns: object -- Array of {id, name, width, height, primary}
screen.listDisplays
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | No | Call with no arguments |
compare
Compare two images byte-by-byte to check if they are identical
Module: screen | Returns: object -- {identical, image1Size, image2Size, sameSize}
screen.compare "./before.png" "./after.png"
| Parameter | Type | Required | Description |
|---|---|---|---|
image1Path | string | Yes | Path to first image |
image2Path | string | Yes | Path to second image |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (standard errors) | Check function parameters and authentication |
@desc "Capture and validate result"
do
set $result as screen.capture "./screenshot.png"
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. List and iterate Displays
Retrieve all items and loop through them.
@desc "List displays and iterate results"
do
set $result as screen.listDisplays
each $item in $result
print $item
end
enddo
2. Multi-step Screen workflow
Chain multiple screen operations together.
@desc "Capture, capture region, and more"
do
set $r_capture as screen.capture "./screenshot.png"
set $r_captureRegion as screen.captureRegion "./region.png" 100 100 400 300
set $r_captureWindow as screen.captureWindow "./notepad.png" "Untitled - Notepad"
print "All operations complete"
enddo
3. Safe capture with validation
Check results before proceeding.
@desc "Capture and validate result"
do
set $result as screen.capture "./screenshot.png"
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.3 | latest | 1 months ago |
Related Modules
ftp
JS@robinpathv0.1.3
FTP and SFTP file transfer operations
http
JS@robinpathv0.1.3
HTTP server for RobinPath scripts. Register routes with static responses (JSON, HTML, files), enable CORS, serve static directories. No callbacks needed.
form
JS@robinpathv0.2.1
Declarative form builder for RobinPath scripts � define fields inline, generate schemas, validate submissions
api
JS@robinpathv0.1.2
HTTP client for making requests to external APIs with profiles, auth, download/upload, and auto-JSON parsing
$ robinpath add @robinpath/screen
