Exemplo n.º 1
0
    def __init__(self):
        tap.register(tap.MMOVE, self.on_move)
        tracker.register('', self.on_stream)

        self.saved_mouse = None
        self.main_mouse = False
        self.main_gaze = False
        self.restore_counter = 0
Exemplo n.º 2
0
    def __init__(self):
        self.hiss_start = 0
        self.hiss_last = 0
        self.button = 0
        self.mouse_origin = Point2d(0, 0)
        self.mouse_last = Point2d(0, 0)
        self.dragging = False

        tap.register(tap.MMOVE, self.on_move)
        noise.register('noise', self.on_noise)
Exemplo n.º 3
0
    def __init__(self):
        if len(ui.screens()) == 1:
            return
        tap.register(tap.MMOVE, self.on_move)
        tracker.register("gaze", self.on_gaze)
        self.top = None

        if len(ui.screens()) >= 2:
            print("Have top screen")
            self.top = ui.screens()[1]
            self.saved_mouse_top = Point2d(self.top.x + self.top.width // 2,
                                           self.top.y + self.top.height // 2)
        self.main_mouse = False
        self.main_gaze = False
        self.restore_counter = 0
Exemplo n.º 4
0
 def __init__(self):
     if len(ui.screens()) == 1:
         return
     tap.register(tap.MMOVE, self.on_move)
     tap.register(tap.MCLICK, self.on_click)
     tracker.register("gaze", self.on_gaze)
     self.left = None
     self.right = None
     if len(ui.screens()) >= 2:
         print("Have left screen")
         self.left = ui.screens()[1]
         self.saved_mouse_left = Point2d(
             self.left.x + self.left.width // 2,
             self.left.y + self.left.height // 2)
     if len(ui.screens()) == 3:
         print("Have right screen")
         self.right = ui.screens()[2]
         self.saved_mouse_right = Point2d(
             self.right.x + self.right.width // 2,
             self.right.y + self.right.height // 2)
     self.main_mouse = False
     self.main_gaze = False
     self.restore_counter = 0
Exemplo n.º 5
0
import eye_mouse
import time
from talon import ctrl, tap
from talon.voice import Context
ctx = Context('mouse')

x, y = ctrl.mouse_pos()
mouse_history = [(x, y, time.time())]
force_move = None

def on_move(typ, e):
    mouse_history.append((e.x, e.y, time.time()))
    if force_move:
        e.x, e.y = force_move
        return True
tap.register(tap.MMOVE, on_move)

def click_pos(m):
    word = m._words[0]
    start = (word.start + min((word.end - word.start) / 2, 0.100)) / 1000.0
    diff, pos = min([(abs(start - pos[2]), pos) for pos in mouse_history])
    return pos[:2]

def delayed_click(m, button=0, times=1):
    old = eye_mouse.config.control_mouse
    eye_mouse.config.control_mouse = False
    x, y = click_pos(m)
    ctrl.mouse(x, y)
    ctrl.mouse_click(x, y, button=button, times=times, wait=16000)
    time.sleep(0.032)
    eye_mouse.config.control_mouse = old
Exemplo n.º 6
0
    # Only do something on key down
    if not e.down: return

    # F3 means click
    if e == "f3":
        e.block()
        click()

    # option+= means toggle tobii on and off.
    elif e == "alt-=":
        e.block()
        toggle_watcher()


tap.register(tap.KEY | tap.HOOK, on_key)

# Uncomment to enable
mouse = LensMouse()

context = Context("lens_mouse")


def toggle_watcher():
    if mouse.enabled:
        # print("    unregister")
        tracker.unregister('gaze', mouse.on_gaze)
        canvas.unregister('overlay', mouse.draw)
        # lens mode is useless without eye tracking
        # noise_model.lens_mode = False
    else:
Exemplo n.º 7
0
        text,
    ]
})

ctx = Context("login", bundle="com.apple.loginwindow")
ctx.keymap({"amigo": [keychain.find("login", "user"), Key("enter")]})


def screensaver_hotkey(_, e):
    # print(e)
    if e == "cmd-ctrl-§" and e.down:
        subprocess.check_call(
            ["open", "/System/Library/CoreServices/ScreenSaverEngine.app"]),
        e.block()
    return True


tap.register(tap.HOOK | tap.KEY, screensaver_hotkey)


# Default to krisp on startup, if present.
def _use_krisp():
    # noinspection PyUnresolvedReferences
    mics = {i.name: i for i in list(microphone.manager.menu.items)}
    krisp = "krisp microphone"
    if krisp in mics:
        microphone.manager.menu_click(mics[krisp])


_use_krisp()
Exemplo n.º 8
0
    scroll_job = None
    gaze_job = None
    gui_wheel.hide()

    # if eye_zoom_mouse.zoom_mouse.enabled and eye_mouse.mouse.attached_tracker is not None:
    #    eye_zoom_mouse.zoom_mouse.sleep(False)


def start_cursor_scrolling():
    global scroll_job, gaze_job
    stop_scroll()
    gaze_job = cron.interval("60ms", gaze_scroll)
    # if eye_zoom_mouse.zoom_mouse.enabled and eye_mouse.mouse.attached_tracker is not None:
    #    eye_zoom_mouse.zoom_mouse.sleep(True)


if app.platform == "mac":
    from talon import tap

    def on_move(e):
        if not config.control_mouse:
            buttons = ctrl.mouse_buttons_down()
            # print(str(ctrl.mouse_buttons_down()))
            if not e.flags & tap.DRAG and buttons:
                e.flags |= tap.DRAG
                # buttons is a set now
                e.button = list(buttons)[0]
                e.modify()

    tap.register(tap.MMOVE | tap.HOOK, on_move)
Exemplo n.º 9
0
    extendable("shift-alt-right cmd-x"),
    "cut way left":
    extendable("cmd-shift-left cmd-x"),
    "cut way right":
    extendable("cmd-shift-right cmd-x"),
    "cut way up":
    extendable("cmd-shift-up cmd-x"),
    "cut way down":
    extendable("cmd-shift-down cmd-x"),
})


def terminal_hotkey(_, e):
    """Adds an alt-w to pick up zle selection as well."""
    window = ui.active_window()
    bundle = window.app.bundle
    if bundle != "com.googlecode.iterm2":
        return
    if e == "cmd-c" and e.up:
        # print("intercept " + str(e))
        Key("alt-w")(None)
    elif e == "enter" and e.up:
        # print("intercept " + str(e))
        cron.after("500ms", lambda: update_ctx(None))
    return True


tap.register(tap.HOOK | tap.KEY, terminal_hotkey)

ctx.set_list("alphabet", alphabet.keys())
Exemplo n.º 10
0
        return app.notify(body=spaghetti[type], sound=True)
    return app.notify(body=spaghetti[type], sound=False)


sleepy.keymap(
    {
        "talon sleep": lambda m: set_voice_type(VoiceType.SLEEPING),
        "talon wake": lambda m: set_voice_type(last_voice_type),
        "dragon mode": lambda m: set_voice_type(VoiceType.DRAGON),
        # "dictation mode": lambda m: set_voice_type(VoiceType.DICTATION),
        "talon mode": lambda m: set_voice_type(VoiceType.TALON),
    }
)
sleep_group.load()


def sleep_hotkey(typ, e):
    global voice_type
    if e == "ctrl-alt-cmd-,":
        set_voice_type(VoiceType.SLEEPING)
    elif e == "ctrl-alt-cmd-.":
        set_voice_type(VoiceType.TALON)
    # elif e == "ctrl-alt-cmd-/":
    #     # set_voice_type(VoiceType.SLEEPING)
    #     set_voice_type(VoiceType.DRAGON)

    return True


tap.register(tap.HOOK | tap.KEY, sleep_hotkey)
Exemplo n.º 11
0
 def start(self):
     tap.register(tap.MMOVE, self.on_move)
     noise.register('noise', self.on_noise)
Exemplo n.º 12
0
    "window preev screen": previous_screen,
})

LEFT = True


def snap_hotkey(typ, e):
    global LEFT
    # Snap screen
    if e == "ctrl-shift-alt-cmd-s" and e.down:
        grid(1, 1, 1, 1)(None)

    # Snap left
    elif e == "ctrl-shift-alt-cmd-l" and e.down:
        if LEFT:
            grid(1, 1, 2, 1)(None)
        else:
            grid(2, 1, 2, 1)(None)
        LEFT = not LEFT
    # Snap next
    elif e == "ctrl-shift-alt-cmd-n" and e.down:
        move_screen(1)
    # Snap center
    elif e == "ctrl-shift-alt-cmd-c" and e.down:
        grid(2, 2, 10, 11, colspan=8, rowspan=9)(None)

    return True


tap.register(tap.HOOK | tap.KEY, snap_hotkey)
Exemplo n.º 13
0
    # Different input volume levels
    # "input volume high": lambda _: set_input_volume(90),
    # "input volume low": lambda _: set_input_volume(30),
})

ctx = Context("shortcat")
ctx.keymap({
    "(shortcat | short cap | shortcut) [<dgndictation>]": [
        Key("cmd+shift+ctrl+alt+n"),
        text,
    ]
})

ctx = Context("login", bundle="com.apple.loginwindow")
ctx.keymap({"amigo": [keychain.find("login", "user"), Key("enter")]})

# keychain.remove("login", "user"); keychain.add("login", "user", "pass")


def misc_hotkey(_, e):
    # if e.down:
    #     print(e)
    if e.down and e == "cmd-ctrl-§" or e == "ctrl-alt-shift-cmd-bksp":
        subprocess.check_call(
            ["open", "/System/Library/CoreServices/ScreenSaverEngine.app"]),
        e.block()
    return True


tap.register(tap.HOOK | tap.KEY, misc_hotkey)
Exemplo n.º 14
0
    def __init__(self):
        self.recording = False
        self.log = []

        tap.register(tap.KEY | tap.MCLICK | tap.MMOVE | tap.SCROLL,
                     self.on_event)