Skip to content

Instantly share code, notes, and snippets.

@kentkrantz
Created May 6, 2020 02:58
Show Gist options
  • Select an option

  • Save kentkrantz/7bb50e20bf5ce5b9d0c2d491191ff19e to your computer and use it in GitHub Desktop.

Select an option

Save kentkrantz/7bb50e20bf5ce5b9d0c2d491191ff19e to your computer and use it in GitHub Desktop.
// import screenshot function from module at
const { screenshot } = at
// Take screenshot without parameters.
// Without parameter `savePath`, it will save the image to your iOS Album
screenshot()
// or
at.screenshot()
// Specify savePath parameter to take scsreenshot.
// If the savePath doesn't start with character '/', means it's a relative path, the image will be saved to the relative path of current script
// If the savePath starts with character '/', means it's a absolute path, the image will be saved to the absolute path
screenshot(`images/${new Date().toISOString()}.png`)
// Specify savePath and region, region means the rect area of the screen you want to capture screenshot
screenshot(`images/${new Date().toISOString()}.png`, { x: 0, y: 0, width: 100, height: 200 })
// Prepare parameters before using
const savePath = `images/${new Date().toISOString()}.png`
const region = { x: 0, y: 0, width: 300, height: 500 }
screenshot(savePath, region)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment