通过pywinauto自动化某些步骤时遇到麻烦。 似乎无法打开wbemtest(需要自动化的过程)。
我的代码是使用SWAPY生成的:
from pywinauto.application import Application
app = Application().Start(cmd_line=u'"C:\\Windows\\System32\\wbem\\wbemtest.exe" ')
window = app.Dialog
window.Wait('ready')
button = window.Button
button.Click()
window2 = app.Dialog
edit = window2.Edit
edit.ClickInput()
edit.Select()
edit.DoubleClickInput('\securitycenter2')
button2 = window.Button7
button2.Click()
window3 = app.Dialog
edit2 = window3.Edit
edit2.ClickInput('\antivirusproduct')
button3 = window3.OK
button3.Click()
问题是它似乎可以与其他应用程序一起使用(在potplayer上测试),但是使用wbemtest时出现以下错误:
Traceback (most recent call last):
File "C:\Users\Vali\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pywinauto\application.py", line 992, in start
start_info) # STARTUPINFO structure.
pywintypes.error: (2, 'CreateProcess', 'The system cannot find the file specified.')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Vali/PycharmProjects/untitled/wsc.py", line 3, in <module>
app = Application().Start(cmd_line=u'"C:\\Windows\\System32\\wbem\\wbemtest.exe" ')
File "C:\Users\Vali\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pywinauto\application.py", line 997, in start
raise AppStartError(message)
pywinauto.application.AppStartError: Could not create the process ""C:\Windows\System32\wbem\wbemtest.exe" "
Error returned by CreateProcess: (2, 'CreateProcess', 'The system cannot find the file specified.')
答案 0 :(得分:1)
问题是我在64位Windows上使用python x86版本。必须将wbem切换为sysnative才能实现