Example #1
0
    def exec(self):
        commands = self.maindata
        print(commands)
        z = self.runFeins(commands)
        if (z[0]):
            r = z[1]
        else:
            r = 1

        keys = list()
        i = 0
        while i < r:
            for c in commands:
                if not self.scanspecial(c):
                    if '{' in c:
                        x = c.replace("{", "")
                        if pyautogui.isValidKey(x):
                            keys.append(x)
                            pyautogui.keyDown(x)
                    elif '}' in c:
                        if pyautogui.isValidKey(keys[len(keys) - 1]):
                            pyautogui.keyUp(keys[len(keys) - 1])
                            keys.pop(len(keys) - 1)
                    else:
                        if pyautogui.isValidKey(c):
                            pyautogui.keyDown(c)
            i = i + 1
Example #2
0
 def makeKwargs(self):
     key = self.key.text()
     kwargs = {'key': key}
     from pyautogui import isValidKey
     if isValidKey(key):
         return kwargs
     else:
         return None
Example #3
0
def keyUp(key):
    if isinstance(key, _IrisKey):
        pyautogui.keyUp(str(key))
    elif isinstance(key, str):
        if pyautogui.isValidKey(key):
            pyautogui.keyUp(key)
        else:
            raise ValueError("Unsupported string input")
    else:
        raise ValueError(INVALID_GENERIC_INPUT)
Example #4
0
    def __combo(info):
        time.sleep(0.5)
        text = info.replace("!TC ", "")
        txt = text.split('+')
        for i in txt:
            if not isValidKey(i.strip()):
                return i + " não é valido"
            else:
                keyDown(i.strip())

        for i in txt:
            keyUp(i.strip())

        return "Combo Digitado: " + text
Example #5
0
File: key.py Project: yyayegor/iris
def key_up(key):
    """Performs a keyboard key release (without the press down beforehand).

    :param key: The key to be released up.
    :return: None.
    """
    if isinstance(key, _IrisKey):
        pyautogui.keyUp(str(key))
    elif isinstance(key, str):
        if pyautogui.isValidKey(key):
            pyautogui.keyUp(key)
        else:
            raise ValueError("Unsupported string input.")
    else:
        raise ValueError(INVALID_GENERIC_INPUT)
Example #6
0
File: key.py Project: yyayegor/iris
def key_down(key):
    """Performs a keyboard key press without the release. This will put that key in a held down state.

    :param key: The key to be pressed down.
    :return: None.
    """
    if isinstance(key, _IrisKey):
        pyautogui.keyDown(str(key))
    elif isinstance(key, str):
        if pyautogui.isValidKey(key):
            pyautogui.keyDown(key)
        else:
            raise ValueError("Unsupported string input.")
    else:
        raise ValueError(INVALID_GENERIC_INPUT)
Example #7
0
    def key_up(key):
        """Performs a keyboard key release (without the press down beforehand).

        :param key: The key to be released up.
        :return: None.
        """
        if isinstance(key, Key):
            pyautogui.keyUp(key.value.label)
        elif isinstance(key, str):
            if pyautogui.isValidKey(key):
                pyautogui.keyUp(key)
            else:
                raise ValueError("Unsupported Key input.")
        else:
            raise ValueError("Unsupported Key input.")
Example #8
0
    def key_down(key):
        """Performs a keyboard key press without the release. This will put that key in a held down state.

        :param key: The key to be pressed down.
        :return: None.
        """
        if isinstance(key, Key):
            pyautogui.keyDown(key.value.label)
        elif isinstance(key, str):
            if pyautogui.isValidKey(key):
                pyautogui.keyDown(key)
            else:
                raise ValueError("Unsupported Key input.")
        else:
            raise ValueError("Unsupported Key input.")
Example #9
0
    def __post_init__(self):
        # everything other than typewrite key requires a valid key
        if self.key_type != KeyType.TYPEWRITE_KEY and not isValidKey(self.key_name):
            raise ValidationError('Invalid Key {} for key type {}'.format(self.key_name, self.key_type))

        # set the activate and deactivate functions based on type and set up the default state where necessary
        if self.key_type == KeyType.HOLD_KEY:
            self._is_down = False
            self.activate = self._hold_key_activate
            self.deactivate = self._hold_key_deactivate
        elif self.key_type == KeyType.TOGGLE_KEY:
            self._is_toggled = False
            self.activate = self._toggle_key_activate
            self.deactivate = self._toggle_key_deactivate
        elif self.key_type == KeyType.TYPEWRITE_KEY:
            self.activate = self._typewrite_key_activate
            self.deactivate = self._typewrite_key_deactivate
        else:
            self.activate = self._default_activate
            self.deactivate = self._default_deactivate
Example #10
0
 def checkForValidCharacters(self, msg):
     for c in msg:
         self.assertTrue(pyautogui.isValidKey(c), '"%c" is not a valid key on platform %s' % (c, sys.platform))
Example #11
0
 def checkForValidCharacters(self, msg):
     for c in msg:
         self.assertTrue(
             pyautogui.isValidKey(c),
             '"%c" is not a valid key on platform %s' % (c, sys.platform))
Example #12
0
def keyPress(key):
    key = str(key)
    if py.isValidKey(key):
        py.press(key)
    else:
        py.typewrite(key)