在这个问题中,keyboard.press("tab"),一个圆圈出现在我正在处理的应用程序中。然后我想找到这个圆的坐标并用鼠标左键单击,但我的代码不起作用。我哪里会犯错。
import pyautogui
import time
import keyboard
def monsterclick():
keyboard.press("tab")
x, y = pyautogui.position("tab")
while True:
monsterclick()
break
使用
pyautogui.position
您正在保存当前光标的 x 和 y,您永远不会在屏幕上找到圆圈。您可以使用 pyautogui.click('circle.png')
定位并单击您作为参数提供的图像:
import pyautogui
import time
import keyboard
def monsterclick():
keyboard.press("tab")
# This will locate and click the circle. If the circle is not found it will return none
x, y = pyautogui.click('circle.png')
while True:
monsterclick()
break