我制作的pyautogui脚本中发生内存泄漏。我不知道它来自哪里或可能是什么原因。
该脚本可完美按下空格以进行游戏中的技能检查。因此,它只是检查像素(阵列中的像素)何时变成白色,然后更改颜色以指示技能检查栏已通过。
我不觉得我在这里做任何不寻常的事情都会导致内存泄漏,不是在pyautogui一边吗?
import pyautogui as auto
import keyboard
import random
import time
import random
circleLocations = [(1023, 522), (1025, 527), (1025, 537), (1024, 548), (1022, 560), (1018, 568)]
def delay(value1 = 0.05, value2 = 0.2):
return random.uniform(value1,value2)
def perfectSpacePress(x, y):
while auto.pixelMatchesColor(x, y, (255,255,255)):
print("waiting")
time.sleep(delay(0.1,0.15 ))
auto.press(' ')
print("PressedCircleSpace")
def checkCircle():
for location in circleLocations:
if auto.pixelMatchesColor(location[0], location[1], (255,255,255)):
perfectSpacePress(location[0], location[1])
try:
while True:
checkCircle()
time.sleep(0.1)
except KeyboardInterrupt:
print('\nDone.')