当前位置: 首页 > 工具软件 > Hotkey > 使用案例 >

python autohotkey_Python pyautogui.hotkey方法代码示例

元俊雅
2023-12-01

本文整理汇总了Python中pyautogui.hotkey方法的典型用法代码示例。如果您正苦于以下问题:Python pyautogui.hotkey方法的具体用法?Python pyautogui.hotkey怎么用?Python pyautogui.hotkey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块pyautogui的用法示例。

在下文中一共展示了pyautogui.hotkey方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _Input

​点赞 6

# 需要导入模块: 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,

示例2: reset_game

​点赞 5

# 需要导入模块: import pyautogui [as 别名]

# 或者: from pyautogui import hotkey [as 别名]

def reset_game():

pyautogui.hotkey('ctrl', 'r')

time.sleep(4.)

开发者ID:pauloalves86,项目名称:go_dino,代码行数:5,

示例3: _press

​点赞 5

# 需要导入模块: 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,

示例4: send_message

​点赞 5

# 需要导入模块: 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,

示例5: press_key

​点赞 5

# 需要导入模块: 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,

示例6: type_text

​点赞 5

# 需要导入模块: 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,

示例7: copy_devpc

​点赞 5

# 需要导入模块: 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,

示例8: copy_pc2dev

​点赞 5

# 需要导入模块: 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,

示例9: fullscreen

​点赞 5

# 需要导入模块: 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,

示例10: __call__

​点赞 4

# 需要导入模块: 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,

注:本文中的pyautogui.hotkey方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

 类似资料: