Jump to content

Get windows created by the program


Go to solution Solved by jdelaney,

Recommended Posts

Hi guys,

This is just a general query, but it is related to >one of my previous topics in some ways. If a program generates 'sub-windows', i.e if file download dialogs are created that belong to the script's process, is there any way to return an array or something with the information, or handles for these windows?

Hopefully that makes sense.

Thanks in advance

Link to comment
Share on other sites

Look helpfile winlist function

Local $var = WinList()

For $i = 1 To $var[0][0]
    ; Only display visble windows that have a title
    If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
        MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
    EndIf
Next

Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf

EndFunc   ;==>IsVisible
Link to comment
Share on other sites

  • Solution

#include <Array.au3>

#include <WinAPI.au3>
$hWin = WinGetHandle("your window") ; This is the parent window
$iPID = WinGetProcess($hWin)
$iCurrentPid = ""
$aWin = WinList()
For $i = UBound($aWin)-1 To 0 Step -1
    _WinAPI_GetWindowThreadProcessId($aWin[$i][1], $iCurrentPid)
    If $iCurrentPid <> $iPID Then
        _ArrayDelete($aWin,$i)
    EndIf
Next

_ArrayDisplay($aWin)

or:

#include <constants.au3>
#include <WinAPI.au3>
$hWin = WinGetHandle("your window") ; This is the parent window
$iPID = WinGetProcess($hWin)

$hWin = _WinAPI_GetWindow($hWin, $GW_HWNDFIRST)
$end= _WinAPI_GetWindow($hWin, $GW_HWNDLAST)

$iCurrentPid = ""
While True
    $hWin = _WinAPI_GetWindow($hWin, $GW_HWNDNEXT)
    _WinAPI_GetWindowThreadProcessId($hWin, $iCurrentPid)
    If $iCurrentPid = $iPID Then
        ConsoleWrite($hWin & " state=[" & WinGetState($hWin) & "] title=[" & WinGetTitle($hWin) & "]" & @CRLF)
    EndIf
    If $hWin = $end Then ExitLoop
WEnd
; many of the handles returned will not be visible, but you can add checks on the wingetstate inside the if statement



Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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

×
×
  • Create New...