Forked from sscotth/keystroke the clipboard extended.workflow
Created
May 7, 2020 16:01
-
-
Save carlchan/24595bfe9f509af4f8947948b6d9a59a to your computer and use it in GitHub Desktop.
Paste as keystrokes (macOS)
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
# Why? | |
# To paste text into windows that normally don't allow it or have access to the clipboard. | |
# Examples: Virtual machines that do not yet have tools installed, websites that highjack paste | |
# | |
# How? | |
# Create a service: open Automator, create new service, receive no input, use any application, run applescript code below, save | |
# Activate: open application menu from menu bar, go to services, and you will see your service | |
on run | |
tell application "System Events" | |
delay 1 | |
keystroke (the clipboard) | |
beep | |
end tell | |
end run |
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
# Why? | |
# To paste text into windows that normally don't allow it or have access to the clipboard. | |
# Examples: Virtual machines that do not yet have tools installed, websites that highjack paste | |
# | |
# How? | |
# Create a service: open Automator, create new service, receive no input, use any application, run applescript code below, save | |
# Activate: open application menu from menu bar, go to services, and you will see your service | |
on run | |
tell application "System Events" | |
delay 2 # DELAY BEFORE BEGINNING KEYPRESSES IN SECONDS | |
repeat with char in (the clipboard) | |
# Converts numbers to ANSI_# characters rather than ANSI_Keypad# characters | |
# https://apple.stackexchange.com/questions/142986/applescript-keystroke-ignoring-numbers | |
set cID to id of char | |
if ((cID ≥ 48) and (cID ≤ 57)) then | |
key code {item (cID - 47) of {29, 18, 19, 20, 21, 23, 22, 26, 28, 25}} | |
else | |
keystroke char | |
end if | |
delay 0.5 # DELAY BETWEEEN EACH KEYPRESS IN SECONDS | |
end repeat | |
beep | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment