How to use the ahk.keys.Key function in ahk

To help you get started, we’ve selected a few ahk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spyoungtech / ahk / ahk / keys.py View on Github external
def _init_keys():
    '''put this in a function to avoid polluting global namespace'''
    for i in range(0, 10):
        #  set numpad keys
        key_name = f'Numpad{i}'
        key = Key(key_name)
        setattr(KEYS, key_name, key)
        setattr(KEYS, key_name.upper(), key)

    for i in range(1, 25):
        # set function keys
        key_name = f'F{i}'
        setattr(KEYS, key_name, Key(key_name))

    for i in range(1, 33):
        # set joystick keys
        key_name = f'Joy{i}'
        setattr(KEYS, key_name, Key(key_name))
        setattr(KEYS, key_name.upper(), Key(key_name))
github spyoungtech / ahk / ahk / keys.py View on Github external
RIGHT_CONTROL = KeyModifier('RControl')
    RCtrl = RIGHT_CONTROL
    RControl = RIGHT_CONTROL
    ALT = KeyModifier('Alt')
    Alt = ALT
    LEFT_ALT = KeyModifier('LAlt')
    LAlt = LEFT_ALT
    RIGHT_ALT = KeyModifier('RAlt')
    RAlt = RIGHT_ALT
    SHIFT = KeyModifier('Shift')
    Shift = SHIFT
    LEFT_SHIFT = KeyModifier("LShift")
    LShift = LEFT_SHIFT
    RIGHT_SHIFT = KeyModifier('RShift')
    RShift = RIGHT_SHIFT
    NUMPAD_DOT = Key('NumpadDot')
    NumpadDot = NUMPAD_DOT
    NUMPAD_DEL = Key('NumpadDel')
    NumpadDel = NUMPAD_DEL
    NUM_LOCK = Key('NumLock')
    NumLock = NUM_LOCK
    NUMPAD_ADD = Key('NumpadAdd')
    NUMPAD_DIV = Key('NumpadDiv')
    NUMPAD_SUB = Key('NumpadSub')
    NUMPAD_MULT = Key('NumpadMult')
    NUMPAD_ENTER = Key('NumpadEnter')
    NumpadAdd = NUMPAD_ADD
    NumpadDiv = NUMPAD_DIV
    NumpadSub = NUMPAD_SUB
    NumpadMult = NUMPAD_MULT
    NumpadEnter = NUMPAD_ENTER
github spyoungtech / ahk / ahk / keyboard.py View on Github external
def key_down(self, key):
        """
        Press down a key (without releasing it)

        :param key:
        :return:
        """
        if isinstance(key, str):
            key = Key(key_name=key)
        return self.send_input(key.DOWN)
github spyoungtech / ahk / ahk / keys.py View on Github external
SCROLL_LOCK = Key('ScrollLock')
    ScrollLock = SCROLL_LOCK
    SPACE = Key('Space')

    TAB = Key('Tab')
    Tab = TAB
    ENTER = Key('Enter')
    Enter = ENTER
    ESCAPE = Key('Escape')
    BACKSPACE = Key('Backspace')
    Backspace = BACKSPACE
    UP = Key('Up')
    Up = UP
    DOWN = Key('Down')
    Down = DOWN
    LEFT = Key('Left')
    Left = LEFT
    RIGHT = Key('Right')
    Right = RIGHT
    DELETE = Key('Delete')
    DEL = DELETE
    Delete = DELETE
    Del = DELETE

    WIN = KeyModifier('Win')
    Win = WIN
    LEFT_WIN = KeyModifier('LWin')
    LWin = LEFT_WIN
    RIGHT_WIN = KeyModifier('RWin')
    RWin = RIGHT_WIN
    CONTROL = KeyModifier('Control')
    Control = CONTROL
github spyoungtech / ahk / ahk / keys.py View on Github external
elif isinstance(other, KeyCombo):
            return other + self

        return self.symbol + str(other)


class KEYS:
    """
    KEYS constants
    REF: https://autohotkey.com/docs/KeyList.htm
    """
    CAPS_LOCK = Key('CapsLock')
    CapsLock = CAPS_LOCK
    SCROLL_LOCK = Key('ScrollLock')
    ScrollLock = SCROLL_LOCK
    SPACE = Key('Space')

    TAB = Key('Tab')
    Tab = TAB
    ENTER = Key('Enter')
    Enter = ENTER
    ESCAPE = Key('Escape')
    BACKSPACE = Key('Backspace')
    Backspace = BACKSPACE
    UP = Key('Up')
    Up = UP
    DOWN = Key('Down')
    Down = DOWN
    LEFT = Key('Left')
    Left = LEFT
    RIGHT = Key('Right')
    Right = RIGHT
github spyoungtech / ahk / ahk / keys.py View on Github external
def __add__(self, other):
        if self._s is not None:
            raise ValueError('Key combo is already terminated')
        if isinstance(other, KeyCombo):
            combo = KeyCombo(*[*self.modifiers, *other.modifiers])
            if other._s:
                combo = combo + other._s
            return combo
        if isinstance(other, KeyModifier):
            self.modifiers.append(other)
        elif isinstance(other, Key) or isinstance(other, str):
            self._s = str(other)
            return self
        else:
            raise TypeError(f"unsupported operand type(s) for +: '{self.__class__.__name__}' and '{type(other)}'")
github spyoungtech / ahk / ahk / keys.py View on Github external
RIGHT_ALT = KeyModifier('RAlt')
    RAlt = RIGHT_ALT
    SHIFT = KeyModifier('Shift')
    Shift = SHIFT
    LEFT_SHIFT = KeyModifier("LShift")
    LShift = LEFT_SHIFT
    RIGHT_SHIFT = KeyModifier('RShift')
    RShift = RIGHT_SHIFT
    NUMPAD_DOT = Key('NumpadDot')
    NumpadDot = NUMPAD_DOT
    NUMPAD_DEL = Key('NumpadDel')
    NumpadDel = NUMPAD_DEL
    NUM_LOCK = Key('NumLock')
    NumLock = NUM_LOCK
    NUMPAD_ADD = Key('NumpadAdd')
    NUMPAD_DIV = Key('NumpadDiv')
    NUMPAD_SUB = Key('NumpadSub')
    NUMPAD_MULT = Key('NumpadMult')
    NUMPAD_ENTER = Key('NumpadEnter')
    NumpadAdd = NUMPAD_ADD
    NumpadDiv = NUMPAD_DIV
    NumpadSub = NUMPAD_SUB
    NumpadMult = NUMPAD_MULT
    NumpadEnter = NUMPAD_ENTER


def _init_keys():
    '''put this in a function to avoid polluting global namespace'''
    for i in range(0, 10):
        #  set numpad keys
        key_name = f'Numpad{i}'
        key = Key(key_name)
github spyoungtech / ahk / ahk / keyboard.py View on Github external
def key_release(self, key):
        """
        Release a key that is currently in pressed down state

        :param key:
        :return:
        """
        if isinstance(key, str):
            key = Key(key_name=key)
        return self.send_input(key.UP)
github spyoungtech / ahk / ahk / keys.py View on Github external
return self.symbol + str(other)


class KEYS:
    """
    KEYS constants
    REF: https://autohotkey.com/docs/KeyList.htm
    """
    CAPS_LOCK = Key('CapsLock')
    CapsLock = CAPS_LOCK
    SCROLL_LOCK = Key('ScrollLock')
    ScrollLock = SCROLL_LOCK
    SPACE = Key('Space')

    TAB = Key('Tab')
    Tab = TAB
    ENTER = Key('Enter')
    Enter = ENTER
    ESCAPE = Key('Escape')
    BACKSPACE = Key('Backspace')
    Backspace = BACKSPACE
    UP = Key('Up')
    Up = UP
    DOWN = Key('Down')
    Down = DOWN
    LEFT = Key('Left')
    Left = LEFT
    RIGHT = Key('Right')
    Right = RIGHT
    DELETE = Key('Delete')
    DEL = DELETE
github spyoungtech / ahk / ahk / keys.py View on Github external
CAPS_LOCK = Key('CapsLock')
    CapsLock = CAPS_LOCK
    SCROLL_LOCK = Key('ScrollLock')
    ScrollLock = SCROLL_LOCK
    SPACE = Key('Space')

    TAB = Key('Tab')
    Tab = TAB
    ENTER = Key('Enter')
    Enter = ENTER
    ESCAPE = Key('Escape')
    BACKSPACE = Key('Backspace')
    Backspace = BACKSPACE
    UP = Key('Up')
    Up = UP
    DOWN = Key('Down')
    Down = DOWN
    LEFT = Key('Left')
    Left = LEFT
    RIGHT = Key('Right')
    Right = RIGHT
    DELETE = Key('Delete')
    DEL = DELETE
    Delete = DELETE
    Del = DELETE

    WIN = KeyModifier('Win')
    Win = WIN
    LEFT_WIN = KeyModifier('LWin')
    LWin = LEFT_WIN
    RIGHT_WIN = KeyModifier('RWin')
    RWin = RIGHT_WIN