python中autos_Python pyautogui.size方法代码示例

本文整理汇总了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 dominant color in an image & his percentage

开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:19,

示例3: _Input

​点赞 6

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

# 或者: from pyautogui import size [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,

示例4: __repr__

​点赞 5

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

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

def __repr__(self):

return "%s(x: %r, y: %r, size: %r x %r)" % (

self.__class__.__name__,

self._bounds.x,

self.y,

self._bounds.width,

self._bounds.height,

)

开发者ID:mozilla,项目名称:iris,代码行数:10,

示例5: test_size

​点赞 5

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

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

def test_size(self):

width, height = pyautogui.size()

self.assertTrue(isinstance(width, int), "Type of width is %s" % (type(width)))

self.assertTrue(isinstance(height, int), "Type of height is %s" % (type(height)))

self.assertTrue(width > 0, "Width is set to %s" % (width))

self.assertTrue(height > 0, "Height is set to %s" % (height))

开发者ID:asweigart,项目名称:pyautogui,代码行数:9,

示例6: test_onScreen

​点赞 5

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

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

def test_onScreen(self):

zero = P(0, 0)

xone = P(1, 0)

yone = P(0, 1)

size = P(*pyautogui.size())

half = size / 2

on_screen = [zero, zero + xone, zero + yone, zero + xone + yone, half, size - xone - yone]

off_screen = [zero - xone, zero - yone, zero - xone - yone, size - xone, size - yone, size]

for value, coords in [(True, on_screen), (False, off_screen)]:

for coord in coords:

self.assertEqual(

value,

pyautogui.onScreen(*coord),

"onScreen({0}, {1}) should be {2}".format(coord.x, coord.y, value),

)

self.assertEqual(

value,

pyautogui.onScreen(list(coord)),

"onScreen([{0}, {1}]) should be {2}".format(coord.x, coord.y, value),

)

self.assertEqual(

value,

pyautogui.onScreen(tuple(coord)),

"onScreen(({0}, {1})) should be {2}".format(coord.x, coord.y, value),

)

self.assertEqual(

value, pyautogui.onScreen(coord), "onScreen({0}) should be {1}".format(repr(coord), value)

)

# These raise PyAutoGUIException.

with self.assertRaises(pyautogui.PyAutoGUIException):

pyautogui.onScreen([0, 0], 0)

with self.assertRaises(pyautogui.PyAutoGUIException):

pyautogui.onScreen((0, 0), 0)

开发者ID:asweigart,项目名称:pyautogui,代码行数:38,

示例7: setUp

​点赞 5

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

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

def setUp(self):

self.oldFailsafeSetting = pyautogui.FAILSAFE

self.center = P(*pyautogui.size()) // 2

pyautogui.FAILSAFE = False

pyautogui.moveTo(*self.center) # make sure failsafe isn't triggered during this test

pyautogui.FAILSAFE = True

开发者ID:asweigart,项目名称:pyautogui,代码行数:9,

示例8: get_screen_size

​点赞 5

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

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

def get_screen_size():

#screen = Gdk.Screen.get_default()

#return (screen.get_width(), screen.get_height())

return pyautogui.size()

# Activate a window

开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:8,

示例9: take_window_screenshot

​点赞 5

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

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

def take_window_screenshot(window, save_to='screenshot'):

size = window.get_geometry()

pb = Gdk.pixbuf_get_from_window(window, 0, 0, size.width, size.height)

pb.savev(save_to + '.png', 'png', (), ())

# Return a screenshot of the game

开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:8,

示例10: fit_position_to_destination

​点赞 5

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

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

def fit_position_to_destination(x, y, window_width, window_height, dest_width, dest_height):

# new coordinate = old coordinate / (window size / destination size)

new_x = x / (window_width / float(dest_width))

new_y = y / (window_height / float(dest_height))

return (int(new_x), int(new_y))

# Adjust click position

开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:9,

示例11: __init__

​点赞 5

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

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

def __init__(self, *args, **kwargs):

tk.Tk.__init__(self, *args, **kwargs)

self.title_font = tkfont.Font(family='Helvetica', size=18,

weight="bold", slant="italic")

geo = str(int(0.43 * x)) + 'x' + str(int(0.52 * y))

self.geometry(geo)

self.resizable(False, False)

self.title('Attendance Management App')

self.protocol("WM_DELETE_WINDOW", self.on_closing)

# The container is where we'll stack a bunch of frames

# on top of each other, then the one we want visible

# will be raised above the others

container = tk.Frame(self)

container.pack(side="top", fill="both", expand=True)

container.grid_rowconfigure(0, weight=1)

container.grid_columnconfigure(0, weight=1)

self.createInitialDirectories()

self.frames = {}

for F in (StartPage, StudentPanelPage, ManagerPanelPage,

CreateNewBatchPage, AddStudentPage):

page_name = F.__name__

frame = F(parent=container, controller=self)

self.frames[page_name] = frame

# Put all of the pages in the same location;

# the one on the top of the stacking order

# will be the one that is visible.

frame.grid(row=0, column=0, sticky="nsew")

self.show_frame("StartPage")

开发者ID:Marauders-9998,项目名称:Attendance-Management-using-Face-Recognition,代码行数:36,

示例12: test_simple

​点赞 5

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

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

def test_simple(self):

width, height = pyautogui.size()

toPoint = (width//2, height//2)

hc = HumanClicker()

hc.move(toPoint)

self.assertTrue(pyautogui.position() == toPoint)

开发者ID:patrikoss,项目名称:pyclick,代码行数:8,

示例13: test_randomMove

​点赞 5

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

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

def test_randomMove(self):

width, height = pyautogui.size()

toPoint = random.randint(width//2,width-1), random.randint(height//2,height-1)

hc = HumanClicker()

hc.move(toPoint)

self.assertTrue(pyautogui.position() == toPoint)

开发者ID:patrikoss,项目名称:pyclick,代码行数:8,

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值