python - PyAutoGUI,停止命令

标签 python pyautogui

我实际上正在使用 Pyautogui 编写脚本,它控制我的鼠标并使用我的浏览器。我的问题是,如果最后一次点击不是超文本链接或类似的点击,我希望脚本停止以下操作或以下鼠标移动和点击!

这是我的代码:

import pyautogui

pyautogui.moveTo(118, 417, duration = 1) #immeuble A11 adductabilité
pyautogui.click(117, 418,)
pyautogui.moveTo(118, 418, duration = 1)
pyautogui.hotkey('ctrl', 'c')
pyautogui.moveTo(419, 1064, duration = 0.1) #go down to Internet explorer
pyautogui.click(419, 1064,)
pyautogui.moveTo(543, 955, duration = 0.1)
# click on Internet explorer
pyautogui.click(543, 955,)
pyautogui.moveTo(1630, 112, duration = 0.1) # click on Rechercher (IPON)
pyautogui.click(1630, 112,)
pyautogui.moveTo(1661, 470, duration = 0.1) # click on Rechercher IMMEUBLE
pyautogui.click(1661, 470,)

最佳答案

是否可以检查它在屏幕上的位置,如果悬停在错误的位置,则取消代码?

关于python - PyAutoGUI,停止命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59842777/

相关文章:

python - 重定向到 ?next=/accounts/social/connections/in django-allauth

python - 找到 x,其中 y 最小

python - 如何在 macOS 上更快地截取屏幕截图?

python - 代码可以在 pyCharm 中运行,但不能在 Visual Studio Code 中运行

python - "TypeError: ' 诠释 ' object does not support item assignment";迭代问题

python - 将数据框转换为 LaTeX

python-3.x - keyDown 功能不适用于 shift 键

python - 使用 Pyinstaller 将脚本转换为 exe 后的 PyAutoGui [WinError 2]

python - Django 错误 : Field 'id' expected a number but got '{}'

python - PyAutoGui 无法在全屏程序中定位图像