作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我看不出有什么区别
import pyautogui
pyautogui.locateOnScreen("anImage")
和
import pyautogui
pyautogui.locateOnScreen("anImage", minSearchTime=10)
文档中没有关于 minSearchTime
的解释或引用。
最佳答案
当您想要等待一段时间才能显示图像时,这很有用。 PyAutoGUI 将继续进行屏幕截图并搜索图像,直到 minSearchTime 过去。我从源代码中得到了这个:
def locateOnScreen(image, minSearchTime=0, **kwargs):
"""minSearchTime - amount of time in seconds to repeat taking
screenshots and trying to locate a match. The default of 0 performs
a single search.
"""
start = time.time()
while True:
try:
screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here.
retVal = locate(image, screenshotIm, **kwargs)
try:
screenshotIm.fp.close()
except AttributeError:
# Screenshots on Windows won't have an fp since they came from
# ImageGrab, not a file. Screenshots on Linux will have fp set
# to None since the file has been unlinked
pass
if retVal or time.time() - start > minSearchTime:
return retVal
except ImageNotFoundException:
if time.time() - start > minSearchTime:
raise
关于python - PyAutoGUIlocateOnScreen 方法中 minSearchTime 参数的目标是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39370253/
我看不出有什么区别 import pyautogui pyautogui.locateOnScreen("anImage") 和 import pyautogui pyautogui.locateOn
我是一名优秀的程序员,十分优秀!