Jump to content
Sign in to follow this  
meisandy

Get windows created by the program

Recommended Posts

meisandy

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
Danyfirex

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

Share this post


Link to post
Share on other sites
Chimp

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
jdelaney

#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
meisandy

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  

  • Similar Content

    • Iznogoud
      By Iznogoud
      Hi,
      Does anyone knows why this command doesn't work?
      Run(@ComSpec & " /c " & "devcon.exe hwids * | findstr /R ""1050&PID_0114&REV_0340&MI_01"" || (rundll32.exe user32.dll, LockWorkStation)", "", "") This is the command in commandline:
      devcon.exe hwids * | findstr /R "1050&PID_0114&REV_0340&MI_01" && (echo USB Device is connected) || (rundll32.exe user32.dll, LockWorkStation) This works, but i want to convert this to AutoIT, but it doesn't work.
       
      In short what i am trying to accomplish is that a script checks every 1 sec. if there is an USB device plugged in and if not ( so it is removed ) it will lock Windows OS.
      Can someone help me with this?
    • Miliardsto
      By Miliardsto
      I want to detect if exact process or window uses directx or opengl or maybe something else library used in applications.
      Thats becouse there could be many windows with same names and different names and the same with process. I got so much process names I want to my script works with all, so i want standardize.
      All of this processes uses DirectX or OpenGL so then If I check this window/process uses these libraries I will be sure thats the right process
    • TryWare90Days
      By TryWare90Days
      I'm trying to kill a malware process, that I can't remove with my www.sophus.com/hom antivirus.

      The malware is known as coinminer,config and my Sophus only creates popups of blocking the malware.

      I know that the malware is constantly launching a svchost *32.exe processes, where the svchost.exe processes are from my Windows 7 operating system.
      I have with no luck tried to do this:
      Global $_bStatus = False
      While $_bStatus = False
                 Global $_iPid
                 Global $_sActiveTitleNew = "svchost *32.exe"
                 $_iPid = WinGetProcess($_sActiveTitleNew)
                 If $_iPid <> -1 Then $_bStatus = ProcessClose($_iPid)   
      Wend
      EXIT
       
      But the $_iPid doesn't ever show anything else than  -1, even if I can see the svchost *32.exe process in my TaskManager
       
      YES - I know I shouldn't EXIT after killing the first malware detection, but it is easier to explain the above for you, so I can get a solution.
    • VITSUSA
      By VITSUSA
      I am using window XP in my desktop, so I want to convert basic disk to a dynamic disk, so how it is possible?
    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I have an inquiry after your permission
      I found a function to get the special line commands for any operation
      It requires the name of the process to be searched
      I want to use it to know the process
      Is this possible with this function
      Here is the code
       
      Func commandLineGet($proc, $strComputer=".")
      dim $array[1]
      local $ArrayNumber
      local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
      local $oProcessColl = $oWMI.ExecQuery("Select * from Win32_Process where Name= " & '"'& $Proc & '"')
      local $Process
      For $Process In $oProcessColl
      $Process = $Process.Commandline
          ReDim $Array[UBound($Array)+1]
      $ArrayNumber = UBound($Array)-1
      $array[$ArrayNumber] = $Process
      Next
      $ArrayNumber = UBound($Array)-1
      $array[0] = $ArrayNumber
      return $array
      EndFunc
×