1
votes

I use the following script to add apostrophes ' around text when a specified hotkey is pressed:

text = clipboard.get_selection()
keyboard.send_key("<delete>")
keyboard.send_keys("'%s'" % text)

Changing the last line to keyboard.send_keys(""%s"" % text) doesn't work -- presumably the quotes have to be escaped.

1
keyboard.send_keys("ā€œ%sā€" % text) doesn't work either. ā€“ user598527

1 Answers

3
votes

You need to use backslash escapes before the quotes that will be wrapped around the selected text:

text = clipboard.get_selection()
keyboard.send_keys("\"%s\"" % text)