Skip to content

CleanShot X

CleanShot X 是一款 macOS 截图和屏幕录制应用。Protocol Launcher 允许您生成 CleanShot X 的 URL scheme 链接。

使用方式

有两种使用此库的方式:

  • 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
  • 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。

生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。

选择安装方式

按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。

URL 方法

下面的 helper 与 CleanShot 官方 URL Scheme API 保持一致。

All-In-One 模式

On-Demand
ts
import { allInOne } from 'protocol-launcher/cleanshot-x'

const url = allInOne()

const areaUrl = allInOne({
  x: 100,
  y: 120,
  width: 200,
  height: 150,
  display: 1,
})

截图

On-Demand
ts
import { captureArea, capturePreviousArea, captureFullscreen, captureWindow, selfTimer, scrollingCapture, pin } from 'protocol-launcher/cleanshot-x'

const captureAreaUrl = captureArea()

const annotateAreaUrl = captureArea({
  action: 'annotate',
})

const regionUrl = captureArea({
  x: 100,
  y: 120,
  width: 200,
  height: 150,
  display: 1,
})

const previousUrl = capturePreviousArea({
  action: 'copy',
})

const fullscreenUrl = captureFullscreen({
  action: 'save',
})

const windowUrl = captureWindow({
  action: 'upload',
})

const timerUrl = selfTimer({
  action: 'pin',
})

const scrollingUrl = scrollingCapture({
  x: 100,
  y: 120,
  width: 200,
  height: 150,
  start: true,
  autoscroll: true,
})

const pinUrl = pin({
  filepath: '/Users/username/Desktop/my screenshot.png',
})

屏幕录制

On-Demand
ts
import { recordScreen } from 'protocol-launcher/cleanshot-x'

const url = recordScreen()

const areaUrl = recordScreen({
  x: 100,
  y: 120,
  width: 200,
  height: 150,
  display: 1,
})

文本识别

On-Demand
ts
import { captureText } from 'protocol-launcher/cleanshot-x'

const url = captureText()

const fileUrl = captureText({
  filepath: '/Users/username/Desktop/my screenshot.png',
})

const areaUrl = captureText({
  x: 100,
  y: 120,
  width: 200,
  height: 150,
  display: 1,
  linebreaks: true,
})

标注

On-Demand
ts
import { openAnnotate, openFromClipboard } from 'protocol-launcher/cleanshot-x'

const fileUrl = openAnnotate({
  filepath: '/Users/username/Desktop/my screenshot.png',
})

const clipboardUrl = openFromClipboard()

桌面图标

On-Demand
ts
import { toggleDesktopIcons, hideDesktopIcons, showDesktopIcons } from 'protocol-launcher/cleanshot-x'

const toggleUrl = toggleDesktopIcons()

const hideUrl = hideDesktopIcons()

const showUrl = showDesktopIcons()

Quick Access Overlay

On-Demand
ts
import { addQuickAccessOverlay } from 'protocol-launcher/cleanshot-x'

const url = addQuickAccessOverlay({
  filepath: '/Users/username/Desktop/my screenshot.png',
})

历史管理

On-Demand
ts
import { openHistory, restoreRecentlyClosed } from 'protocol-launcher/cleanshot-x'

const historyUrl = openHistory()

const restoreUrl = restoreRecentlyClosed()

设置

On-Demand
ts
import { openSettings } from 'protocol-launcher/cleanshot-x'

const url = openSettings()

const tabUrl = openSettings({
  tab: 'recording',
})

官方文档