问题在于:Wizard['Create Shortcut on Desktop'].wait('enabled').check_by_click()
check_by_click()使用click_input()方法移动真实的鼠标光标并执行真实的单击。
改用check()方法。
[编辑]如果安装程序不能正确处理BM_SETCHECK,则解决方法可能如下:checkbox = Wizard['Create Shortcut on Desktop'].wait('enabled')
if checkbox.get_check_state() != pywinauto.win32defines.BST_CHECKED:
checkbox.click()
我将在下一个pywinauto版本中分别创建方法check_by_click和check_by_click_input来修复它。
[编辑2]
我试过你的脚本与我的修复,它完美地工作(和非常快)有和没有鼠标移动。Win7 x64,32位Python 2.7,pywinauto 0.6.x,以管理员身份运行。import sys
import os
from pywinauto import Application
app = Application(backend="win32").start(r'npp.6.8.3.Installer.exe')
Wizard = app['Installer Language']
Wizard.minimize()
Wizard.NextButton.click()
Wizard = app['Notepad++ v6.8.3 Setup']
Wizard.wait('visible')
Wizard.minimize()
Wizard['Welcome to the Notepad++ v6.8.3 Setup'].wait('ready')
Wizard.NextButton.click()
Wizard.minimize()
Wizard['License Agreement'].wait('ready')
Wizard['I &Agree'].click()
Wizard.minimize()
Wizard['Choose Install Location'].wait('ready')
Wizard.Button2.click()
Wizard.minimize()
Wizard['Choose Components'].wait('ready')
Wizard.Button2.click()
Wizard.minimize()
checkbox = Wizard['Create Shortcut on Desktop'].wait('enabled')
if checkbox.get_check_state() != pywinauto.win32defines.BST_CHECKED:
checkbox.click()
Wizard.Install.click()
Wizard['Completing the Notepad++ v6.8.3 Setup'].wait('ready', timeout=30)
Wizard.minimize()
Wizard['CheckBox'].wait('enabled').click()
Wizard.Finish.click()
Wizard.wait_not('visible')