def kill_grids_and_wait(): window_title = utilities.get_active_window_title() if (window_title == settings.RAINBOW_TITLE or window_title == settings.DOUGLAS_TITLE or window_title == settings.LEGION_TITLE): control.nexus().comm.get_com("grids").kill() time.sleep(0.1)
def _activate_grammar(self, rule_name): # TODO: This is a hack. `_change_rule_enabled` should only be accessed in the grammar_manager try: if str(rule_name) == "CasterMicRule": control.nexus()._grammar_manager._change_rule_enabled( "CasterMicRule", True) if str(rule_name) == "DictationSinkRule": control.nexus()._grammar_manager._change_rule_enabled( "DictationSinkRule", True) self._get_grammars_loaded() except MimicFailure as e: printer.out("Caster: {}".format(e))
class CasterRule(MappingRule): mapping = { "clear caster log": R(Function(utilities.clear_log)), "reboot caster": R(Function(utilities.reboot)), # ccr de/activation "enable (c c r|ccr)": R(Function(lambda: control.nexus().set_ccr_active(True))), "disable (c c r|ccr)": R(Function(lambda: control.nexus().set_ccr_active(False))), }
class CasterRule(MappingRule): mapping = { # update management ToDo: Fully implement castervoice PIP install #"update caster": # R(_DependencyUpdate([_PIP, "install", "--upgrade", "castervoice"])), "update dragonfly": R(_DependencyUpdate([_PIP, "install", "--upgrade", "dragonfly2"])), # ccr de/activation "enable c c r": R(Function(lambda: control.nexus().set_ccr_active(True))), "disable c c r": R(Function(lambda: control.nexus().set_ccr_active(False))), }
def move_mouse(n, s, action): sudoku = control.nexus().comm.get_com("grids") sudoku.move_mouse(int(n), int(s)) sudoku.kill() navigation.wait_for_grid_exit() time.sleep(0.1) perform_mouse_action(int(action))
def select_text(): global x1, y1, x2, y2 x2, y2 = win32api.GetCursorPos() s = control.nexus().comm.get_com("grids") s.kill() grids.wait_for_death(settings.DOUGLAS_TITLE) drag_from_to(x1, y1, x2, y2)
def send_input(n, action): s = control.nexus().comm.get_com("grids") int_a = int(action) response = None if int_a != 2: s.go(str(n)) elif int_a == 2: response = s.retrieve_data_for_highlight(str(int(n))) s.kill() grids.wait_for_death(settings.LEGION_TITLE) if int_a == 0: Playback([(["mouse", "left", "click"], 0.0)]).execute() elif int_a == 1: Playback([(["mouse", "right", "click"], 0.0)]).execute() elif int_a == 2: x1 = response["l"] + 2 x2 = response["r"] y = response["y"] win32api.SetCursorPos((x1, y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) win32api.SetCursorPos((x2, y)) time.sleep(0.1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
def select_text(): global x1, y1, x2, y2 x2, y2 = get_cursor_position() s = control.nexus().comm.get_com("grids") s.kill() navigation.wait_for_grid_exit() drag_from_to(x1, y1, x2, y2)
def send_input(n, action): s = control.nexus().comm.get_com("grids") int_a = int(action) response = None if int_a != 2: s.go(str(n)) elif int_a == 2: response = s.retrieve_data_for_highlight(str(int(n))) s.kill() Grid.wait_for_grid_exit() if int_a == 0: Mouse("left").execute() elif int_a == 1: Mouse("right").execute() elif int_a == 2: x1 = response["l"] + 2 x2 = response["r"] y = response["y"] Mouse("[{}, {}]".format(x1, y)).execute() time.sleep(0.1) Mouse("left:down").execute() Mouse("[{}, {}]".format(x2, y)).execute() time.sleep(0.1) Mouse("left:up").execute()
def _execute(self, data=None): output = control.nexus().temp Paste(output).execute() if output: Key(self.action_if_text).execute() else: Key(self.action_if_no_text).execute() return True
def send_input_select(pre1, color1, n1, pre2, color2, n2): s = control.nexus().comm.get_com("grids") s.move_mouse(int(pre1), int(color1), int(n1)) _x1, _y1 = win32api.GetCursorPos() s.move_mouse(int(pre2), int(color2), int(n2)) _x2, _y2 = win32api.GetCursorPos() s.kill() grids.wait_for_death(settings.DOUGLAS_TITLE) drag_from_to(_x1, _y1, _x2, _y2)
def send_input_select(pre1, color1, n1, pre2, color2, n2): s = control.nexus().comm.get_com("grids") s.move_mouse(int(pre1), int(color1), int(n1)) _x1, _y1 = get_cursor_position() s.move_mouse(int(pre2), int(color2), int(n2)) _x2, _y2 = get_cursor_position() s.kill() navigation.wait_for_grid_exit() drag_from_to(_x1, _y1, _x2, _y2)
def send_input_select(x1, y1, x2, y2): s = control.nexus().comm.get_com("grids") s.move_mouse(int(x1), int(y1)) _x1, _y1 = win32api.GetCursorPos() s.move_mouse(int(x2), int(y2)) _x2, _y2 = win32api.GetCursorPos() s.kill() grids.wait_for_death(settings.DOUGLAS_TITLE) drag_from_to(_x1, _y1, _x2, _y2)
def send_input_select(x1, y1, x2, y2): s = control.nexus().comm.get_com("grids") s.move_mouse(int(x1), int(y1)) _x1, _y1 = get_cursor_position() s.move_mouse(int(x2), int(y2)) _x2, _y2 = get_cursor_position() s.kill() navigation.wait_for_grid_exit() drag_from_to(_x1, _y1, _x2, _y2)
def move_mouse(n, s, action): sudoku = control.nexus().comm.get_com("grids") sudoku.move_mouse(int(n), int(s)) int_a = int(action) if (int_a == 0) | (int_a == 1) | (int_a == 2) | (int_a == -1): sudoku.kill() Grid.wait_for_grid_exit() time.sleep(0.1) perform_mouse_action(int(action))
def curse(direction, direction2, nnavi500, dokick): x, y = 0, 0 d = str(direction) d2 = str(direction2) if d == "up" or d2 == "up": y = -nnavi500 if d == "down" or d2 == "down": y = nnavi500 if d == "left" or d2 == "left": x = -nnavi500 if d == "right" or d2 == "right": x = nnavi500 Mouse("<" + str(x) + ", " + str(y) + ">").execute() if int(dokick) != 0: if int(dokick) == 1: left_click(control.nexus()) elif int(dokick) == 2: right_click(control.nexus())
def check_complete(): data = None try: data = control.nexus().comm.get_com("hmc").get_message() if data is None: return False except Exception: return False data_function(data) return True
def send_input(x, y, action): s = control.nexus().comm.get_com("grids") s.move_mouse(int(x), int(y)) int_a = int(action) if (int_a == 0) | (int_a == 1) | (int_a == -1): s.kill() grids.wait_for_death(settings.DOUGLAS_TITLE) if int_a == 0: Mouse("left").execute() elif int_a == 1: Mouse("right").execute()
def _start_server_proxy(self): """ This method will fail if the server isn't started yet. """ # this will never fail: self._server_proxy = control.nexus().comm.get_com("sikuli") # this will fail if the server isn't started yet: self._server_proxy.list_functions() # success at this point: printer.out("Caster-Sikuli server started successfully.") SikuliController._ENABLE_GEN_RULE.execute()
def send_input(x, y, action): s = control.nexus().comm.get_com("grids") s.move_mouse(int(x), int(y)) int_a = int(action) if (int_a == 0) | (int_a == 1) | (int_a == -1): s.kill() navigation.wait_for_grid_exit() if int_a == 0: Mouse("left").execute() elif int_a == 1: Mouse("right").execute()
def move_mouse(n, s, action): sudoku = control.nexus().comm.get_com("grids") sudoku.move_mouse(int(n), int(s)) # Close the grid window sudoku.kill() grids.wait_for_death(settings.SUDOKU_TITLE) time.sleep(0.1) perform_mouse_action(int(action))
def send_input(pre, color, n, action): s = control.nexus().comm.get_com("grids") s.move_mouse(int(pre), int(color), int(n)) int_a = int(action) if (int_a == 0) | (int_a == 1) | (int_a == -1): s.kill() navigation.wait_for_grid_exit() time.sleep(0.1) if int_a == 0: Mouse("left").execute() elif int_a == 1: Mouse("right").execute()
def send_input(pre, color, n, action): s = control.nexus().comm.get_com("grids") s.move_mouse(int(pre), int(color), int(n)) int_a = int(action) if (int_a == 0) | (int_a == 1) | (int_a == -1): s.kill() grids.wait_for_death(settings.DOUGLAS_TITLE) time.sleep(0.1) if int_a == 0: Mouse("left").execute() elif int_a == 1: Mouse("right").execute()
def __init__(self): from castervoice.lib import control self._engine_modes_manager = control.nexus().engine_modes_manager self.engine = get_current_engine().name self.sync_timer = None self.sleep_timer = None if self.engine != 'natlink': # Other engines besides natlink needs a default mic state for sleep_timer self._engine_modes_manager.mic_state = "on" if self.engine != "text": self._engine_timers() self._set_default_mic_mode() self._set_engine_default_mode()
def drag_mouse(n0, s0, n, s, action): sudoku = control.nexus().comm.get_com("grids") x, y = sudoku.get_mouse_pos(int(n), int(s)) # If dragging from a different location, move there first if int(n0) > 0: sudoku.move_mouse(int(n0), int(s0)) sudoku.kill() navigation.wait_for_grid_exit() time.sleep(0.1) # Hold down click, move to drag destination, and release click Mouse("left:down/10").execute() Mouse("[{}, {}]".format(x, y)).execute() time.sleep(0.1) Mouse("left:up/30").execute() perform_mouse_action(int(action))
def drag_highlight(n1, n2): s = control.nexus().comm.get_com("grids") response1 = s.retrieve_data_for_highlight(str(int(n1))) response2 = s.retrieve_data_for_highlight(str(int(n2))) s.kill() Grid.wait_for_grid_exit() x11 = response1["l"] + 2 y1 = response1["y"] x22 = response2["r"] y2 = response2["y"] Mouse("[{}, {}]".format(x11, y1)).execute() time.sleep(0.1) Mouse("left:down").execute() Mouse("[{}, {}]".format(x22, y2)).execute() time.sleep(0.1) Mouse("left:up").execute()
def drag_mouse(n0, s0, n, s, action): sudoku = control.nexus().comm.get_com("grids") x, y = sudoku.get_mouse_pos(int(n), int(s)) # If dragging from a different location, move there first if int(n0) > 0: sudoku.move_mouse(int(n0), int(s0)) sudoku.kill() grids.wait_for_death(settings.SUDOKU_TITLE) time.sleep(0.1) # Hold down click, move to drag destination, and release click win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) time.sleep(0.1) win32api.SetCursorPos((int(x), int(y))) time.sleep(0.1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) time.sleep(0.3) perform_mouse_action(int(action))
def drag_highlight(n1, n2): s = control.nexus().comm.get_com("grids") response1 = s.retrieve_data_for_highlight(str(int(n1))) response2 = s.retrieve_data_for_highlight(str(int(n2))) s.kill() grids.wait_for_death(settings.LEGION_TITLE) x11 = response1["l"] + 2 x12 = response1["r"] y1 = response1["y"] x21 = response2["l"] + 2 x22 = response2["r"] y2 = response2["y"] win32api.SetCursorPos((x11, y1)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) win32api.SetCursorPos((x22, y2)) time.sleep(0.1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
#! python2.7 ''' main Caster module Created on Jun 29, 2014 ''' import six if six.PY2: import logging logging.basicConfig() from castervoice.lib import settings # requires DependencyMan to be initialized settings.initialize() from castervoice.lib.ctrl.configure_engine import EngineConfigEarly, EngineConfigLate EngineConfigEarly() # requires settings/dependencies _NEXUS = None from castervoice.lib import control if control.nexus() is None: # Initialize Caster State from castervoice.lib.ctrl.loading.content_loader import ContentLoader from castervoice.lib.ctrl.loading.content_request_generator import ContentRequestGenerator _crg = ContentRequestGenerator() _content_loader = ContentLoader(_crg) control.init_nexus(_content_loader) EngineConfigLate() # Requires grammars to be loaded and nexus print("\n*- Starting " + settings.SOFTWARE_NAME + " -*")
def fill_within_line(target): result = navigate_to_character("left", str(target), True) if result: from castervoice.lib import control control.nexus().state.terminate_asynchronous(success=True) return result