none
list of open windows in c#

    Question

  • Hi, I'm new to C# so i'm wondering if there's any way i can get a list of all the currently open windows in the system. As an example, if i have a "windows explorer" and an "internet explorer" and two "notepad" windows open, i need to hide these open windows and later on unhide them, so i imagine first i need to get their list somehow and run through a loop to hide them. any help is much appreciated.
    Friday, December 04, 2009 5:15 AM

Answers

  • A virtual desktop has nothing to do with C#. It's way too lower level and you need to operate too much with the OS (which requires invoking the platform functions). Just start off with an easy project, such as a simple calculator, or maybe a small game like Sudoku.
    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
    • Marked as answer by houman_ag Thursday, December 10, 2009 6:15 AM
    Wednesday, December 09, 2009 10:20 AM
  • Hi,

    I suggest you find an existing desktop manager as this is a work for many-many hours. You can`t just hide them, you need to track window destroying and creation, show and hide, support every Windows version (for commercial app), etc. And that is all not on the .NET level but rather on the OS level as Geert van Horrik have stated. If you really want to do that, start deep learning of the OS internals and hooks instead of .NET/BCL/C#.



    Best regards.

    Flexible Treeview - the most flexible treeview-listview-grid hybrid control for .NET!
    • Marked as answer by houman_ag Thursday, December 10, 2009 6:15 AM
    Wednesday, December 09, 2009 11:21 AM

All replies

  • Take a look at EnumWindows its a Window API function but you can call it from managed code.
    A programmer Trapped in a thugs body
    Friday, December 04, 2009 7:58 AM
  • Friday, December 04, 2009 9:00 AM
  • the script on the site works but it returns tonnes of stuff that i cant make sense of... here are some examples. any idea how i can get rid of them? thx a lot

    TokenLoginHiddenWindow

    AXWIN Frame Window
    igfxtrayWindow

    .NET-BroadcastEventWindow.2.0.0.0.21af1a5.0
    Program Manager
    MSCTFIME UI
    Default IME

    Saturday, December 05, 2009 6:00 AM
  • Yeah EnumWindows will give you all sorts of stuff that probably isn't what your after. I beleive it is including all the controls within a window in this (textboxes, listboxes etc).

    If its just the so-called 'Alt+Tab' windows, check out:
    http://blogs.msdn.com/oldnewthing/archive/2007/10/08/5351207.aspx

    Saturday, December 05, 2009 1:16 PM
  • Oh that is all vis C++ code as the example, but you can find the pinvoke definitions up at http://www.pinvoke.net


    I might have some c# code lying about somewhere for this task if you want it
    Saturday, December 05, 2009 1:21 PM
  • To hide all the other windows, run your app maximized.
    Saturday, December 05, 2009 2:33 PM
  • to "Man Bear Pig" - if you could send the code, I'd much appreciate it.

    to "JohnWein" - Not sure if i understand what you mean, or i understand how it helps removing the "unwanted" info (i'm running my code inside the MS Visual C# IDE - if this helps), thx for the comment tho
    Saturday, December 05, 2009 6:22 PM
  • to "JohnWein" - Not sure if i understand what you mean, or i understand how it helps removing the "unwanted" info (i'm running my code inside the MS Visual C# IDE - if this helps), thx for the comment tho

    What are you trying to do?  My response was to your statement:  "i need to hide these open windows and later on unhide them"
    Saturday, December 05, 2009 6:24 PM
  • here's what i'm trying to accomplish... after looking around for a while and not quite finding a simple to use and yet full-feature "virtual desktop manager" (something similar to that of macs where you can drag and drop windows from one virtual desktop to another), I thought i work on it as a side project for myself, which would give me familiarity with c# as well (my first time programming in c#). so as starting point, i wana learn how to loop through open windows on the screen and hide them all (i'm thinking i'll have 4 arraylist to keep track of the windows located on each "virtual desktop")... i hope this makes sense

    Sunday, December 06, 2009 6:02 PM
  • A virtual desktop has nothing to do with C#. It's way too lower level and you need to operate too much with the OS (which requires invoking the platform functions). Just start off with an easy project, such as a simple calculator, or maybe a small game like Sudoku.
    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
    • Marked as answer by houman_ag Thursday, December 10, 2009 6:15 AM
    Wednesday, December 09, 2009 10:20 AM
  • Hi,

    I suggest you find an existing desktop manager as this is a work for many-many hours. You can`t just hide them, you need to track window destroying and creation, show and hide, support every Windows version (for commercial app), etc. And that is all not on the .NET level but rather on the OS level as Geert van Horrik have stated. If you really want to do that, start deep learning of the OS internals and hooks instead of .NET/BCL/C#.



    Best regards.

    Flexible Treeview - the most flexible treeview-listview-grid hybrid control for .NET!
    • Marked as answer by houman_ag Thursday, December 10, 2009 6:15 AM
    Wednesday, December 09, 2009 11:21 AM
  • Geert van Horrik and Ruslan Mogilevskiy - thank to both of you. For some reasons I was under the impression that it would be a simple matter of hiding windows and maybe saving a list of them in an arraylist or something and unhiding them later. but i guess i was wrong. i'll start with a different project then... thanks again
    Thursday, December 10, 2009 6:15 AM