Jump to content
Sign in to follow this  


Recommended Posts


Hi all,

After searching the help file and the forums I couldn't find an easier way to do this -- ControlCommand()'s GetLineCount function appears only to work with Edit controls and most posts related to ListBoxes discuss ones found on AutoIt GUIs.

Thanks to Valik for most of the actual work.

Success: Returns the number of items.

Failure: Returns -1 and sets @Error to 1 if the window/control couldn't be found or 2 if the DLLCall() failed.

Func ListBoxGetCount($Title, $Text, $Control)

    Local Const $LB_GETCOUNT = 0x18B

; Assert that the window and control exist
    Local $Handle = ControlGetHandle($Title, $Text, $Control)
    If @Error Then
        Return -1

    Local $Ret = DLLCall('User32.dll', 'Int', 'SendMessage', 'HWnd', $Handle, 'Int', $LB_GETCOUNT)
    If @Error Then
        Return -1

    Return $Ret[0]

Edited by LxP

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.