本文整理汇总了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))
示例2: reset_game
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import hotkey [as 别名]
def reset_game():
pyautogui.hotkey('ctrl', 'r')
time.sleep(4.)
示例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..')
示例4: _press
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import hotkey [as 别名]
def _press(self, *keys, **options):
keys = self._validate_keys(keys)
ag.hotkey(*keys, **options)
示例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
示例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
示例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")
示例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"
)
示例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"
)
示例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