--this is an applescript for generating animated gifs from a series of screenshots automatically snapped through safari of the google autocomplete for a search. Some examples: Social Media is

--needs gifsicle http://www.lcdf.org/gifsicle/


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 Window" of menu "File" of menu bar 1

end tell

end tell

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


do shell script "/usr/local/bin/gifsicle --delay 90 --colors 128 --loopcount --crop 0,100+800x160 " & tempdir & "* > ~/Desktop/" & theFileName

--

--clean up

do shell script "rm -rf " & tempdir

--do shell script "open " & tempdir




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