Microsoft Edge: Get Window URL and Title

后端 未结 7 1141
滥情空心
滥情空心 2020-12-06 15:33

Previously I was using ShellWindows() API for IE to get the window Title and URL for my application Now with new development, Microsoft Edge is new and has many features und

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 15:54

    I've just pointed the Inspect SDK tool to Edge, when Edge showed 3 tabs. (Inspect uses the UIA Client API to access all the UI shown in apps, and if you have the SDK installed, can be found in places like "C:\Program Files (x86)\Windows Kits\10\bin\x64".) The image below shows that the UIA element for the main Edge window has a child element which is a list. Inspect also shows me that the AutomationId of that child element is "TabsList", (but that's not shown in the image below). The set of list items that are direct children of the TabsList, have names which are the titles of the pages loaded in Edge. So it looks like it's relatively straightforward to access the titles of the pages loaded in Edge.

    However, it looks like it's not so clean to access the URL associated with a page. When I looked through what Inspect was showing me, I only found the URL in the UIA tree for the page that's currently being shown. The URL can be found from the name of an element with a control type of Pane, which is beneath a chain of Pane elements. I don't know what the most robust way of reaching the element with the URL is. For example, if it's the only element with a UIA ClassName of "InternetExplorer_Server", or its parent is the only element with a ClassName of "TabWindowClass", then maybe a single call to FindFirstBuildCache() could get you close to the element you're interested in. (It looks like neither element has an AutomationId to search for.)

    Thanks,

    Guy

提交回复
热议问题