Skip to content

Instantly share code, notes, and snippets.

@somebody32
Created February 17, 2019 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somebody32/b1a7564298ff5bd82decd0fbbbfe83a3 to your computer and use it in GitHub Desktop.
Save somebody32/b1a7564298ff5bd82decd0fbbbfe83a3 to your computer and use it in GitHub Desktop.
Fluent typing effect with Automator
const sysEvents = Application("System Events");
sysEvents.includeStandardAdditions = true;
function typeWithDelay(text, delayValue = 0.02) {
if (delayValue) {
for (let i = 0; i < text.length; i++) {
sysEvents.keystroke(text[i]);
delay(delayValue);
}
} else {
sysEvents.keystroke(text);
}
}
function run(input, parameters) {
const stringToType = 'This string will be typed with a small delay between keystrokes ' +
'and then clipboard will be pasted ';
typeWithDelay(stringToType);
typeWithDelay(sysEvents.theClipboard(), false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment