Skip to content

Instantly share code, notes, and snippets.

@GarthDB
Last active December 23, 2015 07:29
Show Gist options
  • Save GarthDB/6600779 to your computer and use it in GitHub Desktop.
Save GarthDB/6600779 to your computer and use it in GitHub Desktop.
A work in progress - I want to make a rake task that will open a page in a new chrome window, then resize it to a specific size and take a screenshot. Should be awesome if it works.
tell application "/Applications/Google Chrome.app"
make new window
activate
end tell
screencapture -c
http://www.maclife.com/article/columns/terminal_101_taking_screenshots_through_command_line
to splitString(aString, delimiter)
set retVal to {}
set prevDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to {delimiter}
set retVal to every text item of aString
set AppleScript's text item delimiters to prevDelimiter
return retVal
end splitString
on alfred_script(q)
set newDimensions to splitString(q as text, "x")
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
end tell
tell application "System Events" to tell application process frontApp
tell window 1
set size to {item 1 of newDimensions, item 2 of newDimensions}
end tell
end tell
end alfred_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment