Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated documentation in __init__.py #809

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
20 changes: 19 additions & 1 deletion pyautogui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,12 @@ def size():

Returns:
(width, height) tuple of the screen size, in pixels.

Note that in the case of Macs with retina displays, due to greater pixel density of 2x2 per logical pixel, x and y values are multiplied by 2. As a result, locating the desired position of the screen will most likely require a line of code that looks like

pyag.click(loc.x/2,loc.y/2)

to account for the 2:1 correspondence of pixels
"""
return Size(*platformModule._size())

Expand Down Expand Up @@ -1726,8 +1732,20 @@ def hotkey(*args, **kwargs):
time.sleep(interval)


shortcut = hotkey # shortcut() is an alias for htotkey()
shortcut = hotkey # shortcut() is an alias for hotkey()

def clickButtonImage(buttonScreenshot, conf=0.6):

#Takes a screenshot of an image as input, attempts to find the button on screen and click on it
#Example: clickButtonImage('login_button.png', 0.6)

loc = pyag.locateCenterOnScreen(buttonScreenshot, confidence=conf)

try:
pyag.click((loc.x)/2, (loc.y)/2)
else:
pass # don't terminate program if we can't find the button


def failSafeCheck():
if FAILSAFE and tuple(position()) in FAILSAFE_POINTS:
Expand Down