none
How to list all Browser Windows and Browser Tabs RRS feed

  • Question

  • Hi,

    I am a dev looking for C# solution in listing out several things.

    1. List out All open windows for any program and their IDs

    2. List out All browser windows and browser tabs and their IDs

    Is there an efficient coding way in C# to do this.

    Thx in advance for the help.

    DevDJ

    Thursday, October 17, 2019 3:01 PM

All replies

  • Hi all,
    I am a dev looking for C# solution in listing out several things.
    1. List out All open windows for any program and their IDs
    2. List out All browser windows and browser tabs and their IDs
    Is there an efficient coding way in C# to do this.
    Thx in advance for the help.
    DevDJ
    Thursday, October 17, 2019 3:07 PM
  • This is not a C# question and it is a duplicate. I will post a reply to the other thread.


    Sam Hobbs
    SimpleSamples.Info

    Thursday, October 17, 2019 3:30 PM
  • Those are totally different questions. In the future please ask separate questions separately.

    For processes you can use the Win32_Process class; there are examples in that page.

    For browser windows and/or tabs it depends on the browser. I have researched the subject in the past and I know how to do it for IE but as I said it is different for each browser. I think the best way and probably the only way is to use a browser extension. There is very much available on that subject.



    Sam Hobbs
    SimpleSamples.Info

    Thursday, October 17, 2019 3:39 PM
  • Sorry, u didn't answer my first ques. and your answer didn't really help in any ques.

    Thursday, October 17, 2019 11:20 PM
  • You are correct that I totally misread your first question. As I said, in the future concentrate on one problem at a time.

    I do not know what you mean by any program; how will that be determined? What information will there be about the program?

    What does ID mean?

    If you are trying to get the open windows of a browser then that will not help get the information about the browser session (such as the tabs) in it. In particular, you cannot get access to the HTML by using the Windows window such as the window handle. Many have tried. I have researched it extensively.



    Sam Hobbs
    SimpleSamples.Info

    Friday, October 18, 2019 12:23 AM
  • Hello DevDJ,

    This forum is for "Discuss general issues about developing applications for Windows." in C++.

    Since your are using C# I'll move it to C# forum for more professional support.

    Best regards,

    Rita


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 18, 2019 3:00 AM
  • there is no efficient coding way in C# to do want you want. It is really not a language designer's business to do UI stuff. You have to use OS API or some kind of library. 

    How you enumerate windows is OS dependent. On Windows there's the EnumWindows API. But it only gives you the windows on the same desktop. A user session could have many desktops. And there could be many user sessions on the same machine. There is no API to let you enumerate windows across Windows desktops - the system id is window handle and window handle is only valid in the context of a desktop. On Linux I am not sure it is even practical- there are probably a couple dozens of desktop environments and you have to look up the API for each one.

    It's even harder for browsers. Browsers don't really provide a method to identify their windows as browsers. Well IE does, but pretty much nobody else, and confusing enough, the way IE expose itself (IShellWindows) is also implemented by Windows Explorer windows. If you only want to access browser windows you create, and you only support major browsers, there's Selenium. For browser windows created by the user or random browsers brought to you by EU's lawsuit, tough luck.



    Visual C++ MVP


    Friday, October 18, 2019 4:31 AM