Python pyautogui.hotkey() Examples

The following are 10 code examples of pyautogui.hotkey(). 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: tools.py    From Dindo-Bot with MIT License 8 votes vote down vote up
def type_text(text, interval=0.1):
	for c in text:
		if c.isdigit():
			pyautogui.hotkey('shift', c, interval=0.1)
		else:
			pyautogui.press(c)
		time.sleep(interval)

# Scroll to value 
Example #2
Source File: tools.py    From Dindo-Bot with MIT License 7 votes vote down vote up
def press_key(key, interval=None):
	if interval is not None:
		time.sleep(interval)
	keys = parser.parse_key(key)
	count = len(keys)
	if count == 1:
		pyautogui.press(keys[0])
	elif count == 2:
		pyautogui.hotkey(keys[0], keys[1])

# Type text 
Example #3
Source File: toolkit.py    From guiscrcpy with GNU General Public License v3.0 7 votes vote down vote up
def copy_devpc(self):
        if self.has_modules:
            scrcpywindow = getWindowsWithTitle("scrcpy")[0]
            scrcpywindow.focus()
            auto.hotkey("ctrl", "c")
        else:
            os.system(
                "wmctrl -x -a  scrcpy && xdotool key --clearmodifiers ctrl+c") 
Example #4
Source File: slack_messenger.py    From automate-the-boring-stuff-projects with MIT License 4 votes vote down vote up
def send_message(contact, message):
    """Sends message to an active slack contact
    Args:
        contact (str): contacts name on slack
        message (str): message to send to friend
    Returns:
        None
    """
    try:
        print('5 seconds to navigate to slack app..')
        time.sleep(5)

        # Use JumpTo slack feature
        pyautogui.hotkey('command', 'k')
        time.sleep(1)
        # Enter contact name in search box, click enter
        pyautogui.typewrite(contact)
        time.sleep(1)
        pyautogui.typewrite(['enter'])
        time.sleep(1)

        active = pyautogui.locateOnScreen('active_identifier.png')
        
        if not active:
            print(f'{contact} is not active, skipped contact')
            return
        
        print('Contact is active, sending message...')
        pyautogui.typewrite(['tab'])      
        pyautogui.typewrite(message)
        pyautogui.typewrite(['enter'])

    except KeyboardInterrupt:
        print('Process was cancelled..') 
Example #5
Source File: playback.py    From xbmc with GNU General Public License v3.0 3 votes vote down vote up
def _Input(mousex=0, mousey=0, click=0, keys=None, delay='0.2'):
    import pyautogui
    '''Control the user's mouse and/or keyboard.
       Arguments:
         mousex, mousey - x, y co-ordinates from top left of screen
         keys - list of keys to press or single key
    '''
    g = Globals()
    screenWidth, screenHeight = pyautogui.size()
    mousex = int(screenWidth / 2) if mousex == -1 else mousex
    mousey = int(screenHeight / 2) if mousey == -1 else mousey
    exit_cmd = [('alt', 'f4'), ('ctrl', 'shift', 'q'), ('command', 'q')][(g.platform & -g.platform).bit_length() - 1]

    if keys:
        if '{EX}' in keys:
            pyautogui.hotkey(*exit_cmd)
        else:
            pyautogui.press(keys, interval=delay)
    else:
        pyautogui.moveTo(mousex, mousey)
        if click:
            pyautogui.click(clicks=click)

    Log('Input command: Mouse(x={}, y={}, click={}), Keyboard({})'.format(mousex, mousey, click, keys)) 
Example #6
Source File: dino_api.py    From go_dino with GNU General Public License v3.0 2 votes vote down vote up
def reset_game():
        pyautogui.hotkey('ctrl', 'r')
        time.sleep(4.) 
Example #7
Source File: __init__.py    From robotframework-imagehorizonlibrary with MIT License 2 votes vote down vote up
def _press(self, *keys, **options):
        keys = self._validate_keys(keys)
        ag.hotkey(*keys, **options) 
Example #8
Source File: toolkit.py    From guiscrcpy with GNU General Public License v3.0 1 votes vote down vote up
def copy_pc2dev(self):
        if self.has_modules:
            scrcpywindow = getWindowsWithTitle("scrcpy")[0]
            scrcpywindow.focus()
            auto.hotkey("ctrl", "shift", "c")
            logging.warning("NOT SUPPORTED ON WINDOWS")
        else:
            os.system(
                "wmctrl -x -a  scrcpy && "
                "xdotool key --clearmodifiers ctrl+shift+c"
            ) 
Example #9
Source File: toolkit.py    From guiscrcpy with GNU General Public License v3.0 1 votes vote down vote up
def fullscreen(self):
        if self.has_modules:
            scrcpy_window = getWindowsWithTitle("scrcpy")[0]
            scrcpy_window.focus()
            auto.hotkey("ctrl", "f")
        else:
            os.system(
                "wmctrl -x -a  scrcpy && "
                "xdotool key --clearmodifiers ctrl+f"
            ) 
Example #10
Source File: dolphin.py    From phillip with GNU General Public License v3.0 0 votes vote down vote up
def __call__(self):
    args = [self.exe, "--user", self.user]
    if not self.netplay:
      args += ["--exec", self.iso]
    if self.movie is not None:
      args += ["--movie", self.movie]
    
    print(args)
    process = subprocess.Popen(args)
    
    if self.netplay:
      import time
      time.sleep(2) # let dolphin window spawn
      
      import pyautogui
      #import ipdb; ipdb.set_trace()
      pyautogui.click(150, 150)
      #pyautogui.click(50, 50)
      time.sleep(0.5)
      pyautogui.hotkey('alt', 't') # tools

      time.sleep(0.5)
      pyautogui.hotkey('n') # netplay
      
      time.sleep(1) # allow netplay window time to spawn
      
      #return process
      
      #pyautogui.hotkey('down') # traversal
      
      #for _ in range(3): # move to textbox
      #  pyautogui.hotkey('tab')
      
      #pyautogui.typewrite(self.netplay) # write traversal code
      
      #return process
      
      time.sleep(0.1)
      # connect
      #pyautogui.hotkey('tab')
      pyautogui.hotkey('enter')

      #import ipdb; ipdb.set_trace()
    
    return process