Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arbal/076b66ae75f94db608c1e7ebc41571fc to your computer and use it in GitHub Desktop.
Save arbal/076b66ae75f94db608c1e7ebc41571fc to your computer and use it in GitHub Desktop.
Resize current screen, center current screen & capture window with CleanShot
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Screenshot resize
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 📸
# @raycast.packageName Utilities
# Documentation:
# @raycast.description Resizes the window for screenshots
# @raycast.author Sebastiaan Kloos
# @raycast.authorURL https://github.com/SebastiaanKloos
tell application "System Events"
set activeApps to name of application processes whose frontmost is true
set currentApplication to item 1 of activeApps
end tell
set screenWidth to 1500
set screenHeight to 900
tell application "System Events" to tell application process currentApplication
try
set size of window 1 to {screenWidth, screenHeight}
on error err
log err
-- no window open
end try
end tell
tell application "System Events"
set frontWindow to the first window of application process currentApplication
set windowSize to size of frontWindow
set windowPosition to position of frontWindow
end tell
tell application "Finder"
set screenBounds to bounds of window of desktop
end tell
set windowSizeX to item 1 of windowSize
set windowSizeY to item 2 of windowSize
set windowCenterX to windowSizeX / 2
set windowCenterY to windowSizeY / 2
set screenCenterX to (item 3 of screenBounds) / 2
set screenCenterY to (item 4 of screenBounds) / 2
set newWindowPositionX to screenCenterX - windowCenterX
set newWindowPositionY to screenCenterY - windowCenterY
tell application "System Events"
set position of frontWindow to {newWindowPositionX, newWindowPositionY}
end tell
open location "cleanshot://capture-window"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment