Exemplo n.º 1
0
def bring_add(launch, key):
    '''
    Add current program or highlighted text to bring me
    '''
    key = str(key)
    if launch == "program":
        path = utilities.get_active_window_path()
        if not path:
            # dragonfly.get_engine().speak("program not detected")
            print("Program path for bring me not found ")
    # elif launch == 'file':
    # no way to add file via pyperclip
    else:
        Key("a-d/5").execute()
        fail, path = context.read_selected_without_altering_clipboard()
        if fail == 2:
            #FIXME
            time.sleep(0.1)
            _, path = context.read_selected_without_altering_clipboard()
            if not path:
                # dragonfly.get_engine().speak("nothing selected")
                print("Selection for bring me not found ")
        Key("escape").execute()
    if not path:
        #logger.warn('Cannot add %s as %s to bringme: cannot get path', launch, key)
        return
    CONFIG[launch][key] = path
    utilities.save_toml_file(CONFIG, settings.SETTINGS["paths"]["BRINGME_PATH"])
    refresh()
Exemplo n.º 2
0
def toggle():
    if natlink.getMicState()!="on":
        return
    
    '''determines whether to toggle and then if so toggles appropriately'''
    global _LAST, _HAS_RUN_FIRST_TIME, _ON, _OFF
    should_toggle = False
    if not _HAS_RUN_FIRST_TIME:
        should_toggle = True
        _HAS_RUN_FIRST_TIME = True
    
    if not settings.SETTINGS["auto_com"]["change_language_only"]:
        current_window = utilities.get_active_window_path(natlink).split("\\")[-1]
        should_be_on = current_window in settings.SETTINGS["auto_com"]["executables"]
        should_toggle = should_be_on != _LAST
        _LAST = should_be_on
        
        if should_toggle:
            e = _ON if _LAST else _OFF
            e.execute()
            
    
    # language switching section
    if settings.SETTINGS["auto_com"]["change_language"]:
        language.toggle_language()
Exemplo n.º 3
0
def bring_add(launch, key):
    '''
    Add current program or highlighted text to bring me
    '''
    key = str(key)
    if launch == "program":
        path = utilities.get_active_window_path()
        if not path:
            # dragonfly.get_engine().speak("program not detected")
            print("Program path for bring me not found ")
    # elif launch == 'file':
    # no way to add file via pyperclip
    else:
        Key("a-d/5").execute()
        fail, path = context.read_selected_without_altering_clipboard()
        if fail == 2:
            #FIXME
            time.sleep(0.1)
            _, path = context.read_selected_without_altering_clipboard()
            if not path:
                # dragonfly.get_engine().speak("nothing selected")
                print("Selection for bring me not found ")
        Key("escape").execute()
    if not path:
        #logger.warn('Cannot add %s as %s to bringme: cannot get path', launch, key)
        return
    CONFIG[launch][key] = path
    utilities.save_toml_file(CONFIG,
                             settings.SETTINGS["paths"]["BRINGME_PATH"])
    refresh()
Exemplo n.º 4
0
 def _execute(self, data=None):
     if control.nexus().dep.NATLINK:
         executable = utilities.get_active_window_path(natlink).split("\\")[-1]
         is_executable = executable in self.executables
         if (is_executable and not self.negate) or (self.negate and not is_executable):
             self.action._execute()
     else:
         utilities.availability_message("SelectiveAction", "natlink")
         self.action._execute()
Exemplo n.º 5
0
 def _toggle(self):
     if self.is_natlink and natlink.getMicState()!="on":
         return
     
     '''determines whether to toggle and then if so toggles appropriately'''
     should_toggle = False
     if not self._has_run_first_time:
         should_toggle = True
         self._has_run_first_time = True
     if not settings.SETTINGS["auto_com"]["change_language_only"]:
         current_window = utilities.get_active_window_path().split("\\")[-1]
         should_be_on = current_window in settings.SETTINGS["auto_com"]["executables"]
         should_toggle = should_be_on != self._last
         self._last = should_be_on
     
         if should_toggle:
             e = self._ON if self._last else self._OFF
             e.execute()
     
     '''language switching section'''
     if settings.SETTINGS["auto_com"]["change_language"]:
         self._toggle_language()
Exemplo n.º 6
0
def toggle():
    if control.nexus().dep.NATLINK and natlink.getMicState() != "on":
        return
    '''determines whether to toggle and then if so toggles appropriately'''
    global _LAST, _HAS_RUN_FIRST_TIME, _ON, _OFF
    should_toggle = False
    if not _HAS_RUN_FIRST_TIME:
        should_toggle = True
        _HAS_RUN_FIRST_TIME = True

    if not settings.SETTINGS["auto_com"]["change_language_only"]:
        current_window = utilities.get_active_window_path().split("\\")[-1]
        should_be_on = current_window in settings.SETTINGS["auto_com"][
            "executables"]
        should_toggle = should_be_on != _LAST
        _LAST = should_be_on

        if should_toggle:
            e = _ON if _LAST else _OFF
            e.execute()

    # language switching section
    if settings.SETTINGS["auto_com"]["change_language"]:
        language.toggle_language()
Exemplo n.º 7
0
 def _execute(self, data=None):
     executable = utilities.get_active_window_path().split("\\")[-1]
     is_executable = executable in self.executables
     if (is_executable and not self.negate) or (self.negate
                                                and not is_executable):
         self.action.execute()
Exemplo n.º 8
0
 def _execute(self, data=None):
     executable = utilities.get_active_window_path().split("\\")[-1]
     is_executable = executable in self.executables
     if (is_executable and not self.negate) or (self.negate and not is_executable):
         self.action.execute()