Skip to content

Instantly share code, notes, and snippets.

@mitchellsimoens
Created June 30, 2014 19:51
Show Gist options
  • Save mitchellsimoens/a1d16257fc64f2912d86 to your computer and use it in GitHub Desktop.
Save mitchellsimoens/a1d16257fc64f2912d86 to your computer and use it in GitHub Desktop.
Automate text with AppleScript in Sencha Fiddle. Must have fiddle open and active tab, could do but meh
on theSplit(theString, theDelimiter)
-- save delimiters to restore old settings
set oldDelimiters to AppleScript's text item delimiters
-- set delimiters to delimiter to be used
set AppleScript's text item delimiters to theDelimiter
-- create the array
set theArray to every text item of theString
-- restore the old setting
set AppleScript's text item delimiters to oldDelimiters
-- return the result
return theArray
end theSplit
activate application "Google Chrome"
tell application "Google Chrome" to tell active tab of window 1
execute javascript "document.getElementsByTagName('textarea')[0].focus()"
end tell
delay 1
set toType to my theSplit("Ext.Msg.alert('', 'Mitch Rocks!')", "")
tell application "System Events"
keystroke "a" using command down
delay 0.5
keystroke (ASCII character 8)
delay 1
repeat with characterType in toType
keystroke characterType
delay 0.1
end repeat
keystroke return using command down
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment