Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Makes auto complete google search gifs, needs gifsicle
--needs gifsicle http://www.lcdf.org/gifsicle/
-- updated for retina screen
set thetext to text returned of (display dialog "What do you want to autocomplete?" default answer "I hate")
set theFileName to change_case_of(thetext, "lower") & ".gif"
set tempdir to POSIX path of (path to temporary items from user domain) & "autogifs/"
try
do shell script "mkdir " & tempdir
end try
set alphabet to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
set vowels to "aeiou"
tell application "Safari"
activate
tell application "System Events"
tell process "Safari"
click menu item "New Private Window" of menu "File" of menu bar 1
end tell
end tell
set bounds of window 1 to {0, 0, 800, 600}
set the URL of the front document to "http://google.co.uk"
delay 5
tell application "System Events"
keystroke thetext
end tell
repeat with letter in alphabet
set typing to " " & letter
set tfile to tempdir & letter & ".gif"
tell application "System Events"
keystroke typing
delay 1
do shell script "screencapture -t GIF " & tfile
keystroke (ASCII character 8)
keystroke (ASCII character 8)
end tell
end repeat
end tell
if isRetina() then
do shell script "/usr/local/bin/gifsicle --delay 90 --colors 128 --loopcount --crop 0,200+1600x320 --resize 800x160 " & tempdir & "* > ~/Desktop/" & theFileName
else
do shell script "/usr/local/bin/gifsicle --delay 90 --colors 128 --loopcount ---crop 0,100+800x160 " & tempdir & "* > ~/Desktop/" & theFileName
end if
--
--clean up
do shell script "rm -rf " & tempdir
--do shell script "open " & tempdir
on isRetina()
set ret to (do shell script "system_profiler SPDisplaysDataType | awk '/Retina:/{print $2}'")
if ret is "Yes" then
return true
else
return false
end if
end isRetina
on change_case_of(this_text, this_case)
if this_case is "lower" then
set the comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ "
set the source_string to "abcdefghijklmnopqrstuvwxyz_"
else
set the comparison_string to "abcdefghijklmnopqrstuvwxyz"
set the source_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
end if
set the new_text to ""
repeat with thisChar in this_text
set x to the offset of thisChar in the comparison_string
if x is not 0 then
set the new_text to (the new_text & character x of the source_string) as string
else
set the new_text to (the new_text & thisChar) as string
end if
end repeat
return the new_text
end change_case_of
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment