本文整理汇总了Python中pyautogui.size方法的典型用法代码示例。如果您正苦于以下问题:Python pyautogui.size方法的具体用法?Python pyautogui.size怎么用?Python pyautogui.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块pyautogui的用法示例。
在下文中一共展示了pyautogui.size方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: adjust_click_position
点赞 6
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import size [as 别名]
def adjust_click_position(click_x, click_y, window_width, window_height, dest_x, dest_y, dest_width, dest_height):
# get screen size
screen_width, screen_height = pyautogui.size()
if screen_width > window_width and screen_height > window_height:
# fit position to destination size
new_x, new_y = fit_position_to_destination(click_x, click_y, window_width, window_height, dest_width, dest_height)
#print('new_x: %d, new_y: %d, dest_x: %d, dest_y: %d' % (new_x, new_y, dest_x, dest_y))
# scale to screen
x = new_x + dest_x
y = new_y + dest_y
else:
x = click_x
y = click_y
return (x, y)
# Perform a simple click or double click on x, y position
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:18,
示例2: get_color_percentage
点赞 6
# 需要导入模块: import pyautogui [as 别名]
# 或者: from pyautogui import size [as 别名]
def get_color_percentage(image, expected_color, tolerance=10):
# get image colors
width, height = image.size
image = image.convert('RGB')
colors = image.getcolors(width * height)
# check if the expected color exist
expected_color_count = 0
for count, color in colors:
if color_matches(color, expected_color, tolerance):
expected_color_count += count
# convert to percentage
if height == 0: height = 1
if width == 0: width = 1
percentage = ((expected_color_count / height) / float(width)) * 100
return round(percentage, 2)
# Return the domi