Sign in to follow this  
Followers 0
meisandy

Get windows created by the program

5 posts in this topic

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

Share this post


Link to post
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

 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

or maybe also WinGetProcess () can do to your case

here something similar?

bye


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

Share this post


Link to post
Share on other sites

#4 ·  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.

Share this post


Link to post
Share on other sites

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. :)

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  
Followers 0

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      I have a question
      about the display language of the system
      How can I get the current display language and how can I change it by autoit
      Of course, if this is possible
      Greetings to all and hope you help me
    • Nareshm
      By Nareshm
      If Process exits then end process and ;Some code here {1}
       
      If Process does not exits then ; My {1} Code
    • breakbadsp
      By breakbadsp
      AutoIT AU3info doeas not detect all gui objects uniquely for .NET GUIs developed in C#.
      this is not working now i am using COM windows approach for this, But its very difficult.
      Please let me know if anyone has done it before.
    • ur
      By ur
      How to retrieve the target executable path from a process.
      My system is effected with IMG001.exe virus and I remove the folders created by it daily but still it is creating the folders everytime I login to my PC.
      My Antivirus is not detecting it.

       
      So I thought to create a process in AutoIT to check for the process name IMG001.exe and retrieve the process target exe to a log file, so that I can track where it is putting these files.
      With  ProcessExists ( "process" ) , i can get the process ID.
      But how to get the target location of the executable of the process.??
    • salah kai
      By salah kai
      Hey everyone
      i wanna close a process by  path like
      C:\Users\salah\AppData\Local\Temp\a.exe
      processclose(C:\Users\salah\AppData\Local\Temp\a.exe)
      i tried to split the path but i don't know how to know last loop
      and thanks