我确实从列表中选择了一个项目(使用下面的代码),我现在需要发送一个ctrl+E
. 问题是 SendKeys 方法不知何故不可用,我无法使用SendKeys('^e')
。(此快捷方式将在同上应用程序中编辑所选项目)
from pywinauto.application import Application
from pywinauto import findbestmatch
from pywinauto import keyboard #not sure if I need to import it
ditto=Application().connect(path='Ditto.exe')
#---- print all available methods of the object
print(dir(ditto.ditto.SysListView321.wrapper_object())) #( the list does not contains 'SendKeys')
#-----Find and select the item (containing 'xxx') in the SysListView321
#The list of texts to search through
texts = ditto.ditto.SysListView321.texts()[1:] #skip window text itself, use only item texts
# The list of items corresponding (1 to 1) to the list of texts to search through.
items = ditto.ditto.SysListView321.items() #>>[]
found_item = findbestmatch.find_best_match('xxx', texts, items, limit_ratio=0.1).Select()
一些错误:
ditto.ditto.SysListView321.SendKeys('^e')
... WindowSpecification 类没有“SendKeys”方法
ditto.ditto.SysListView321.keyboard.SendKeys('^e')
... findbestmatch.MatchError:在'dict_keys(['','Header'])'中找不到'keyboard'
[编辑](更多错误)
ditto.ditto.SysListView321.type_keys('^e')
win32gui.SetForegroundWindow(self.handle) pywintypes.error: (0, 'SetForegroundWindow', 'No error message is available')
keyboard.send_keys('^e')
AttributeError:模块 'pywinauto.keyboard' 没有属性 'send_keys'
(ps.初学者:app.Ditto
相当于app.window(best_match='Ditto')
)