尝试在下面调试我的代码,它应该自行循环执行,直到完成相关的图像识别检查为止。循环工作正常,但是应该在返回值为{1的rsa_clip
的情况下返回None
。
代码;
def mbox(title, text, style):
return ctypes.windll.user32.MessageBoxW(0, text, title, style)
def rsa():
try:
# look for RSA icon in taskbar
pyautogui.locateOnScreen(os.path.expanduser(os.sep.join(["~", "My Documents", 'rsa_icon.png'])),
confidence=0.9)
try:
# see if there is enough time to copy the RSA code
pyautogui.locateOnScreen(os.path.expanduser(os.sep.join(["~", "My Documents", 'rsa_pips.png'])),
confidence=0.9)
print('pips found')
x = pyautogui.locateCenterOnScreen(
os.path.expanduser(os.sep.join(["~", "My Documents", 'rsa_copy.png'])), confidence=0.9)
print('copy button found')
pyautogui.click(x)
print('copy button clicked')
rsa_clip = 1
print(rsa_clip)
print('From the RSA function')
print(rsa_clip)
return rsa_clip
except:
# explaining not enought time and looping
mbox('Warning', 'Please wait for timeout on current token',0)
time.sleep(20)
rsa()
except:
# open RSA application
rsa_p = r'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\RSA\RSA SecurID Token'
os.chdir(rsa_p)
mbox('Info', 'Please enter your Pin', 0)
os.startfile('RSA SecurID Token')
time.sleep(5)
rsa()
print(rsa())
输出:
pips found
copy button found
copy button clicked
1
From the RSA function
1
None