コード例 #1
0
ファイル: action_paste.py プロジェクト: LexiconCode/dragonfly
    def _execute_events(self, events):
        original = Clipboard()
        try:
            original.copy_from_system()
        except Exception as e:
            self._log.warning(
                "Failed to store original clipboard contents:"
                " %s", e)

        # Store the contents to copy (i.e. *events*) in a Clipboard
        #  instance using the specified (or default) format.  If *events* is
        #  a dictionary, then pass it instead.
        if isinstance(events, dict):
            clipboard = Clipboard(contents=events)
        else:
            clipboard = Clipboard(contents={self.format: events})

        # Copy the contents to the system clipboard and paste using the
        #  paste action.
        clipboard.copy_to_system()
        self.paste.execute()

        # Restore the original clipboard contents afterwards.  This should
        #  clear the clipboard if we failed to store the original contents
        #  above.
        original.copy_to_system()
        return True
コード例 #2
0
def SendCommandToClickByVoiceDragon(command):
    def go():
        temporary = Clipboard({Clipboard.format_text: command})
        temporary.copy_to_system()
        DragonKey('cs-dot/10').execute()

    try:
        original = Clipboard(from_system=True)
        go()
        original.copy_to_system()
    except Exception as e:
        go()
コード例 #3
0
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()
コード例 #4
0
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()
コード例 #5
0
def readSelected():
	clipBoardInstance = Clipboard(from_system=True)
	# make a temporary clipboard, with the message didn't found selected text, and clone it to system.
	temporary = Clipboard({Clipboard.format_unicode: u"didn't found selected text."})
	temporary.copy_to_system()

	# copy new text to this set clipboard. If no text selected the text "didn't found selected text." remains on clipboard
 	Key("c-c/25").execute()
 	text = Clipboard(from_system=True).get_text()
	sayOutLoud(text.encode('utf8'))

	# set the first obtained clipboard back to the system.
	clipBoardInstance.copy_to_system()
コード例 #6
0
    def _execute_events(self, events):
        original = Clipboard()
        original.copy_from_system()

        if self.format == win32con.CF_UNICODETEXT:
            events = unicode(events)
        elif self.format == win32con.CF_TEXT:
            events = str(events)

        clipboard = Clipboard(contents={self.format: events})
        clipboard.copy_to_system()
        self.paste.execute()

        original.copy_to_system()
        return True
コード例 #7
0
    def _execute_events(self, events):
        original = Clipboard()
        original.copy_from_system()

        if self.format == win32con.CF_UNICODETEXT:
            events = unicode(events)
        elif self.format == win32con.CF_TEXT:
            events = str(events)

        clipboard = Clipboard(contents={self.format: events})
        clipboard.copy_to_system()
        self.paste.execute()

        original.copy_to_system()
        return True
コード例 #8
0
ファイル: utils.py プロジェクト: haughki/MyDragonflyModules
def getSelectedText():
    """ Get the currently selected text by copying it to the clipboard and pulling it from there.
    Preserve the original clipboard state. """
    original = Clipboard(from_system=True)
    
    # print "original before copy: " + original.get_text()
    
    Key("c-c/5").execute()
    # note that trying to re-use this clipboard object after it's been
    # modified has caused me issues in the past -- seems to hold onto old values...
    just_copied = Clipboard()
    just_copied.copy_from_system()
    
    # print "original after copy: " + original.get_text()
    # print "just copied before original copy back: " + just_copied.get_text()
    
    original.copy_to_system()  # restore the state of the clipboard

    return just_copied.get_text()
コード例 #9
0
ファイル: utils.py プロジェクト: haughki/MyDragonflyModules
def getSelectedText():
    """ Get the currently selected text by copying it to the clipboard and pulling it from there.
    Preserve the original clipboard state. """
    original = Clipboard(from_system=True)
    
    # print "original before copy: " + original.get_text()
    
    Key("c-c/5").execute()
    # note that trying to re-use this clipboard object after it's been
    # modified has caused me issues in the past -- seems to hold onto old values...
    just_copied = Clipboard()
    just_copied.copy_from_system()
    
    # print "original after copy: " + original.get_text()
    # print "just copied before original copy back: " + just_copied.get_text()
    
    original.copy_to_system()  # restore the state of the clipboard

    return just_copied.get_text()
コード例 #10
0
 def go():
     temporary = Clipboard({Clipboard.format_text: command})
     temporary.copy_to_system()
     DragonKey('cs-dot/10').execute()
コード例 #11
0
def save_to_clipboard(text):
    """Stores text to the clipboard"""
    clipboard = Clipboard(from_system=True)
    clipboard.set_text(text)
    clipboard.copy_to_system()
コード例 #12
0
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()
コード例 #13
0
def restore_clip():
    """Restores the most recent clipboard item"""
    global clip
    clipboard = Clipboard(from_system=True)
    clipboard.set_text(clip)
    clipboard.copy_to_system()
コード例 #14
0
ファイル: clipboard.py プロジェクト: barrysims/dragonfly
def save_to_clipboard(text):
    """Stores text to the clipboard"""
    clipboard = Clipboard(from_system=True)
    clipboard.set_text(text)
    clipboard.copy_to_system()
コード例 #15
0
ファイル: clipboard.py プロジェクト: barrysims/dragonfly
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()
コード例 #16
0
ファイル: clipboard.py プロジェクト: barrysims/dragonfly
def restore_clip():
    """Restores the most recent clipboard item"""
    global clip
    clipboard = Clipboard(from_system=True)
    clipboard.set_text(clip)
    clipboard.copy_to_system()