Skip to content

Instantly share code, notes, and snippets.

@cvson
Created August 27, 2014 03:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvson/74f9ed5afc565e144b55 to your computer and use it in GitHub Desktop.
Save cvson/74f9ed5afc565e144b55 to your computer and use it in GitHub Desktop.
Automatically screenshot webpage with AppleScript
-- set file name
set fileNames to "webshot-googleAnalytics"
tell application "Google Chrome"
-- open window with secret mode, if with normal mode then use {mode:"normal"}
set aWin to make new window with properties {mode:"normal"}
tell aWin
-- open new tab and set URL
set newTab to make new tab with properties {URL:"https://www.google.com/analytics/web/?et=&authuser=#report/visitors-overview/a38108925w74194420p76615924/"}
tell active tab
repeat -- wait completion of loading
set curStat to loading
if curStat = false then exit repeat
delay 0.1
end repeat
tell application "Google Chrome" to activate
delay 3.0
--full screen
tell application "System Events"
keystroke "f" using {command down, shift down}
end tell
end tell
delay 6.0
set saveDir to "Macintosh HD:Users:cvson:Dropbox:Public:vilib-ana:"
set picPath to ((POSIX path of saveDir) & fileNames & ".jpg") as string
--screencapture
do shell script "screencapture -tjpg " & quoted form of picPath
end tell
close aWin
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment