Created
April 17, 2023 03:30
-
-
Save user52839307/3b1ca96f1bf18d816beb86b30d39279b to your computer and use it in GitHub Desktop.
This AppleScript emulates typing by outputting the contents of the clipboard with a delay between each keystroke.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
This AppleScript emulates typing by outputting the contents of the clipboard | |
with a delay between each keystroke, making it appear more like actual human typing. | |
The script retrieves the formatted clipboard contents as plain text and outputs each character | |
as a keystroke with a 0.1 second delay using the `keystroke` and `delay` commands in a `repeat` loop. | |
You can adjust the delay time to be shorter or longer by changing the value in the delay command. | |
*) | |
-- Get the formatted clipboard contents as plain text | |
set clipboardText to (get the clipboard as «class utf8») as text | |
-- Use a repeat loop to iterate over each character in the clipboard text | |
tell application "System Events" | |
repeat with i from 1 to length of clipboardText | |
-- Output the current character as a keystroke | |
keystroke (character i of clipboardText) | |
-- Add a delay of 0.1 seconds between each keystroke | |
delay 0.1 | |
end repeat | |
end tell |
To preserve line breaks you can omit the «class utf8»
as follows.
-- Get the clipboard contents as text
set clipboardText to the clipboard as text
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To bind this to a keyboard shortcut with built-in OSX utilities you can follow this guide.
http://blog.fosketts.net/2010/08/09/assign-keyboard-shortcut-applescript-automator-service/
Otherwise, you can use a third-party program that lets you set custom hotkeys such as: BetterTouchTool, Keyboard Maestro, or Hammerspoon.
This has been tested with BetterTouchTool.