當前位置: 首頁>>代碼示例>>Python>>正文


Python pyautogui.hotkey方法代碼示例

本文整理匯總了Python中pyautogui.hotkey方法的典型用法代碼示例。如果您正苦於以下問題:Python pyautogui.hotkey方法的具體用法?Python pyautogui.hotkey怎麽用?Python pyautogui.hotkey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyautogui的用法示例。


在下文中一共展示了pyautogui.hotkey方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _Input

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
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)) 
開發者ID:Sandmann79,項目名稱:xbmc,代碼行數:26,代碼來源:playback.py

示例2: reset_game

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
def reset_game():
        pyautogui.hotkey('ctrl', 'r')
        time.sleep(4.) 
開發者ID:pauloalves86,項目名稱:go_dino,代碼行數:5,代碼來源:dino_api.py

示例3: send_message

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
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..') 
開發者ID:kudeh,項目名稱:automate-the-boring-stuff-projects,代碼行數:36,代碼來源:slack_messenger.py

示例4: _press

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
def _press(self, *keys, **options):
        keys = self._validate_keys(keys)
        ag.hotkey(*keys, **options) 
開發者ID:eficode,項目名稱:robotframework-imagehorizonlibrary,代碼行數:5,代碼來源:__init__.py

示例5: press_key

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
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 
開發者ID:AXeL-dev,項目名稱:Dindo-Bot,代碼行數:13,代碼來源:tools.py

示例6: type_text

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
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 
開發者ID:AXeL-dev,項目名稱:Dindo-Bot,代碼行數:11,代碼來源:tools.py

示例7: copy_devpc

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
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") 
開發者ID:srevinsaju,項目名稱:guiscrcpy,代碼行數:10,代碼來源:toolkit.py

示例8: copy_pc2dev

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
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"
            ) 
開發者ID:srevinsaju,項目名稱:guiscrcpy,代碼行數:13,代碼來源:toolkit.py

示例9: fullscreen

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
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"
            ) 
開發者ID:srevinsaju,項目名稱:guiscrcpy,代碼行數:12,代碼來源:toolkit.py

示例10: __call__

# 需要導入模塊: import pyautogui [as 別名]
# 或者: from pyautogui import hotkey [as 別名]
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 
開發者ID:vladfi1,項目名稱:phillip,代碼行數:47,代碼來源:dolphin.py


注:本文中的pyautogui.hotkey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。