1:获取全量窗口信息

可以在全量信息中找出获焦窗口的WinId,将该WinId作为参数传递给其他命令以获取相关信息。

hdc shell hidumper -s WindowManagerService -a '-a'

使用示例:
注意到 Focus window:3 即当前获焦窗口

-------------------------------[ability]-------------------------------


----------------------------------WindowManagerService----------------------------------
-------------------------------------ScreenGroup 1-------------------------------------
WindowName           DisplayId Pid     WinId Type Mode Flag ZOrd Orientation [ x    y    w    h    ]
settings0            0         3179    3     1    1    0    1    0           [ 0    0    1920 1080 ]
EntryView            0         3003    1     2001 1    0    0    8           [ 0    0    1920 1080 ]
---------------------------------------------------------------------------------------
SystemUi_VolumePanel 0         2949    2     2111 1    0    -1   0           [ 0    0    0    0    ]
Focus window: 3
total window num: 3



2:输出焦点树

hdc shell hidumper -s WindowManagerService -a '-w 3 -focus'

 使用过滤语句过滤使得只显示获焦节点
 

hdc shell hidumper -s WindowManagerService -a '-w 3 -focus' | findstr *

使用示例: 

  |-> root(Scope*) id:0 childSize:1
    |-> page(Scope*) id:2 childSize:1
      |-> Column(Scope*) id:5 childSize:1
        |-> Column(Scope*) id:6 childSize:1
          |-> Stack(Scope*) id:8 childSize:2
            |-> Row(Scope*) id:11 childSize:2
              |-> Column(Scope*) id:17 childSize:3
                |-> List(Scope*) id:20 childSize:8
                  |-> ListItem(Scope*) id:25 idstr:设置-1 childSize:1
                    |-> Flex(Scope*) id:52 childSize:4
                      |-> Text(Node*) id:56 idstr: [Painted] childSize:0

输出层级页面队列:
 

hdc shell hidumper -s WindowManagerService -a '-w 3 -focusmanager'

 3:节点显示规则:

  • 带* 号的都是当前获焦节点
 |-> ListItem(Scope*) id:25 idstr:设置-1 childSize:1
  • 带(-)的节点,表示该节点不可获焦
                      |-> (-)Text(Node) id:47 Focusable:false childSize:0
                      |-> (-)Text(Node) id:49 Focusable:false childSize:0
                      |-> (-)Image(Node) id:50 Focusable:false childSize:0
  • 不带(-)的节点,表示该节点可获焦
     
|-> Flex(Scope) id:72 childSize:4
       |-> Text(Node) id:76 idstr: childSize:0

4: dump所有tree:
 

hdc shell hidumper -s WindowManagerService -a '-w 3 -inspector'

 根据elementID 进一步查看具体信息
 

hdc shell hidumper -s WindowManagerService -a '-w 3 -inspector 39'

示例如下:
 

----------------------------------WindowManagerService----------------------------------
WindowName: settings0
DisplayId: 0
WindowRect: [ 0, 0, 1920, 1080 ]
TouchHotAreas: [ 0, 0, 1920, 1080 ]
bundleName:com.ohos.settings
moduleName:tv
 LastRequestVsyncTime: 2665924369108
 transactionFlags: [3179,0]
 last vsyncId: 1157
 finishCount:[ ]
  |-> Text childSize:0
      ID:  39
      parent ID:  37
      child IDs:
      component type:  Text
      accessibilityCustomRole:
      text:  图像模式、屏幕亮度、护眼模式
      window id: 3
      width:  505
      height:  42
      left:  1214
      top:  715
      right:  1719
      bottom:  757
      enabled:  true
      focusable:  false
      focused:  false
      visible:  true
     
      bundle name:  com.ohos.settings
      page id: 1
      page path:  pages/settingList
      ...

      childWindowId:  0


 


 

 

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐