Jump to content

Enumerate all windows!


ezzetabi
 Share

Recommended Posts

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

Check here!

http://www.autoitscript.com/forum/index.php?showtopic=5764

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
Next
MsgBox(0, '', $msg)

Exit
Func _GetWindowHandles()
   $GW_HWNDNEXT = 2
   $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
      EndIf
   Wend
   Return $List
EndFunc  ;==>_GetWindowHandles
Edited by ezzetabi
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...