Beispiel #1
0
def stoosh_keep_clipboard(nnavi500, nexus):
    if nnavi500 == 1:
        Key("c-c").execute()
    else:
        max_tries = 20
        cb = Clipboard(from_system=True)
        Key("c-c").execute()
        key = str(nnavi500)
        for i in range(0, max_tries):
            failure = False
            try:
                # time for keypress to execute
                time.sleep(
                    settings.SETTINGS["miscellaneous"]["keypress_wait"] /
                    1000.)
                nexus.clip[key] = Clipboard.get_system_text()
                utilities.save_toml_file(
                    nexus.clip,
                    settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"])
            except Exception:
                failure = True
                utilities.simple_log()
            if not failure:
                break
        cb.copy_to_system()
Beispiel #2
0
def duple_keep_clipboard(nnavi50):
    cb = Clipboard(from_system=True)
    Key("escape, home, s-end, c-c, end").execute()
    time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/1000.)
    for i in range(0, nnavi50):
        Key("enter, c-v").execute()
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/1000.)
    cb.copy_to_system()
Beispiel #3
0
def duple_keep_clipboard(nnavi50):
    cb = Clipboard(from_system=True)
    Key("escape, home, s-end, c-c, end").execute()
    time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.)
    for i in range(0, nnavi50):
        Key("enter, c-v").execute()
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.)
    cb.copy_to_system()
Beispiel #4
0
def read_selected_without_altering_clipboard(same_is_okay=False):
    '''Returns a tuple:
    (0, "text from system") - indicates success
    (1, None) - indicates no change
    (2, None) - indicates clipboard error
    '''
    time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] /
               1000.)  # time for previous keypress to execute
    cb = Clipboard(from_system=True)
    temporary = None
    prior_content = None
    try:

        prior_content = Clipboard.get_system_text()
        Clipboard.set_system_text("")

        Key("c-c").execute()
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] /
                   1000.)  # time for keypress to execute
        temporary = Clipboard.get_system_text()
        cb.copy_to_system()

    except Exception:
        utilities.simple_log(False)
        return 2, None
    if prior_content == temporary and not same_is_okay:
        return 1, None
    return 0, temporary
Beispiel #5
0
def drop_keep_clipboard(nnavi500, nexus, capitalization, spacing):
    # Maintain standard spark functionality for non-strings
    if capitalization == 0 and spacing == 0 and nnavi500 == 1:
        Key("c-v").execute()
        return
    # Get clipboard text
    if nnavi500 > 1:
        key = str(nnavi500)
        if key in nexus.clip:
            text = nexus.clip[key]
        else:
            dragonfly.get_engine().speak("slot empty")
            text = None
    else:
        text = Clipboard.get_system_text()
    # Format if necessary, and paste
    if text is not None:
        cb = Clipboard(from_system=True)
        if capitalization != 0 or spacing != 0:
            text = textformat.TextFormat.formatted_text(
                capitalization, spacing, text)
        Clipboard.set_system_text(text)
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.)
        Key("c-v").execute()
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.)
        # Restore the clipboard contents.
        cb.copy_to_system()
Beispiel #6
0
def read_selected_without_altering_clipboard(same_is_okay=False):
    '''Returns a tuple:
    (0, "text from system") - indicates success
    (1, None) - indicates no change
    (2, None) - indicates clipboard error
    '''
    time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/
               1000.)  # time for previous keypress to execute
    cb = Clipboard(from_system=True)
    temporary = None
    prior_content = None
    try:

        prior_content = Clipboard.get_system_text()
        Clipboard.set_system_text("")

        Key("c-c").execute()
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/
                   1000.)  # time for keypress to execute
        temporary = Clipboard.get_system_text()
        cb.copy_to_system()

    except Exception:
        utilities.simple_log(False)
        return 2, None
    if prior_content == temporary and not same_is_okay:
        return 1, None
    return 0, temporary
Beispiel #7
0
def paste_string_without_altering_clipboard(content):
    '''
    True - indicates success
    False - indicates clipboard error
    '''
    time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/
               1000.)  # time for previous keypress to execute
    cb = Clipboard(from_system=True)

    try:
        Clipboard.set_system_text(str(content))

        Key("c-v").execute()
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/
                   1000.)  # time for keypress to execute
        cb.copy_to_system()

    except Exception:
        utilities.simple_log(False)
        return False
    return True
Beispiel #8
0
def drop_keep_clipboard(nnavi500, nexus, capitalization, spacing):
    # Maintain standard spark functionality for non-strings
    if capitalization == 0 and spacing == 0 and nnavi500 == 1:
        Key("c-v").execute()
        return
    # Get clipboard text
    if nnavi500 > 1:
        key = str(nnavi500)
        if key in nexus.clip:
            text = nexus.clip[key]
        else:
            dragonfly.get_engine().speak("slot empty")
            text = None
    else:
        text = Clipboard.get_system_text()
    # Format if necessary, and paste
    if text is not None:
        cb = Clipboard(from_system=True)
        if capitalization != 0 or spacing != 0:
            text = textformat.TextFormat.formatted_text(capitalization, spacing, text)
        Clipboard.set_system_text(text)
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/1000.)
        Key("c-v").execute()
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/1000.)
        # Restore the clipboard contents.
        cb.copy_to_system()
Beispiel #9
0
def stoosh_keep_clipboard(nnavi500, nexus):
    if nnavi500 == 1:
        Key("c-c").execute()
    else:
        max_tries = 20
        cb = Clipboard(from_system=True)
        Key("c-c").execute()
        key = str(nnavi500)
        for i in range(0, max_tries):
            failure = False
            try:
                # time for keypress to execute
                time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/1000.)
                nexus.clip[key] = Clipboard.get_system_text()
                utilities.save_toml_file(
                    nexus.clip, settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"])
            except Exception:
                failure = True
                utilities.simple_log()
            if not failure:
                break
        cb.copy_to_system()
Beispiel #10
0
def paste_string_without_altering_clipboard(content):
    '''
    True - indicates success
    False - indicates clipboard error
    '''
    time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] /
               1000.)  # time for previous keypress to execute
    cb = Clipboard(from_system=True)

    try:
        Clipboard.set_system_text(str(content))

        Key("c-v").execute()
        time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] /
                   1000.)  # time for keypress to execute
        cb.copy_to_system()

    except Exception:
        utilities.simple_log(False)
        return False
    return True