I'm googling and trying to solve this problem already one whole day, so I think it's right time to ask.
In my C# code, I'm trying to get hwnds of IE tabs in the same order as they are displayed in the browser.
Important note: I cannot do it with URL or Title since browser can contain two tabs with same page opened.
For that I tried different approaches:
I used Interop.SHDocVw library, where I'm trying to get all IE windows and get their tab hwnd. This approach is working fine, but tabs are ordered by date of creation. So if I open 4 tabs in IE it returns me the right order, but when I move one tab to first position, it's still shown as 4th in this approach.
List<int> hwnds = new List<int>(); ShellWindows shellWindows = new ShellWindows(); var explorer = shellWindows.Cast<InternetExplorer>() .ToList() .Where(item => item.Document is IHTMLDocument2); foreach (var internetExplorer in explorer) { hwnds.Add((internetExplorer.Document as IOleWindow).GetWindow()); } return windows;
Another thing that I tried was to implement IEAccessible way of getting tabs, but that didn't work for me at all. https://social.msdn.microsoft.com/Forums/ie/en-US/03a8c835-e9e4-405b-8345-6c3d36bc8941/ie7-ie8-tab-interaction-accessibility-class?forum=ieextensiondevelopment
Last thing that I tried is to use UI Automation, but with WinSDK Inspect tool I could see that only hwnd of current opened tab is visible. Otherwise I can see only button with titles without hwnds.
I would be really thankful if someone could help me with this problem - since I cannot see any other solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.