Sign in to follow this  
Followers 0
chssoccer

Returning double of every list item

8 posts in this topic

#1 ·  Posted (edited)

For $a = 0 To _GUICtrlListCount($ListBox) - 1

;MsgBox(0,0,ControlGetHandle ( "Find Player", "", "ListBox1" ))

GUICtrlCreateListViewItem(_GUICtrlListGetText($ListBox, $a), $sListview)

Next

The code above somehow is returning double of every listbox item it returns, so if there are 2 list items it will return 4. Whats the problem?

Edited by chssoccer

Share this post


Link to post
Share on other sites



For $a = 0 To _GUICtrlListCount($ListBox) - 1

;MsgBox(0,0,ControlGetHandle ( "Find Player", "", "ListBox1" ))

GUICtrlCreateListViewItem(_GUICtrlListGetText($ListBox, $a), $sListview)

Next

The code above somehow is returning double of every listbox item it returns, so if there are 2 list items it will return 4. Whats the problem?

I don't quite get your question.

You have a list box with say n items, then you say for $a = 0 to n - 1 create a new item equal to item $a.

Then are you ask why you have doubled the items?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Ok, it is returning properly, just too many items.

For example, if there are items abc and def in the listbox, it will copy those items plus one more of each into my listview so it will appear like this in my listview:

abc

abc

def

def

when its supposed to appear as

abc

def

Share this post


Link to post
Share on other sites

It'll be easier to solve this problem with my full code:

WinClose("Find Player", "")
            If WinExists("Full Tilt Poker - Logged In As", "" ) Then
                WinActivate("Full Tilt Poker - Logged In As", "")
                $buddiesSearch = StringSplit($var, ",")
                Send("{CTRLDOWN}{f}"); Opens Find Player window
                Send("{CTRLUP}")
                WinWait("Find Player", ""); Waits for it to open
                ControlSetText("Find Player", "", "Edit1", "")
                    If IsArray($buddiesSearch) Then
                        For $i = 1 To $buddiesSearch[0]
                            ControlSend("Find Player", "", $Edit, $buddiesSearch[$i] & "{Enter}"); Searches for each individual player
                            $ListBox = ControlGetHandle ( "Find Player", "", "ListBox1" )
                            For $a = 0 To _GUICtrlListCount($ListBox) - 1
                            ;MsgBox(0,0,ControlGetHandle ( "Find Player", "", "ListBox1" ))
                                GUICtrlCreateListViewItem(_GUICtrlListGetText($ListBox, $a), $sListview)
                            Next
                        Next
                    EndIf
            Else
                MsgBox(16, "Error", "Full Tilt isn't running!")
            EndIf

Share this post


Link to post
Share on other sites

It'll be easier to solve this problem with my full code:

WinClose("Find Player", "")
            If WinExists("Full Tilt Poker - Logged In As", "" ) Then
                WinActivate("Full Tilt Poker - Logged In As", "")
                $buddiesSearch = StringSplit($var, ",")
                Send("{CTRLDOWN}{f}"); Opens Find Player window
                Send("{CTRLUP}")
                WinWait("Find Player", ""); Waits for it to open
                ControlSetText("Find Player", "", "Edit1", "")
                    If IsArray($buddiesSearch) Then
                        For $i = 1 To $buddiesSearch[0]
                            ControlSend("Find Player", "", $Edit, $buddiesSearch[$i] & "{Enter}"); Searches for each individual player
                            $ListBox = ControlGetHandle ( "Find Player", "", "ListBox1" )
                            For $a = 0 To _GUICtrlListCount($ListBox) - 1
                        ;MsgBox(0,0,ControlGetHandle ( "Find Player", "", "ListBox1" ))
                                GUICtrlCreateListViewItem(_GUICtrlListGetText($ListBox, $a), $sListview)
                            Next
                        Next
                    EndIf
            Else
                MsgBox(16, "Error", "Full Tilt isn't running!")
            EndIf
I see that I didn't read your first post correctly.

I would guess that you simply need to put a debug line or two inside the For $i = 1 to $buddiessearch because every time you go round that loop you are adding the items to the listview again. If yu only want the items added once then why put it inside a loop? Where is $var set anyway?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I see that I didn't read your first post correctly.

I would guess that you simply need to put a debug line or two inside the For $i = 1 to $buddiessearch because every time you go round that loop you are adding the items to the listview again. If yu only want the items added once then why put it inside a loop? Where is $var set anyway?

FYI: $var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")

So it would be like this?:

WinClose("Find Player", "")
            If WinExists("Full Tilt Poker - Logged In As", "" ) Then
                WinActivate("Full Tilt Poker - Logged In As", "")
                $buddiesSearch = StringSplit($var, ",")
                Send("{CTRLDOWN}{f}"); Opens Find Player window
                Send("{CTRLUP}")
                WinWait("Find Player", ""); Waits for it to open
                ControlSetText("Find Player", "", "Edit1", "")
                    If IsArray($buddiesSearch) Then
                        For $i = 1 To $buddiesSearch[0]
                            ControlSend("Find Player", "", $Edit, $buddiesSearch[$i] & "{Enter}"); Searches for each individual player
                            $ListBox = ControlGetHandle ( "Find Player", "", "ListBox1" )
                        Next
                                                For $a = 0 To _GUICtrlListCount($ListBox) - 1
                                GUICtrlCreateListViewItem(_GUICtrlListGetText($ListBox, $a), $sListview)
                            Next
                    EndIf
            Else
                MsgBox(16, "Error", "Full Tilt isn't running!")
            EndIf

Share this post


Link to post
Share on other sites

Yep, that works.

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  
Followers 0