Exemple #1
0
    def key(key: str):
        if key == ' ': key = 'space'
        keys = key.strip().split(' ')

        for key in keys:
            parts = [key]
            if len(key) > 1:
                sep = '-'
                if '+' in key and (not '-' in key
                                   or key.index('+') < key.index('-')):
                    sep = '+'
                if sep == '-':
                    if key.endswith('--'):
                        key = key[:-1] + 'dash'
                else:
                    if key.endswith('++'):
                        key = key[:-1] + 'plus'
                parts = key.split(sep)
            metas, key = parts[:-1], parts[-1]
            kwargs = {}
            kwargs.update({k: True for k in metas})
            key = REMAP.get(key, key)
            if not 'wait' in kwargs:
                kwargs['wait'] = 1000
            ctrl.key_press(key, **kwargs)
Exemple #2
0
def place(m):
    times = 1
    if len(m._words) > 1:
        times = parse_words_as_integer(m._words[1:])
    for t in range(times):
        ctrl.key_press('u')
        time.sleep(0.25)
Exemple #3
0
def hold_key(m):
    keymap = {'attack': 'k', 'eat': 'u'}
    half_seconds = parse_words_as_integer(m._words[1:])
    if half_seconds != None and half_seconds > 0 and half_seconds < 10:
        microseconds = half_seconds * 500000
        key_to_press = keymap[m._words[0]]
        ctrl.key_press(key_to_press, hold=microseconds)
Exemple #4
0
 def window_next_hold(number: int):
     """Windows-specific implementation that holds alt while tabbing."""
     # TODO: Port to newapi once down/up implemented
     ctrl.key_press("alt", down=True)
     for i in range(number):
         actions.key("tab")
         time.sleep(0.1)
     ctrl.key_press("alt", up=True)
Exemple #5
0
 def delayed_click(m, button=0, times=1, from_end=False, mods=None):
     if mods is None:
         mods = []
     for key in mods:
         ctrl.key_press(key, down=True)
     ctrl.mouse_click(button=button, times=times)
     for key in mods[::-1]:
         ctrl.key_press(key, up=True)
     time.sleep(0.032)
Exemple #6
0
    def play(self, log, delay=True):
        for i, (typ, e) in enumerate(log):
            if i > 0 and delay:
                _, last = log[i - 1]
                time.sleep(max(e.ts - last.ts, 0))

            # if typ == tap.MMOVE:
            #     ctrl.mouse_move(e.x, e.y)
            # elif typ == tap.MCLICK:
            #     ctrl.mouse_click(button=e.button, down=e.down, up=e.up)
            if typ == tap.KEY and (e.down or e.up):
                mods = {mod: True for mod in e.mods}
                ctrl.key_press(e.key, down=e.down, up=e.up, **mods)
Exemple #7
0
def delayed_click(m, button=0, times=1, from_end=False, mods=None):
    if mods is None:
        mods = []
    old = eye_mouse.config.control_mouse
    eye_mouse.config.control_mouse = False
    x, y = click_pos(m, from_end=from_end)
    ctrl.mouse(x, y)
    for key in mods:
        ctrl.key_press(key, down=True)
    ctrl.mouse_click(x, y, button=button, times=times, wait=16000)
    for key in mods[::-1]:
        ctrl.key_press(key, up=True)
    time.sleep(0.032)
    eye_mouse.config.control_mouse = old
Exemple #8
0
    def descend(self, m):
        ctx.set_list('current', self.roots.keys())
        word = str(m['menus.current'][0])
        #         print(word, self.path)
        new_menu = False
        if word in self.roots:
            if self.path:
                new_menu = True
            self.path = [word]
        elif word == 'menu back':
            self.path.pop()
        else:
            self.path.append(word)

        if word == 'menu cancel' or word == 'menu back' and not self.path:
            ctrl.key_press('escape')
            self.update()
            return

        pos = self.roots.get(word) or self.leafs.get(word)
        if pos and False:
            x, y = map(int, pos)
            ctrl.mouse(x, y)
            if not new_menu:
                ctrl.mouse_click()
        app = get_app()
        cur, menu = get_menu(app.menu_bars[1], self.path)
        if not pos or True:
            if new_menu:
                ctrl.key_press('escape')
            cur.click()
        self.leafs = name_and_centers(menu.menu_items)

        if self.leafs:
            #             print(self.leafs)
            ctx.set_list(
                'current',
                list(self.leafs.keys()) + ['menu back', 'menu cancel'] +
                list(self.roots.keys()))
        else:
            self.update()
Exemple #9
0
def shell_rerun(m):
    # switch_app(name='iTerm2')
    app = ui.apps(bundle="io.alacritty")[0]
    ctrl.key_press("c", ctrl=True, app=app)
    time.sleep(0.05)
    ctrl.key_press("up", app=app)
    ctrl.key_press("enter", app=app)
Exemple #10
0
def shell_rerun(m):
    # switch_app(name='iTerm2')
    app = ui.apps(bundle="com.googlecode.iterm2")[0]
    ctrl.key_press("c", ctrl=True, app=app)
    time.sleep(0.05)
    ctrl.key_press("up", app=app)
    ctrl.key_press("enter", app=app)
Exemple #11
0
 def shell_rerun():
     """rerun the most recent command in whichever shell as most recently used"""
     # switch_app(name='iTerm2')
     app = ui.apps(bundle="com.googlecode.iterm2")[0]
     ctrl.key_press("c", ctrl=True, app=app)
     actions.sleep("50ms")
     ctrl.key_press("up", app=app)
     ctrl.key_press("enter", app=app)
Exemple #12
0
def climb(m):
    repeat = 1
    if len(m._words) > 1:
        repeat = parse_words_as_integer(m._words[1:])
    for r in range(repeat):
        ctrl.key_press('space', down=True)
        time.sleep(0.25)
        ctrl.key_press('u')
        ctrl.key_press('space', up=True)
        time.sleep(0.25)
Exemple #13
0
 def click(e):
     for key in mods:
         ctrl.key_press(key, down=True)
     click_func(e)
     if not hold_keys:
         for key in mods[::-1]:
             ctrl.key_press(key, up=True)
     if release_all_keys:
         for key in ['ctrl', 'alt', 'shift', 'cmd', 'fn']:
             ctrl.key_press(key, up=True)
Exemple #14
0
def stop_attack(m):
    ctrl.key_press('k', up=True)
Exemple #15
0
def start_pan(m):
    ctrl.key_press('space', down=True)
Exemple #16
0
def stop_pan(m):
    ctrl.key_press('space', up=True)
 Key('alt+shift+left'),
 'rotate clockwise by 1 degree':
 Key('alt+shift+right'),
 'close drawing [editor]':
 Key('cmd+esc'),
 '(insert | add) comment':
 Key('cmd+alt+m'),
 'open discussion thread':
 Key('cmd+alt+shift+a'),
 'enter [current] comment':
 Key('ctrl+enter'),
 'insert footnote':
 Key('cmd+alt+f'),
 'move to current footnote':
 lambda m: (
     ctrl.key_press('cmd', ctrl=True, cmd=True, down=True),
     press('e'),
     press('f'),
     ctrl.key_press('cmd', ctrl=True, cmd=True, up=True),
 ),
 'move to next footnote':
 lambda m: (
     ctrl.key_press('cmd', ctrl=True, cmd=True, down=True),
     press('n'),
     press('f'),
     ctrl.key_press('cmd', ctrl=True, cmd=True, up=True),
 ),
 'move to previous footnote':
 lambda m: (
     ctrl.key_press('cmd', ctrl=True, cmd=True, down=True),
     press('p'),
Exemple #18
0
 def do_it(m):
     # noinspection PyProtectedMember
     num = text_to_number(m._words[-1])
     if num < 10:
         ctrl.key_press(str(num), ctrl=control, alt=mod_one, shift=mod_one)
Exemple #19
0
 def do_it(_):
     ctrl.key_press(key, shift=True, ctrl=True, alt=True)
Exemple #20
0
def fire_bow(m):
    ctrl.key_press('u', up=True)
Exemple #21
0
def control_shift_click(m, button=0, times=1):
    ctrl.key_press("shift", ctrl=True, shift=True, down=True)
    ctrl.mouse_click(x, y, button=button, times=times, wait=16000)
    ctrl.key_press("shift", ctrl=True, shift=True, up=True)
Exemple #22
0
 def click(e):
     for key in mods:
         ctrl.key_press(key, down=True)
     delayed_click(e)
     for key in mods[::-1]:
         ctrl.key_press(key, up=True)
Exemple #23
0
    Key('down'),
    'left':
    Key('left'),
    'right':
    Key('right'),
    'select all':
    Key('cmd-a'),
    'next space':
    Key('cmd-alt-ctrl-right'),
    'last space':
    Key('cmd-alt-ctrl-left'),
    'scroll down': [Key('down')] * 30,
    'scroll up': [Key('up')] * 30,
    'lift <dgndictation>':
    lambda n: [
        ctrl.key_press('up')
        for i in range(numberDict[n.dgndictation[0]._words[0]])
    ],
    'hinder <dgndictation>':
    lambda n: [
        ctrl.key_press('down')
        for i in range(numberDict[n.dgndictation[0]._words[0]])
    ],
    'copy active bundle':
    copy_bundle,
})

alpha_alt = 'aim bat chain drum each fox good harp india jury cake look made neat odd pure queen rule sun trap urine vest whale plex yard zulu'.split(
)
#alpha_alt = 'air bat cap drum each fine gust harp sit jury crunch look made near odd pit quench red sun trap urge vest whale plex yank zip'.split()
#alpha_alt = 'alpha bravo chain delta echo foxy golf hotel india juliet kilo Lima mikey nova oyster Paris queen ricky sierra tango urinal victor whiskey xray yankee sooloo'.split()
Exemple #24
0
 def do_it(m):
     num = text_to_number(m._words[-1])
     if num<10:
         ctrl.key_press(str(num), ctrl=control, alt=mod1, shift=mod1)
Exemple #25
0
def start_attack(m):
    ctrl.key_press('k', down=True)
Exemple #26
0
 Key("alt+shift+left"),
 "rotate clockwise by 1 degree":
 Key("alt+shift+right"),
 "close drawing [editor]":
 Key("cmd+esc"),
 "(insert | add) comment":
 Key("cmd+alt+m"),
 "open discussion thread":
 Key("cmd+alt+shift+a"),
 "enter [current] comment":
 Key("ctrl+enter"),
 "insert footnote":
 Key("cmd+alt+f"),
 "move to current footnote":
 lambda m: (
     ctrl.key_press("cmd", ctrl=True, cmd=True, down=True),
     press("e"),
     press("f"),
     ctrl.key_press("cmd", ctrl=True, cmd=True, up=True),
 ),
 "move to next footnote":
 lambda m: (
     ctrl.key_press("cmd", ctrl=True, cmd=True, down=True),
     press("n"),
     press("f"),
     ctrl.key_press("cmd", ctrl=True, cmd=True, up=True),
 ),
 "move to (previous | prev) footnote":
 lambda m: (
     ctrl.key_press("cmd", ctrl=True, cmd=True, down=True),
     press("p"),
from ..utils import time_delay
import time

ctx = Context(
    "Outlook", exe="C:\\Program Files\\Microsoft Office\\root\\Office16\\OUTLOOK.EXE"
)

keymap = {
    "reply (message | mail | male)": [
        Key("alt-h"),
        time_delay(0.1),
        Key("r"),
        time_delay(0.1),
        Key("p"),
    ],
    "send (message | mail | male)": Key("ctrl-enter"),
    "next (pain | pane)": Key("ctrl-tab"),
    "preev (pain | pane)": Key("shift-ctrl-tab"),
    "[show] options": lambda m: (
        ctrl.key_press("alt", alt=True, down=True),
        time.sleep(0.5),
        ctrl.key_press("alt", alt=True, up=True),
    ),
    "search bar": Key("ctrl-e"),
    "go inbox": Key("ctrl-shift-i"),
    "compose [message]": Key("ctrl-shift-m"),
    # "dismiss outlook": [lambda m: switch_app(name="outlook"), Key("cmd-w")],
}

ctx.keymap(keymap)
Exemple #28
0
def draw_bow(m):
    ctrl.key_press('u', down=True)
Exemple #29
0
def press_key_and_click(m, key, button=0, times=1):
    ctrl.key_press(key, down=True)
    ctrl.mouse_click(pos=(x, y), button=button, times=times, wait=16000)
    ctrl.key_press(key, up=True)
Exemple #30
0
def jump(m):
    ctrl.key_press('space', hold=500000)