Jump to content

Copy Listview Items


FireLord
 Share

Recommended Posts

Hi,

I have been trying to copy listview items from one listview in one window to my own program's listview but have been having no luck. I tried _GUICtrlListViewCopyItems() but it doesn't work. Maybe I'm not getting the handle correctly?

Here's how I've been trying to do it.

$nListview = GUICtrlCreateListView("Online|Buddy Name ", 30, 85, 230, 200) ; my listview

$xListview = ControlGetHandle("Find Player", "", "[CLASS:Listbox; INSTANCE:1]" )    ; Listview from another window

and I tried getting the handle this way:

$xListview= ControlGetHandle("Find Player", "", 259 )

_GUICtrlListViewCopyItems($xlistview, $nListview)

But the listview items from the window won't copy into my listview.

Please help if you can,

FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

Hi,

"[CLASS:Listbox; INSTANCE:1]"

Looks like your trying to copy data from a Listbox and not a ListView control.

Cheers

Ok, but I know it has to be possible to copy it from a listbox to a listview because I downloaded a program

coded in AutoHotKey that can do it, and all I am doing is programming the same thing but in AutoIt.

So...how could I copy all the items from a listbox to my listview?

EDIT:

P.S: btw, whats the difference between a listbox and a listview, because I am looking at and clicking on the "so-called"

listbox in the application and it looks like a listview and pretty much can do exactly the same thing.

Edited by FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

I took it upon myself to find out the difference and I did. I looked into _GUICtrlListGetLocale and I think that is exactly

what I need to copy the items from the window into my listview. Please correct me if I'm wrong.

FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

I'd use _GUICtrlListBox_GetCount($hWnd) and then loop through the count using _GUICtrlListBox_GetText($hWnd, $iIndex) to get the text to set in my ListView. eg:

#include <GuiConstants.au3>
#include <GUIListBox.au3>

$Gui = GUICreate("ListBox & ListView", 500, 290)
$ListBox = GUICtrlCreateList("", 5, 5, 240, 260)
GUICtrlSetData(-1, "Nemo|Mundo|Jock|Supra|Bodge|Fatty|Ando")
$ListView = GUICtrlCreateListView("Online|Player", 250, 5, 245, 253)
$Button = GUICtrlCreateButton("Copy all from listbox", 150, 265, 200, 20)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            For $i = 0 To _GUICtrlListBox_GetCount($ListBox) - 1
                GUICtrlCreateListViewItem("|" &  _GUICtrlListBox_GetText($ListBox, $i), $ListView)
                $Online = Random(0, 1, 1)
                If $Online Then 
                    GUICtrlSetImage(-1, "shell32.dll", -138)
                Else
                    GUICtrlSetImage(-1, "shell32.dll", -110)
                EndIf   
            Next    
    EndSwitch
WEnd

Cheers

Edited by smashly
Link to comment
Share on other sites

I was using Autoit v3.2.9.10 (beta), it's part of it..

I gather it would be the same for v3.2.9.13 (beta) (as a guess)

Could you just upload it here so I can quickly download it?

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

Wouldn't be much point in me attaching it as it probably is dependent on other includes from the beta version I'm using..

Just dl Autoit beta.. it's only 6.21MB and it'll save yourself the headache of mismatched includes and variables.

Cheers

Edit: Here's the same thing using public Autoit v3.2.8.1

#include <GuiConstants.au3>
#Include <GuiList.au3>
;~ #include <GUIListBox.au3> ;  v3.2.9.10 (beta)

$Gui = GUICreate("ListBox & ListView", 500, 290)
$ListBox = GUICtrlCreateList("", 5, 5, 240, 260)
GUICtrlSetData(-1, "Nemo|Mundo|Jock|Supra|Bodge|Fatty|Ando")
$ListView = GUICtrlCreateListView("Online|Player", 250, 5, 245, 253)
$Button = GUICtrlCreateButton("Copy all from listbox", 150, 265, 200, 20)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
;~          For $i = 0 To _GUICtrlListBox_GetCount($ListBox) - 1 ;  v3.2.9.10 (beta)
;~              GUICtrlCreateListViewItem("|" &  _GUICtrlListBox_GetText($ListBox, $i), $ListView) ;  v3.2.9.10 (beta)
            For $i = 0 To _GUICtrlListCount($ListBox) - 1
                GUICtrlCreateListViewItem("|" & _GUICtrlListGetText($ListBox, $i), $ListView)
                $Online = Random(0, 1, 1)
                If $Online Then 
                    GUICtrlSetImage(-1, "shell32.dll", -138)
                Else
                    GUICtrlSetImage(-1, "shell32.dll", -110)
                EndIf   
            Next    
    EndSwitch
WEnd
Edited by smashly
Link to comment
Share on other sites

I'm using 3.2.9.13 and on the line: For $i = 0 To _GUICtrlListCount($ListBox) - 1 it is saying "Unknown function name"

Anyone know why?

btw smashly: if i can get past this error i think this is going to work because its exactly what i need.

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

  • Moderators

I'm using 3.2.9.13 and on the line: For $i = 0 To _GUICtrlListCount($ListBox) - 1 it is saying "Unknown function name"

Anyone know why?

btw smashly: if i can get past this error i think this is going to work because its exactly what i need.

You have

#include <GUIList.au3>

At the top of your script?

If you do, then trying running it under beta (Tools - Beta Run) or Alt + F5

Edit:

Oh yeah... they changed the names of some of the functions... replace

_GUICtrlListCount with _GUICtrlListBox_GetCount

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Now I'm having trouble sending the ONE word in the INI into the input in the window with the listbox in it.

Code:

Global $var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
$buddiesSearch = StringSplit($var, ",")
For $i = 1 To $buddiesSearch[0]
    Send($buddiesSearch[$i] & Send("{Enter}")); Search for each individual player
    Next

INI:

[buddyList]

Buddies=value1

Now everytime it is sent into the input in the other window it adds a number "1" to the end of the word.

For example, when it would go to input the only value in my ini into the input it would come out as "value11"

Get it? Does anyone know the reason for this?

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

  • Moderators

Now I'm having trouble sending the ONE word in the INI into the input in the window with the listbox in it.

Code:

Global $var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
$buddiesSearch = StringSplit($var, ",")
For $i = 1 To $buddiesSearch[0]
    Send($buddiesSearch[$i] & Send("{Enter}")); Search for each individual player
    Next

INI:

[buddyList]

Buddies=value1

Now everytime it is sent into the input in the other window it adds a number "1" to the end of the word.

For example, when it would go to input the only value in my ini into the input it would come out as "value11"

Get it? Does anyone know the reason for this?

Something in the way you wrote it for sure. Sounds like you're putting a value return of another function in there.

Before you send, what does a MsgBox give you.

(P.S. - I'm not much for chasing my tail, so I will be blunt... if the above doesn't help, you can wait for others to post, or post a recreation script that I can test and not waste my time doing the guessing game on)

Edit:

Yep, I was right in my assumption, you are concatenating the Send() as a string.

Send() will return a value of 1.

Here's what you are doing.

1. Sending Enter (remember right to left with functions)

2. Send returned 1 as a success

3. Now you are sending $buddiesSearch[$i] & 1

You're probably trying to do:

Send($buddiesSearch[$i] & "{Enter}");

Edit2:

Typo

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

@SmOke_N:

That solved the problem :P

Code:

If IsArray($buddiesSearch) Then
    For $i = 1 To $buddiesSearch[0]
        Send($buddiesSearch[$i] & "{Enter}"); Search for each individual player
    Next
    Sleep(500)
    [b]For $i = 0 To _GUICtrlListCount($ListBox) - 1[/b]
        GUICtrlCreateListViewItem("|" &  _GUICtrlListGetText($ListBox, $i), $nListView)
    Next

When I tried out the code from post #5 from smashly I noticed that it wasn't creating the listview item. Then I put a msgbox there and nothing happened. So it seems the code stops at the line in bold. Why? Does anything above look wrong?

FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

If IsArray($buddiesSearch) Then
    For $i = 1 To $buddiesSearch[0]
        Send($buddiesSearch[$i] & "{Enter}"); Search for each individual player
    Next
    Sleep(500)
    For $i = 0 To _GUICtrlListCount($ListBox) - 1
    Next
    GUICtrlCreateListViewItem("|" &  _GUICtrlListGetText($ListBox, $i), $nListView)

With GUICtrlCreateListViewItem() after the next it works but it doesn't copy the items from the listbox to my listview, it justs puts "-1" in the listview. I'm assuming thats the return value of GUICtrlListGetText but don't know how to fix it?

FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

  • Moderators

If IsArray($buddiesSearch) Then
    For $i = 1 To $buddiesSearch[0]
        Send($buddiesSearch[$i] & "{Enter}"); Search for each individual player
    Next
    Sleep(500)
    For $i = 0 To _GUICtrlListCount($ListBox) - 1
    Next
    GUICtrlCreateListViewItem("|" &  _GUICtrlListGetText($ListBox, $i), $nListView)

With GUICtrlCreateListViewItem() after the next it works but it doesn't copy the items from the listbox to my listview, it justs puts "-1" in the listview. I'm assuming thats the return value of GUICtrlListGetText but don't know how to fix it?

FireLord

http://www.autoitscript.com/forum/index.ph...st&p=436419

_GUICtrlListCount << You have this function in your Beta?

Edit:

Hell... Or this function? _GUICtrlListGetText

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

http://www.autoitscript.com/forum/index.ph...st&p=436419

_GUICtrlListCount << You have this function in your Beta?

Edit:

Hell... Or this function? _GUICtrlListGetText

Umm...why did you tell me to change _GUICtrlListCount with _GUICtrlListBox_GetCount when _GUICtrlListBox_GetCount isn't even a function (I get an error saying unknown function name).

Hell... Or this function? _GUICtrlListGetText

And I don't know what that means ^

EDIT:

P.S: I have version 3.2.9.13

Edited by FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

I just upgraded to 3.2.9.14 and it :P my code up. ;) It doesn't even work anymore (my program).

If IsArray($buddiesSearch) Then
                        For $i = 1 To $buddiesSearch[0]
                            Send($buddiesSearch[$i] & "{Enter}"); Search for each individual player
                        Next
                        Sleep(500)
                        For $i = 0 To _GUICtrlListBox_GetCount($ListBox) - 1
                        Next
                            GUICtrlCreateListViewItem(_GUICtrlListBox_GetText($ListBox, $i), $sListView)                    
                    EndIf

^^^That doesn't even work. Instead of copying all the items in the listbox into my listview (which it was supposed to do) it put a "-1" in my listview. Now that I "updated" and used _GUICtrlListBox_GetText and _GUICtrlListBox_GetCount nothing works now!

So it seems I'm back to square on on solving the problem of how do I copy all of the items from the listbox into my listview? I'm using 3.2.9.14.

Any helpful advice would be greatly appreciated.

FireLord

Edited by FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

  • Moderators

I just upgraded to 3.2.9.14 and it :P my code up. ;) It doesn't even work anymore (my program).

If IsArray($buddiesSearch) Then
                        For $i = 1 To $buddiesSearch[0]
                            Send($buddiesSearch[$i] & "{Enter}"); Search for each individual player
                        Next
                        Sleep(500)
                        For $i = 0 To _GUICtrlListBox_GetCount($ListBox) - 1
                        Next
                            GUICtrlCreateListViewItem(_GUICtrlListBox_GetText($ListBox, $i), $sListView)                    
                    EndIf

^^^That doesn't even work. Instead of copying all the items in the listbox into my listview (which it was supposed to do) it put a "-1" in my listview. Now that I "updated" and used _GUICtrlListBox_GetText and _GUICtrlListBox_GetCount nothing works now!

So it seems I'm back to square on on solving the problem of how do I copy all of the items from the listbox into my listview? I'm using 3.2.9.14.

Any helpful advice would be greatly appreciated.

FireLord

I think you need to slow down a bit.

Figure out which you are going to program in... and stick to it (Beta or Release).

Your code wasn't working before the download, and just because you are getting errors now, doesn't mean much when you have REFUSED to write a replication script that causes the issue that everyone can run to fix your issue.

You flammed someone not too long ago for asking for one (In another thread), and here you are DAYS later, still trying to fix an issue that if you had put 20/30 minutes into a replication script, the issue would have more than likely been solved.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...