def scan_directory(nexus): on_complete = AsynchronousAction.hmc_complete(lambda data: _scan_directory(data, nexus), nexus) h_launch.launch(settings.QTYPE_DIRECTORY) AsynchronousAction([L(S(["cancel"], on_complete))], time_in_seconds=0.5, repetitions=300, blocking=False).execute()
def add_vocab(): engine = dragonfly.get_engine() if engine.name != "natlink": utilities.report( "feature unavailable in your speech recognition engine", speak=True) return # attempts to get what was highlighted first highlighted = context.read_selected_without_altering_clipboard(True) # change the following regex to accept alphabetical only disallow = "^[A-Za-z]*$" selected = None if highlighted[0] == 0 and highlighted[1] != "": if not re.match(disallow, highlighted[1]): utilities.report("only used for single words", speak=True) return selected = highlighted[1] try: h_launch.launch(settings.QTYPE_SET, process_set, selected) except Exception: utilities.simple_log(False)
def settings_window(): # if control.nexus().dep.WX: if not utilities.window_exists( None, settings.STATUS_WINDOW_TITLE + settings.SOFTWARE_VERSION_NUMBER): h_launch.launch(settings.WXTYPE_SETTINGS, get_settings_from_settings_window)
def settings_window(nexus): h_launch.launch(settings.WXTYPE_SETTINGS) on_complete = AsynchronousAction.hmc_complete( lambda data: receive_settings(data), nexus) AsynchronousAction([L(S(["cancel"], on_complete))], time_in_seconds=1, repetitions=300, blocking=False).execute()
def settings_window(nexus): h_launch.launch(settings.WXTYPE_SETTINGS) on_complete = AsynchronousAction.hmc_complete(lambda data: receive_settings(data), nexus) AsynchronousAction( [L(S(["cancel"], on_complete))], time_in_seconds=1, repetitions=300, blocking=False).execute()
def chain_alias(self): text = read_highlighted(10) if text is not None: h_launch.launch(settings.QTYPE_INSTRUCTIONS, data="Enter_spec_for_command|") on_complete = AsynchronousAction.hmc_complete(lambda data: self.refresh(data[0].replace("\n", ""), text), self.nexus) AsynchronousAction([L(S(["cancel"], on_complete, None))], time_in_seconds=0.5, repetitions=300, blocking=False).execute()
def _execute(self, data=None): '''the factory (ConfirmAction) sharing data with the objects it generates (StackItemConfirm) would be a problem if there could ever be more than one of these at a time, but there can't''' self.mutable_integer["value"] = 0 confirm_stack_item = StackItemConfirm(self, data) confirm_stack_item.shared_state(self.mutable_integer) h_launch.launch(settings.QTYPE_CONFIRM, data=settings.HMC_SEPARATOR.join(self.instructions.split(" "))) self.nexus().state.add(confirm_stack_item)
def chain_alias(self): text = read_highlighted(10) if text is not None: h_launch.launch(settings.QTYPE_INSTRUCTIONS, data="Enter_spec_for_command|") on_complete = AsynchronousAction.hmc_complete( lambda data: self.refresh(data[0].replace("\n", ""), text), self.nexus) AsynchronousAction( [L(S(["cancel"], on_complete))], time_in_seconds=0.5, repetitions=300, blocking=False).execute()
def record_from_history(): # save the list as it was when the command was spoken control.nexus().preserved = control.nexus().history[:] # format for display formatted = "" for t in control.nexus().preserved: for w in t: formatted += w.split("\\")[0] + "[w]" formatted += "[s]" h_launch.launch(settings.QTYPE_RECORDING, add_recorded_macro, formatted)
def get_chain_alias_spec(): global MESSAGE_SPLITTER result=None copy_worked=False for i in range(0, 10): result=context.read_selected_without_altering_clipboard(True) if result[0]==0: copy_worked=True break if copy_worked==True: h_launch.launch(settings.QTYPE_INSTRUCTIONS, chain_alias, "Enter_spec_for_command|" + MESSAGE_SPLITTER.join(result[1].split())) else: utilities.report("copy failed")
def _execute(self, data=None): '''the factory (ConfirmAction) sharing data with the objects it generates (StackItemConfirm) would be a problem if there could ever be more than one of these at a time, but there can't''' self.mutable_integer["value"] = 0 confirm_stack_item = StackItemConfirm(self, data) confirm_stack_item.shared_state(self.mutable_integer) h_launch.launch(settings.QTYPE_CONFIRM, data=settings.HMC_SEPARATOR.join( self.instructions.split(" "))) self.nexus().state.add(confirm_stack_item)
def _execute(self, data=None): confirm_stack_item = self.state.generate_confirm_stack_item(self, data) self.mutable_integer["value"] = 0 mutable_integer = self.mutable_integer def hmc_closure(data): ''' receives response from homunculus, uses it to stop the stack and tell the ConfirmAction how to execute ''' mutable_integer["value"] = data["confirm"] confirm_stack_item.receive_hmc_response(data["confirm"]) h_launch.launch(settings.QTYPE_CONFIRM, hmc_closure, "_".join(self.rdescript.split(" "))) self.state.add(confirm_stack_item)
def get_chain_alias_spec(): global MESSAGE_SPLITTER result = None copy_worked = False for i in range(0, 10): result = context.read_selected_without_altering_clipboard(True) if result[0] == 0: copy_worked = True break if copy_worked == True: h_launch.launch( settings.QTYPE_INSTRUCTIONS, chain_alias, "Enter_spec_for_command|" + MESSAGE_SPLITTER.join(result[1].split())) else: utilities.report("copy failed")
def record_from_history(self): # save the list as it was when the command was spoken self.nexus.preserved = self.nexus.history[:] # format for display formatted = "" for t in self.nexus.preserved: for w in t: formatted += w.split("\\")[0] + "[w]" formatted += "[s]" # use a response window to get a spec and word sequences for the new macro h_launch.launch(settings.QTYPE_RECORDING, data=formatted) on_complete = AsynchronousAction.hmc_complete(lambda data: self.add_recorded_macro(data), self.nexus) AsynchronousAction([L(S(["cancel"], on_complete))], time_in_seconds=0.5, repetitions=300, blocking=False).execute()
def add_vocab(): engine=dragonfly.get_engine() if engine.name!="natlink": utilities.report("feature unavailable in your speech recognition engine", speak=True) return # attempts to get what was highlighted first highlighted=context.read_selected_without_altering_clipboard(True) # change the following regex to accept alphabetical only disallow="^[A-Za-z]*$" selected=None if highlighted[0]==0 and highlighted[1]!="": if not re.match(disallow, highlighted[1]): utilities.report("only used for single words", speak=True) return selected=highlighted[1] try: h_launch.launch(settings.QTYPE_SET, process_set, selected) except Exception: utilities.simple_log(False)
def settings_window(): # if control.nexus().dep.WX: if not utilities.window_exists(None, settings.STATUS_WINDOW_TITLE + settings.SOFTWARE_VERSION_NUMBER): h_launch.launch(settings.WXTYPE_SETTINGS, get_settings_from_settings_window)
def get_macro_spec(): h_launch.launch(settings.QTYPE_DEFAULT, add_recorded_macro, None)
def scan_directory(): h_launch.launch(settings.QTYPE_DIRECTORY, _scan_directory, None)
def settings_window(nexus): if not utilities.window_exists(None, settings.STATUS_WINDOW_TITLE + settings.SOFTWARE_VERSION_NUMBER): h_launch.launch(settings.WXTYPE_SETTINGS) on_complete = AsynchronousAction.hmc_complete(lambda data: receive_settings(data), nexus) AsynchronousAction([L(S(["cancel"], on_complete))], time_in_seconds=1, repetitions=300, blocking=False).execute()
def _execute(self, data=None): self._["tries"] = 0 # reset self._["dragonfly_data"] = data h_launch.launch(self.box_type, data = self.encode_box_settings()) self.nexus().state.add(StackItemAsynchronous(self, data))
def _execute(self, data=None): self._["tries"] = 0 # reset self._["dragonfly_data"] = data h_launch.launch(self.box_type, data=self.encode_box_settings()) self.nexus().state.add(StackItemAsynchronous(self, data))
def del_vocab(): try: h_launch.launch(settings.QTYPE_REM, process_delete, None) except Exception: utilities.simple_log(False)