Skip to content

Instantly share code, notes, and snippets.

@trevor-atlas
Created June 30, 2023 20:29
Show Gist options
  • Save trevor-atlas/17746a243dd9bbfa8062d8fb86b5fc20 to your computer and use it in GitHub Desktop.
Save trevor-atlas/17746a243dd9bbfa8062d8fb86b5fc20 to your computer and use it in GitHub Desktop.
// Name: humanlike typing
// Description: Type the contents of your clipboard as if you were a human
// Author: Trevor Atlas
// Twitter: @trevoratlas
import "@johnlindquist/kit"
await hide();
await applescript(String.raw`
set texttowrite to the clipboard as text
tell application "System Events"
repeat with i from 1 to count characters of texttowrite
if (character i of texttowrite) is equal to linefeed or (character i of texttowrite) is equal to return & linefeed or (character i of texttowrite) is equal to return then
keystroke return
else
keystroke (character i of texttowrite)
end
if (character i of texttowrite) is equal to " " then
delay (random number from 0.01 to 0.1)
else if (character i of texttowrite) is equal to "\n" then
delay (random number from 0.1 to 0.3)
else
delay (random number from 0.01 to 0.05)
end
end repeat
end tell
`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment