要求:
从“添加”中删除应用程序。此代码需要python 64位。我要从中执行卸载操作的python脚本需要32位python,因为有些DLL是使用32位python编译的。
反正我能做到吗?是否有可能在python的两种体系结构之间切换?我想知道我能否将卸载脚本保留为单独的python模块,并以某种方式强制其使用python 64位运行。可能吗?
Python专家请帮忙。
Python版本:2.7.12
结构:
My python application (require 32 bit python)
Uninstall() (require 64 bit python)
My script continues (require 32 bit python)
卸载代码()
import pywinauto
pywinauto.Application().Start(r'explorer.exe')
explorer = pywinauto.Application().Connect(path='explorer.exe')
# Go to "Control Panel -> Programs and Features"
NewWindow = explorer.Window_(top_level_only=True, active_only=True, class_name='CabinetWClass')
try:
print "hello"
NewWindow.AddressBandRoot.ClickInput()
NewWindow.TypeKeys(r'Control Panel\Programs\Programs and Features{ENTER}', with_spaces=True, set_foreground=False)
ProgramsAndFeatures = explorer.Window_(top_level_only=True, active_only=True, title='Programs and Features', class_name='CabinetWClass')
# Wait while list of programs is loading
explorer.WaitCPUUsageLower(threshold=5)
item_7z = ProgramsAndFeatures.FolderView.GetItem('7-Zip 9.20 (x64 edition)')
item_7z.EnsureVisible()
item_7z.ClickInput(button='right', where='icon')
explorer.PopupMenu.MenuItem('Uninstall').Click()
Confirmation = explorer.Window_(title='Programs and Features', class_name='#32770', active_only=True)
if Confirmation.Exists():
Confirmation.Yes.ClickInput()
Confirmation.WaitNot('visible')
WindowsInstaller = explorer.Window_(title='Windows Installer', class_name='#32770', active_only=True)
if WindowsInstaller.Exists():
WindowsInstaller.WaitNot('visible', timeout=20)
SevenZipInstaller = explorer.Window_(title='7-Zip 9.20 (x64 edition)', class_name='#32770', active_only=True)
if SevenZipInstaller.Exists():
SevenZipInstaller.WaitNot('visible', timeout=20)
if '7-Zip 9.20 (x64 edition)' not in ProgramsAndFeatures.FolderView.Texts():
print "OK"
finally:
NewWindow.Close()
答案 0 :(得分:0)
您考虑过使用两种不同的方法吗?
selectedItem
函数。