Jump to content

Recommended Posts

Posted

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

Posted

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
Posted

or maybe also WinGetProcess () can do to your case

here something similar?

bye

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

  • Solution
Posted (edited)

#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.
Posted

Thank you very much everyone. You all showed me exactly what I was looking for!

I'm going to mark jdelaney's answer as the one that solved the topic, but only because it is the more complete of the three. :)

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
×
×
  • Create New...