English
Longshot
Longshot is a powerful screenshot and screen recording tool for macOS. Protocol Launcher allows you to generate deep links to trigger actions like screenshot, recording, OCR, and more in Longshot.
Usage
There are two ways to use this library:
- On-Demand import from subpaths enables tree-shaking and keeps bundles small.
- Full Import from the root package is convenient but includes all app modules.
Pick On-Demand for production builds; Full Import is fine for quick scripts or demos.
Select Installation Method
On-Demand
Recommended. Optimized for production.
Full Import
Convenient. Good for quick scripts.
Start Screenshot
ts
import { snip } from 'protocol-launcher/longshot'
const url = snip({
func: 'start',
})Start Area Recording
ts
import { record } from 'protocol-launcher/longshot'
const url = record({
func: 'start_area',
})Start OCR
ts
import { ocr } from 'protocol-launcher/longshot'
const url = ocr({
func: 'start',
})Start Screen Measurement
ts
import { rule } from 'protocol-launcher/longshot'
const url = rule({
func: 'start',
})Open Preferences
ts
import { pref } from 'protocol-launcher/longshot'
const url = pref({
page: 'shortcuts',
})Return Capture Results
snip, record and ocr accept xSuccess, xError and xSource. Supplying callback options (or xCallback: true) selects x-callback-url and clipboard results: data for snip, filepath for record, string for ocr. The official area-recording examples use start_area for the plain route and startArea for the callback route. Supply the corresponding func value; it is preserved as provided. errorMessage is returned by Longshot, rather than supplied in the request.
ts
import { snip } from 'protocol-launcher/longshot'
const snipUrl = snip({
'func': 'start',
'xSuccess': 'myapp://snipped'
})ts
import { record } from 'protocol-launcher/longshot'
const recordUrl = record({
'func': 'startArea',
'xSuccess': 'myapp://recorded',
'xError': 'myapp://error'
})ts
import { ocr } from 'protocol-launcher/longshot'
const ocrUrl = ocr({
'func': 'start',
'xSuccess': 'myapp://recognized'
})