smellyfingers

_GUICtrlListBox_GetText Only retrieves 2 Char

6 posts in this topic

#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <GuilistBox.au3>
#include <Misc.au3>
#include <File.au3>
#include <Array.au3>
#include <String.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIEx.au3>


Opt("WinDetectHiddenText", 1) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1) ;0=no, 1=search children also

$ttlWindow = "Kundinformation"

$hdlWindow = WinGetHandle($ttlWindow)
;$id = _WinAPI_GetDlgCtrlID($hdlWindow)
$hdlList = ControlGetHandle($hdlWindow, "", 8197)
;MsgBox(0,"",$hdlList)
_GUICtrlListBox_ClickItem($hdlList, 3, "left")
$count = _GUICtrlListBox_GetCount($hdlList)
;MsgBox(0,"",$count)
Global $item
Dim $textArr[0]
For $item = 0 To ($count - 1) Step 1
    _GUICtrlListBox_ClickItem($hdlList, $item, "left")
    $tlength = _GUICtrlListBox_GetTextLen($hdlList, $item)
    $iIndex = _GUICtrlListBox_GetText($hdlList, $item)
    MsgBox(64,"",$tlength & " | " & $iIndex)

Next

Hi, I'm trying to get the text from ListBox (selected item) or item looped as the code above, as you can see from the attached file I only get 2 characters for each item, is this a bug or is there something else making it return those 2, GetTextLen seems to be working ok and reads the length.

x.jpg

Share this post


Link to post
Share on other sites



Did you try _GUICtrlListBox_GetSelItemsText  ?

Share this post


Link to post
Share on other sites

Hi, yes i did try that also, no luck, just seems odd it can give just the 2 first letters and ignore and leave out the rest, it's my work computer by the way forgot to mention It's a Windows 7 64 bit version, could that be it perhaps? I'll get a coworker to try the script on their 32 bit Windows tomorrow when I'm back at the office.

Share this post


Link to post
Share on other sites
On ‎2017‎-‎01‎-‎16 at 4:48 PM, mikell said:

Did you try _GUICtrlListBox_GetSelItemsText  ?

Here is the result of _GUICtrlListBox_GetSelItemsText

#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <GuilistBox.au3>
#include <Misc.au3>
#include <File.au3>
#include <Array.au3>
#include <String.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIEx.au3>


Opt("WinDetectHiddenText", 1) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1) ;0=no, 1=search children also

$ttlWindow = "Front Office"

$hdlWindow = WinGetHandle($ttlWindow)

$hdlList = ControlGetHandle($hdlWindow, "", 8197)

$count = _GUICtrlListBox_GetCount($hdlList)
;MsgBox(0,"",$count)
Global $item,$sItems
Dim $textArr[0]
For $item = 0 To ($count - 1) Step 1

    _GUICtrlListBox_ClickItem($hdlList, $item, "left")
    $aItems = _GUICtrlListBox_GetSelItemsText($hdlList)
    For $iI = 1 To $aItems[0]
        If $iI > 1 Then $sItems &= ", "
        $sItems &= $aItems[$iI]
    Next
    MsgBox($MB_SYSTEMMODAL, "Information", "Items Selected: " & $sItems)
Next

I get a blank response

x2.jpg

Share this post


Link to post
Share on other sites

Are you sure that this control is a Listbox ? on the picture it looks more like a Treeview

Share this post


Link to post
Share on other sites

Hi, thanx for the reply, yes it looks that way using the window info tool, but i agree it looks more like a treeview, i found another problem with this app itself when trying to automate it, it constantly changing the classnn names for the controls, is there a way to get the classnn names from it's id?, i think the id is the only thing that is permanent in this application...

xx2.jpg

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