python 为什么pyautogui点击鼠标指针的位置而不是定义的位置?

r1zk6ea1  于 2023-01-01  发布在  Python
关注(0)|答案(1)|浏览(145)
  • 下面是我的代码和.click函数是点击一个点,我的鼠标指针是。但我需要找到一个图像的东西,需要点击。任何人都有一个解决方案??*
import pyautogui

import os

os.system(r'C:\Users\User\AppData\Roaming\Zoom\bin\Zoom.exe')

position = pyautogui.locateOnScreen(r"join_button.png")

pyautogui.click(position)
nimxete2

nimxete21#

这个答案可能有点晚了,但我很确定你必须在屏幕上定位后使用pyautogui.center(position)。所以,代码看起来像这样:

import pyautogui

import os

os.system(r'C:\Users\User\AppData\Roaming\Zoom\bin\Zoom.exe')

position = pyautogui.locateOnScreen(r"join_button.png")
center_pos = pyautogui.center(position)

pyautogui.click(center_pos)

相关问题