Jump to content

Recommended Posts

Posted

I have had great success using the AutoIT Powershell cmdlets, 

However I am stuck trying to get a comprehensive list of Window handles (as provided by AutoIt "WinList" command).

I have resorted to a cludge of calling an AutoIt script to run the command and put results in a file and then reading the file in powershell.

Can someone point me to an explanation of how to do this better?

Posted

Yes, do it all in autoit.

Why use powershell anyway?

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

can always resort to executeline

.\AutoIt3.exe /AutoIt3ExecuteLine "msgbox(0 , '' , winlist('AutoIt v3')[1][0] & ' | ' & winlist('AutoIt v3')[1][1])"

5b5158292f15f_powershellwinlist.thumb.PNG.a2cdc684dc49fc83021bf6036180f9b6.PNG

  Reveal hidden contents

  • Moderators
Posted
  On 7/20/2018 at 3:04 AM, careca said:

Yes, do it all in autoit.

Why use powershell anyway?

Expand  

There is a reason Jon decided to create a PowerShell sub forum.

@JC_Aus while I agree that AutoIt makes this task easier, if you have a requirement to do it in PS you could do something like this:

Get-Process | 
    Where-Object {$_.MainWindowTitle -like "*notepad*"} | 
        Select MainWindowTitle, MainWindowHandle |
            Out-GridView

If you're looking to capture more like all open windows, you can modify it slightly:

Get-Process |
    Where-Object {$_.MainWindowTitle -ne ""} |
        Select MainWindowTitle, MainWindowHandle |
            Out-GridView

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

Thanks all for your comments/suggestions.

I had originally gone down the 'Get-Process' path, but it does not display all child windows (eg Outlook can have multiple windows open). Winlist does display them all.

My final solution was to use ComObject, it had to run as 32 bit, but otherwise no issue 

    $AU3 = New-object -ComObject "AutoItX3.Control"   # Must run as 32 bit
    $array1 = @()
    $list = $AU3.winlist("[ALL]")
    for ($i = 1;$i -lt $($list.GetUpperBound(1));$i++)
    {
      $title = $list[0,$i]
      if ($title -ne ""  )
        {
          $array1+=($title)
        }    
    }

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
  • Recently Browsing   0 members

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