def copy_modify_paste(modifying_function): selected_text = utils.getSelectedText() if not selected_text: print "No selected text?" return modified_text = modifying_function(str(selected_text)) # tried to use the original clipboard here, but couldn't get it to "clear" -- some apps would # somehow get the original, unmodified text when the paste happened new_clipboard = Clipboard() new_clipboard.set_text(modified_text) new_clipboard.copy_to_system() Key("c-v").execute()
def save_to_clipboard(text): """Stores text to the clipboard""" clipboard = Clipboard(from_system=True) clipboard.set_text(text) clipboard.copy_to_system()
def reverse_clip(): """Reverses the most recent clipboard item""" clip = text_clip() clipboard = Clipboard(from_system=True) clipboard.set_text(clip[::-1]) clipboard.copy_to_system()
def restore_clip(): """Restores the most recent clipboard item""" global clip clipboard = Clipboard(from_system=True) clipboard.set_text(clip) clipboard.copy_to_system()