Jump to content

_GUICtrlListView_GetItemText works but AutoItX3Lib.AutoItX3Class.ControlListView() doesn't


Recommended Posts

Hi guys,

I'm new to AutoIt and trying to figure out if I can use it to make me life easy :)

I've got a problem maybe you can advice me something.

When I use the the AutoIt native environment: SciTE and run my actions then the _GUICtrlListView_GetItemText works correctly but when I try to use Visual Studio and Interop.AutoItX3Lib.dll to get the text through AutoItX3Lib.AutoItX3Class.ControlListView("GetText") I'm getting empty string but at the same time the Athe utoItX3Lib.AutoItX3Class.ControlListView("GetItemCount") works fine. Can you give me some advice on what I'm missing.

Please find my code below:

SciTE

#include <GuiListView_edit.au3>

Local $hWindow = WinGetHandle("Model Palette", "")
;ConsoleWrite($hWindow & @LF)
Local $hListView = ControlGetHandle($hWindow, "", "[CLASS:ListView20WndClass; INSTANCE:1]")
;ConsoleWrite($hListView & @LF)
Local $iItemCnt = _GUICtrlListView_GetItemCount($hListView)
Local $iColCnt = _GUICtrlListView_GetColumnCount($hListView)
For $i = 0 To $iItemCnt - 1
   $sText = _GUICtrlListView_GetItemText($hListView, $i, 0)        
   ConsoleWrite("Item: " & $i & ": " & $sText & @LF)       
Next

VS C#

static void Main(string[] args)
        {
            string itemText = "";
            AutoItX3Lib.AutoItX3Class driver = new AutoItX3Lib.AutoItX3Class();
            int itemsCount = int.Parse(driver.ControlListView("Model Palette", "", "[CLASS:ListView20WndClass; INSTANCE:1]", "GetItemCount", "", ""));
            Debug.Print("items count=" + itemsCount);
            for (int index = 0; index < itemsCount; index++)
            {
                itemText = driver.ControlListView("Model Palette", "", "[CLASS:ListView20WndClass; INSTANCE:1]", "GetText", index.ToString(), "0");
                Debug.Print("itemText=" + itemText);
            }
            return;
        }
Link to comment
Share on other sites

You don't even need AutoIt to do this, look at the UDF for how the function _GUICtrlListView_GetItemText works, it's just a wrapper around a sendmessage command and reading/writing in a structure.

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

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