0

This is a pretty straightforward question with a few parts, one I'm not entirely sure is possible.

  1. Pick a browser, any browser. This can be done in any browser. My initial desire was Chrome, but it seems to be the least likely one to work.
  2. It needs to have a way to differentiate different windows.
  3. It needs to be able to read the URL of all open tabs within a given window.
  4. Read the size and position of the browser window (I already have a function for this, so it isn't a necessity).

I have an existing windows form application. Ideally I am looking to have it be able to open a browser window and maintain certain knowledge of it. Basically after the file is reloaded I'd like it to be able to open the browser window(s) with the tabs exactly the way they were when it was saved. I don't care about any of the information in the tabs, so all I really need is the ability to reopen the url's that were open and know which url belonged in which window and in which order.

Thus far I have been able to read all open tabs, but I haven't been able to differentiate which tab belongs to which window, so that's not really going to work properly. Honestly, barring some kind of reference assembly (which I haven't been able to find so far) I can't really see a way to do this at all. But, maybe someone knows of a way to do this.

Naryna
  • 121
  • 9
  • Look into selenium (or any other browser automation/testing tool) or better yet just host your own browser... Note that in current state your post is a bit too broad for SO (and hard to narrow down as you actually don't explain why you trying to do so). – Alexei Levenkov Oct 25 '15 at 06:34
  • Does this answers help http://stackoverflow.com/questions/13307946/get-the-urls-of-opened-tabs-in-browser – Amitd Oct 25 '15 at 07:01
  • @Amitd While that question doesn't state anything about knowing which window held what tabs, the code example looks promising if I play around with it. I will try it out and see if I can make it work for my needs. If it does work, you could make an answer out of it and I would gladly mark it correct. – Naryna Oct 25 '15 at 20:03
  • @BrandynBaryski it would be better if you put answer to your question if it works for you , as my answer is just linking to another answer. – Amitd Oct 26 '15 at 05:23

1 Answers1

0

I'm a little confused by the question, but my guess is that you are developing an application, and you want to be able to get all of the open browser windows, get a list of the tabs open in each window, and get the URL of each open tab.

Each browser is going to be different, because each browser is structured differently, and you'll be doing some below-board stuff / hacks to make this work.

There is a fairly complete answer here on how to get the URL's of open tabs: How can I get URLs of open pages from Chrome and Firefox?
It covers IE (in the question), Firefox, Opera, and Chrome.

and as far as getting open browser windows, that you can do with a little bit of research into the USER32 EnumWindows API. http://pinvoke.net/default.aspx/user32.EnumWindows

Community
  • 1
  • 1
caesay
  • 16,932
  • 15
  • 95
  • 160