Python pyautogui.keyDown() Examples

The following are 5 code examples of pyautogui.keyDown(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyautogui , or try the search function .
Example #1
Source File: keyboard_unix.py    From LPHK with GNU General Public License v3.0 6 votes vote down vote up
def press(key):
    # keyboard_controller.press(key)
    pyautogui.keyDown(key) 
Example #2
Source File: gmail_generator.py    From gmail-generator with MIT License 6 votes vote down vote up
def locate_gmail():
    
    #Sleep for a while and wait for Firefox to open
    time.sleep(3)

    # Printing message
    msg(1,'Opening Gmail...')

    # Typing the website on the browser
    pyautogui.keyDown('ctrlleft');  pyautogui.typewrite('a'); pyautogui.keyUp('ctrlleft')
    pyautogui.typewrite('https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ltmpl=default')
    pyautogui.typewrite('\n')
    
    # Wait for a while until the website responds
    time.sleep(6)

    # Print a simple message
    msg(1,'Locating the form...')

    # Locate the form
    pyautogui.press('tab')
 
    time.sleep(2)

    _gmail_ = pyautogui.locateOnScreen('images/gmail_form.png')
    formx, formy = pyautogui.center(_gmail_)
    pyautogui.click(formx, formy)
    
    # Check and print message
    if not pyautogui.click(formx, formy):
        msg(1,'Located the form.')
    else:
        msg(3,'Failed to locate the form.')
        ext()


# Function used to randomize credentials 
Example #3
Source File: _keyboard.py    From robotframework-imagehorizonlibrary with MIT License 6 votes vote down vote up
def type_with_keys_down(self, text, *keys):
        '''Press keyboard keys down, then write given text, then release the
        keyboard keys.

        See valid keyboard keys in `Press Combination`.

        Examples:

        | Type with keys down | write this in caps  | Key.Shift |
        '''
        valid_keys = self._validate_keys(keys)
        for key in valid_keys:
            ag.keyDown(key)
        ag.typewrite(text)
        for key in valid_keys:
            ag.keyUp(key) 
Example #4
Source File: keyboard.py    From iris with Mozilla Public License 2.0 5 votes vote down vote up
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 #5
Source File: Commands.py    From roc with MIT License 5 votes vote down vote up
def do_work(self):
        pyautogui.keyDown('s')
        time.sleep(1)
        pyautogui.keyUp('s')
        pyautogui.keyDown('s')
        time.sleep(1)
        pyautogui.keyUp('s')
        pyautogui.keyDown('s')
        time.sleep(1)
        pyautogui.keyUp('s')
        pyautogui.keyDown('s')
        time.sleep(1)
        pyautogui.keyUp('s')
        print('Zoomed out.')
        self.next()