我一直在尝试为自己实现一个过程的自动化,基本上点击网页上的很多东西。你知道吗
我试着用pyAutoGui来找到我需要的东西,然后点击和输入。我发现的问题是,如果屏幕分辨率或浏览器显示大小以任何方式发生变化,它就会停止工作(它会将参考图像与拍摄的屏幕截图进行比较)。因此,目前我需要的东西,找到html元素的位置,并点击它(pyAutoGui手点击如果需要)。你知道吗
主要的问题是我需要使用runas打开internetexplorer,因为每次程序运行时,都有不同的用户。 我看到许多人建议使用web工具包来打开自己的浏览器会话,但我不知道他们是否能够以不同的用户身份运行。你知道吗
有人能对这件事有所了解吗?你知道吗
编辑:一些代码。你知道吗
在屏幕上查找参考图像的功能(仅当图像像素完美时才起作用)
def FindImageAndClick(ImagePath:str, numberOfTries:int):
counter = 0
while counter <numberOfTries:
try:
x, y = pyautogui.locateCenterOnScreen(ImagePath, grayscale=True)
print('encontrado posicoes x='+str(x)+' e y='+str(y))
break
except:
time.sleep(2.0)
counter += 1
if counter==numberOfTries:
return False
pyautogui.moveTo(x,y)
pyautogui.click()
return True
使用运行方式打开IE(程序启动时提供用户凭据):
iePath='"'+ '\\'+'"'+os.getenv("SystemDrive")+'\Program Files\Internet Explorer\iexplore.exe\\'+'"'
website = corporate website
print (iePath + website)
o = subprocess.Popen('runas.exe /user:domain\%s %s %s' %(currentUser, iePath, website))
time.sleep(1.0)
pyautogui.typewrite(currentPassword)
pyautogui.press('enter')
Jus重申只要分辨率、浏览器缩放级别等保持不变,程序就可以正常工作。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐