【发布时间】:2020-11-18 15:45:55
【问题描述】:
我只想将下面的整个代码重复为我设置的值,如果我设置为 10,那么我的代码运行 10 次而无需征求我的任何许可或输入。停止的唯一方法是等待或手动停止如果有人知道请解决我的问题.. 重复完整代码而不是某些行
从 pyclick 导入 HumanClicker 导入pyautogui 导入数学 进口时间 随机导入 导入操作系统 导入系统 从时间导入睡眠 hc = HumanClicker() pyautogui.FAILSAFE = True
睡眠(4) coords = pyautogui.locateCenterOnScreen('calc.png', confidence=0.6)
如果坐标为无: print("图片未找到")
其他: hc.move((坐标), 2) hc.click()
coords1 = pyautogui.locateOnScreen('calc1.png') 如果 coords1 为无: print('屏幕上没有找到图片!')
其他: hc.move((coords1), 2) hc.click()
coords2 = pyautogui.locateOnScreen('calc2.png') 如果 coords2 为无: print('屏幕上没有找到图片!')
其他: hc.move((coords2), 2) hc.click()
coords3 = pyautogui.locateOnScreen('calc4.png', confidence=0.6) 如果 coords3 为无: print('屏幕上没有找到图片!')
其他: hc.move((coords3), 0.5) hc.click()
【问题讨论】:
-
你在想什么类型的循环?有没有想退出循环的情况?
-
请添加更多细节你想要实现什么,“循环或我的整体保持我的代码自动运行的东西”没有太多的信息价值
-
你想重复哪些部分?您希望循环何时停止?您在尝试实现循环时遇到了哪些问题?你认为增加睡眠会有帮助吗?