1

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.

user598527
  • 175
  • 13

1 Answers1

3

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)
Little Girl
  • 168
  • 6