Jump to content

could not get list count using ControlListView


 Share

Recommended Posts

Hi all,

I am working on a window application and facing problem getting a list count. I've used the following functions, even though there are rows/list items present in WinList box every time it is returning 0 value. Please help on this.

1. ControlListView ("Window Name", "", 123, GetItemCount)

2.  _GUICtrlListBox_GetCount(123)

123 is the Control Id of the object(Win List) in "Window Name"
Link to comment
Share on other sites

Listbox or Listview? You're mixing your control types. If you have a listview use _GUICtrlListView_GetItemCount. Also, make sure you're using the correct handle, because 123 doesn't look like a handle identifier.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

hi,

Here 123 is the control ID. I am not using the Handler here. Can you please explain more? Generally for getting a List count which is preferred and how can I get handle of an object in a window?

Link to comment
Share on other sites

hi,

Here 123 is the control ID. I am not using the Handler here. Can you please explain more? Generally for getting a List count which is preferred and how can I get handle of an object in a window?

Link to comment
Share on other sites

Use ControlGetHandle ( "title", "text", controlID ) to get the handle, the ListView UDF needs the handle, you're giving it the control ID. Check to make sure that ControlGetHandle returns a handle before trying to use the listview function, if you're not able to get the handle, you won't be able to get the count. Also, if you can't get the handle using it, then perhaps your control ID is incorrect.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi,

I could able to get the handle of an object but still it is returning 0 number of list count. Following is the code i have tried

WinActivate("XYZ Window")

Local $hWnd= ControlGetHandle("XYZ Window", "",123)     ;*123- is the control Id, got from AutoIt window Info->Control -> Id 

$iHcc= ControlListView ( "XYZ Window", "", $hWnd, "GetItemCount")
MsgBox(0,"",$iHcc)    ;* is returning 0

Please check and let me know.

Link to comment
Share on other sites

_GUICtrlListView_GetItemCount is the function that needs the handle to the control, ControlListView needs the control ID. Use _GUICtrlListView_GetItemCount with the handle and see if that works for you.

Also, there's no way for me to check this, because I don't know what it is you're trying to access.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 4 years later...

Do not resurrect old threads like that.  I doubt very much that the guy is still around to answer you.  Create a new thread and post the code you got (make it a snippet that we can actually run).  To post your code, use this tool. 

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...