我正在尝试使用python与pywinauto框架控制Windows媒体播放器。我可以通过app.WindowsMediaPlayer.MenuSelect(“View-> GoTo-> Library”)访问菜单 但是当我尝试访问库项目时,使用对话框无法执行此操作。 类似地,左边的任务栏想要直接访问它而无需访问菜单,只需单击左侧的按钮.... 需要帮助...
答案 0 :(得分:0)
>>> wmp.WindowsMediaPlayer.MenuSelect("View->Library")
>>> wmp.WindowsMediaPlayer.print_control_identifiers()
Control Identifiers:
WMPAppHost - 'WMPAppHost' (L40, T152, R731, B648)
'WMPAppHost' 'WMPAppHostWMPAppHost'
WMP Skin Host - '' (L40, T188, R731, B588)
'' '0' '1' 'WMP Skin Host'
ATL:5BB55150 - 'LibraryContainer' (L40, T188, R731, B588)
'ATL:5BB55150' 'LibraryContainer' 'LibraryContainerATL:5BB55150'
ATL:5BB550C0 - '' (L190, T220, R193, B588)
'2' 'ATL:5BB550C0'
ToolbarWindow32 - '' (L40, T188, R40, B188)
'3' 'Toolbar' 'Toolbar0' 'Toolbar1'
ToolbarWindow32 - 'View Toolbar' (L416, T189, R461, B219)
'Toolbar2' 'View Toolbar' 'View ToolbarToolbar'
ToolbarWindow32 - '' (L705, T193, R729, B215)
'4' 'Toolbar3'
ToolbarWindow32 - 'Command Toolbar' (L44, T189, R414, B219)
'Command Toolbar' 'Command ToolbarToolbar' 'Toolbar4'
Edit - 'Search' (L465, T197, R663, B213)
'5' 'Edit'
ToolbarWindow32 - '' (L663, T194, R689, B214)
'6' 'Toolbar5'
ToolbarWindow32 - '' (L689, T194, R703, B214)
'7' 'Toolbar6'
SysListView32 - 'PrimaryListView' (L193, T220, R731, B588)
'ListView' 'PrimaryListView' 'PrimaryListViewListView'
SysHeader32 - '' (L193, T220, R716, B244)
'8' 'Header'
SysTreeView32 - 'Library Treeview' (L40, T220, R190, B538)
'Library Treeview' 'Library TreeviewTreeView' 'TreeView'
ATL:5BB62F40 - 'ServiceBar' (L40, T538, R190, B588)
'ATL:5BB62F40' 'ServiceBar' 'ServiceBarATL:5BB62F40'
ToolbarWindow32 - 'Service Selector' (L46, T541, R184, B585)
'Service Selector' 'Service Selector0' 'Service Selector1' 'Service SelectorToolbar' 'Servic
e SelectorToolbar0' 'Service SelectorToolbar1' 'Toolbar7'
ToolbarWindow32 - 'Service Toolbar' (L184, T541, R184, B585)
'Service Toolbar' 'Service ToolbarToolbar' 'Toolbar8'
ToolbarWindow32 - 'Service Selector' (L184, T541, R184, B585)
'Service Selector2' 'Service SelectorToolbar2' 'Toolbar9'
PrimaryListView看起来可能是我们需要的 - 所以让我们通过在该控件周围画一个框来检查。
>>> wmp.WindowsMediaPlayer.PrimaryListView.DrawOutline()
>>>
似乎很好:)。那么让我们看看我们是否可以从列表视图中获取项目
>>> wmp.WindowsMediaPlayer.PrimaryListView.ItemCount()
1217
到目前为止一切顺利
>>> for item_index in range(wmp.WindowsMediaPlayer.PrimaryListView.ItemCount()):
... print wmp.WindowsMediaPlayer.PrimaryListView.GetItem(item_index)
...
{'text': u'', 'state': 0L, 'indent': 240, 'image': 0}
{'text': u'', 'state': 0L, 'indent': 240, 'image': 0}
{'text': u'', 'state': 0L, 'indent': 240, 'image': 0}
...
嗯=现在看起来不太好:( 而且我在没有更多研究的情况下陷入困境