Jump to content
Sign in to follow this  

Enumerate all windows!

Recommended Posts

(Damn it, wrong forum) Jon, can you move this to v3 Scripts and Scraps?

Check here!


Larry made a perfectly working 'Find all windows handles' Func!

I found no topic about that great func in this section (actually the other one) so I posted it.

Thanks Larry!

Opt ('WinTitleMatchMode', 4)
$a = _GetWindowHandles()

$msg = ''
For $c = 1 To $a[0]
   $msg = $msg & WinGetTitle('handle=' & $a[$c]) & @LF
MsgBox(0, '', $msg)

Func _GetWindowHandles()
   $GW_CHILD = 5
   Dim $List[1]
   $List[0] = 0
   $x = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
   If @error Then Return $List
   $x = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $x[0], "int", $GW_CHILD)
   If @error Then Return $List
   While 1
      $x = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $x[0], "int", $GW_HWNDNEXT)
      If @error Then ExitLoop
      If String($x[0]) = "00000000" Then ExitLoop
      If BitAND(WinGetState($x[0]), 2) Then
         $ub = UBound($List)
         ReDim $List[$ub + 1]
         $List[$ub] = $x[0]
         $List[0] = $ub
   Return $List
EndFunc  ;==>_GetWindowHandles
Edited by ezzetabi

Share this post

Link to post
Share on other sites

All Larry, I tried for a while on that as soon as I started playing with the DDL function, but I didn't figure it out until I saw Larry's UDF.

I make my own variations, like finding all the hidden ones only, etc etc.

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...