Results 1 to 11 of 11

Thread: Enumerating Windows

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    4

    Lightbulb Enumerating Windows

    I just wanted to know whether anyone could explain to me [I]exactly[I] how to access the properties of other windows of the desktop that are not of my application. I'd like to do things like, say, find their position, find wether or not they are minimised or maximised, where, access the text on controls placed on them,...

    Also, how would I use the hWnd property of another window (not of my application) to make an object our of that window which I could use to access it's properties in an easier way, if at all possible.

    What is messaging? How can I use it, and what is it for?

    Isn't there a nice class I could get from somewhere that encapsulates all the dirty work and provides a humanisitic collection of all windows on the screen just like, for example, the controls collection of a VB form? I'd appreciate anyone's help.

    Thanks.

    Yours Sincerely,
    WiseJack

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Enumerating Windows

    Quote Originally Posted by WiseJack
    Isn't there a nice class I could get from somewhere that encapsulates all the dirty work and provides a humanisitic collection of all windows on the screen just like, for example, the controls collection of a VB form?
    Not that I know of, but it's a great idea. I might write one

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Enumerating Windows

    Quote Originally Posted by penagate
    Not that I know of, but it's a great idea. I might write one
    Do so, penagate 'cause as far as I know, the answer is No. There isn't one.

  4. #4
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Enumerating Windows

    I think there was something a bit like that in the EventVB.dll - the code for which should be around on this site somewhere...ah yes - here

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Enumerating Windows

    Ah yes, the good ole EventVB.dll - I remember it well.

    Are you working on a .NET version?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Enumerating Windows

    The number of times I crashed VB writing this...

    At present, I haven't found a way of getting For Each to work, so to to loop through all windows you have to do this:
    VB Code:
    1. Dim objWindows As CWindows
    2. Set objWindows = New CWindows
    3. objWindows.GetWindows
    4.  
    5. Dim i As Long
    6. For i = 1 To objWindows.Count
    7.     With objWindows(i)
    8.         ' do something
    9.     End With
    10. Next i
    11.  
    12. Set objWindows = Nothing

    It has 2 classes, CWindows (collection class) and CWindow (wraps various window-related APIs) and a .bas module MCallbacks.

    I'll update it with any feature requests, at the moment it just has the basics such as window caption, position, etc.

    Attached Files Attached Files

  7. #7
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Enumerating Windows

    Quote Originally Posted by Hack
    Ah yes, the good ole EventVB.dll - I remember it well.

    Are you working on a .NET version?
    Not as such - the .Net framework does pretty much everything that EventVB did (well, with the exception of printer monitoring ;-) ) so I'm just doing whichever bits aren't covered by the framework (gradually)

    For this question I thing the eventvb ApiSystem class's .TopLevelWindows property which is a collection of ApiWindow classes and you could drill down through the ApiWindow's .ChildWindows property to build up a tree of all the windows open on an operating system...

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Enumerating Windows

    Quote Originally Posted by penagate
    The number of times I crashed VB writing this...

    At present, I haven't found a way of getting For Each to work, so to to loop through all windows you have to do this:
    VB Code:
    1. Dim objWindows As CWindows
    2. Set objWindows = New CWindows
    3. objWindows.GetWindows
    4.  
    5. Dim i As Long
    6. For i = 1 To objWindows.Count
    7.     With objWindows(i)
    8.         ' do something
    9.     End With
    10. Next i
    11.  
    12. Set objWindows = Nothing

    It has 2 classes, CWindows (collection class) and CWindow (wraps various window-related APIs) and a .bas module MCallbacks.

    I'll update it with any feature requests, at the moment it just has the basics such as window caption, position, etc.
    If you feel this is in a finished state, put it in the CodeBank with a little Intro regarding what its purpose is, what it does, and briefly, how it does it.

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Enumerating Windows

    Done

    I added a few more features to the version above.

  10. #10

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    4

    Re: Enumerating Windows

    Quote Originally Posted by penagate
    Not that I know of, but it's a great idea. I might write one
    When(if) you do PLEASE lemme know. I need it bad...

  11. #11
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Enumerating Windows

    I have mate, if you read the rest of the thread, I linked to it in post #9...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width