Jump to content

WinList with title-parameter from function call


Go to solution Solved by HurleyShanabarger,

Recommended Posts

Hello,

I am writing an UDF which uses WinList. The title-parameter is taken from the function call of the UDF.

If the title-parameter is blank

WinList("")

or default

WinList(Default)

the function returns something different, as if called using this

WinList()

Is it possible to have the same output as in the third example? This is the code I am using (reduced to the core):

#Region Includes
    #include <Array.au3>
#EndRegion Includes

#Region Main
    _Main()

    Func _Main()
        Local $arWinList

        ; Return WinList with all windows
        $arWinList = WinList()
        _ArrayDisplay($arWinList)

        ; Returns WinList with only - in my case - scite window from the script
        $arWinList = _WinListWrapper("")
        _ArrayDisplay($arWinList)
    EndFunc   ;==>_Main
#EndRegion Main

#Region Functions
    Func _WinListWrapper($sgTitle = "")
        Return WinList($sgTitle)
    EndFunc
#EndRegion Functions

 

Edited by HurleyShanabarger
Link to comment
Share on other sites

@HurleySh.

you can use EnumWindows

 s it possible to have the same output as in the third example?

#include <Array.au3>
#include <WinAPISysWin.au3>
    Local $aWindows = _WinAPI_EnumWindows(False)
    Local $aResult[$aWindows[0][0]][5]
    For $i = 1 To $aWindows[0][0]
        $aResult[$i - 1][0] = $aWindows[$i][0]
        $aResult[$i - 1][1] = WinGetTitle($aWindows[$i][0])
    Next
    _ArrayDisplay($aResult, "_WinAPI_EnumWindows")

 

Edited by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

@HurleyShanabarger

_WinAPI_EnumWindows

Enumerates all windows:

_WinAPI_EnumWindows ( [$bVisible = True [, $hWnd = Default]] )

Parameters

$bVisible [optional] Window selection flag:
 True - Returns only visible windows
False - Returns all windows
$hWnd [optional] Handle of the starting windows (default Desktop windows)

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

  • Solution

@ad777, sorry I mixed _WinAPI_EnumWindows with _WinAPI_EnumWindowsTop.

@Luke94, I use _WinAPI_EnumDesktopWindows like this, I get the same result as WinList, but without the option to filter for title/name:

_WinAPI_EnumDesktopWindows(_WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId()), False)

My solution for now is this:

Func _WinList($vWndw = "", $sgText = "")
    Return ($sgText Or $vWndw) ? WinList($vWndw, $sgText) : WinList()
EndFunc   ;==>_WinList

Still feels like a bug, that if use "", Default, -1 or Null WinList is returning something different.

Link to comment
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
 Share

  • Recently Browsing   0 members

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