Created
August 27, 2014 03:47
-
-
Save cvson/74f9ed5afc565e144b55 to your computer and use it in GitHub Desktop.
Automatically screenshot webpage with AppleScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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