Jump to content
Sign in to follow this  
JC_Aus

Calling WinList from Powershell

Recommended Posts

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?

Share this post


Link to post
Share on other sites

Yes, do it all in autoit.

Why use powershell anyway?


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

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


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
11 hours ago, careca said:

Yes, do it all in autoit.

Why use powershell anyway?

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!

Share this post


Link to post
Share on other sites

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)
        }    
    }

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...