How to get pyautogui's click working on mac?

℡╲_俬逩灬. 提交于 2020-03-23 08:14:45

问题


pyautogui's click method's issue: I am running the script from Spyder, if I click anything on Spyder's window the click works fine.

If I execute a script to open Outlook, then click on anything, the click does not happen. Although I am able to use the "moveTo" functionality properly.

Things I have tried as suggested by doing google search:

pyautogui.click()
pyautogui.click()

OS : mac os high sierra

Note: In order to reach any located image I have to do coordinates/2, as it is a Retina 2x display.

Any workaround or any help will be greatly appreciated.


回答1:


To anyone who might stumble into the same issue on a Mac, I was able to get it working by using a workaround that is using the pynput library.

Code:

import pyautogui
from pynput.mouse import Button, Controller

mouse = Controller()
pyautogui.moveTo(x,y)
mouse.click(Button.left)



回答2:


I was also facing same issue, Here is what I tried :

Just add one more line pyautogui.dragTo() to focus on that particular selected area:

pyautogui.moveTo(990,28)
pyautogui.dragTo() 
pyautogui.click()


来源:https://stackoverflow.com/questions/58066712/how-to-get-pyautoguis-click-working-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!