Jeff, I'm not quite sure what the problem is? All of your questions until this email, have been about how to add list view items from the script itself. when doing that, you need to add each item and it's subitems one at a time. the line in your email just now seems to be your wanting to retrieve the values from the listview; and in fact, you don't have any code in the script for adding the listview items, they seem to be hard-coded in your xml. yes, the syntax for retrieving an entire row for speaking does look quite different from that used to build the listview, where you can't (according to the documentation) build an entire row at once; you have to add each item separately. so, tell me again what part is giving you the difficulty? (sorry for my not being able to follow your thread on this). Chip
_____ From: Jeff Weiss [mailto:[email protected]] Sent: Monday, November 01, 2010 11:31 AM To: [email protected] Subject: RE: adding new items to a listview Chip, I still am not having any success with this listview. What I did find out, is that when the listview items are listed in the .xml file, the following line works for getting all items in a row: TextToSpeak = dObj.Control("lv_sample1").Text & " " & dObj.Control("lv_sample1").Text(, 1) & " " & dObj.Control("lv_sample1").Text(, 2) Note the commas. The script for this and the xml follow. When, however, the listview items are added from the script itself, I still am at a loss. ' DialogListView ' listview items set in xml file Dim isVisible : isVisible = 0 Dim myHotkey : Set myHotkey = Keyboard.RegisterHotkey("Alt-Control-Shift-I","LaunchDialog") Sub LaunchDialog() If isVisible = 0 Then Queue "DisplayDialog" End If End Sub Sub DisplayDialog() Dialog "DialogListView.xml", "MyDialog1", "DialogEventHandler" End Sub Function DialogEventHandler(dObj, dEvent, dId, dControl) DialogEventHandler = False Select Case dId Case "btn_ok" If dEvent = buttonClicked Then SpeakResult dObj, dEvent, dId, dControl DialogEventHandler = True Exit Function End If Case "btn_cancel" If dEvent = buttonClicked Then Speak "closing dialog " Sleep 200 isVisible = 0 dObj.Close DialogEventHandler = True Exit Function End If Case Else If dEvent = dialogCreated Then isVisible = 1 DialogEventHandler = True Exit Function End If End Select End Function Function SpeakResult(dObj, dEvent, dId, dControl) Dim textToSpeak ' for just first column ' TextToSpeak = dObj.Control("lv_sample1").Text ' for all three columns TextToSpeak = dObj.Control("lv_sample1").Text & " " & dObj.Control("lv_sample1").Text(, 1) & " " & dObj.Control("lv_sample1").Text(, 2) Speak "You have chosen " & textToSpeak End Function <?xml version="1.0" encoding="UTF-8" standalone="no"?> <wescriptui> <options> <languageorder> WE,OS,en-us </languageorder> </options> <language id="en-us"> <dialog id="MyDialog1"> Dialog ListView <group> <group orientation="vertical"> <listview id="lv_sample1"> <listviewcolumn> Name </listviewcolumn> <listviewcolumn> Color </listviewcolumn> <listviewcolumn> Number </listviewcolumn> <listviewitem> Option 1 <subitem> Red </subitem> <subitem> 4221 </subitem> </listviewitem> <listviewitem> Option 2 <subitem> Green </subitem> <subitem> 1235 </subitem> </listviewitem> <listviewitem> Option 3 <subitem> Orange </subitem> <subitem> 6414 </subitem> </listviewitem> </listview> </group> <group> <button id="btn_ok" system="ok" default="yes" widthclass="btn"> OK </button> <button id="btn_cancel" system="cancel" widthclass="btn" width="+10"> Close </button> </group> </group> </dialog> </language> </wescriptui> From: Chip Orange [mailto:[email protected]] Sent: Saturday, October 30, 2010 8:20 PM To: [email protected] Subject: RE: adding new items to a listview Jeff, here's a bit of the documentation example used in the insert method of the listViewItem object; it shows how you set the values for each column in the listView with a separate assignment statement for each one. the very first column, the person's name in this case, should be the only value in your assignment statement for the .text property; you should remove all the rest of the items (except for the name) from those lines as the example below shows: ' Now we'll add a single item to the list view Set newLVItem = dObj.Control("listview1").NewItem newLVItem.Text = "Aaron" newLVItem.Insert dObj.Control("listview1").Items.Count + 1 newLVItem.Text(1) = "Obsidian Blue" newLVItem.Text(2) = "42" ' The list view now contains a single item, which Window-Eyes would read (by default), "Aaron, Favorite Color Obsidian Blue, Favorite Number 42." _____ From: Jeff Weiss [mailto:[email protected]] Sent: Friday, October 29, 2010 9:19 AM To: [email protected] Subject: RE: adding new items to a listview This is supposed to show the name, favorite color, and favorite number. The XML and VBS files follow: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <wescriptui> <options> <languageorder> WE,OS,en-us </languageorder> </options> <language id="en-us"> <dialog id="MyDialog1"> Dialog ListView <group> <group orientation="vertical"> <listview id="listview1" view="report"> <listviewcolumn> Name </listviewcolumn> <listviewcolumn> Favorite Color </listviewcolumn> <listviewcolumn> Favorite Number </listviewcolumn> </listview> </group> <group> <button id="btn_ok" system="ok" default="yes" widthclass="btn"> OK </button> <button id="btn_cancel" system="cancel" widthclass="btn" width="+10"> Close </button> </group> </group> </dialog> </language> </wescriptui> Option Explicit ' We'll assume we have a list view whose ID is "listview1" which contains no items by default Dim isVisible : isVisible = 0 Dim Mark Dim MyHotkey : Set MyHotkey = Keyboard.RegisterHotkey("Control-Alt-Shift-I", "LaunchDialog") Sub LaunchDialog() If isVisible = 0 Then Queue "DisplayDialog" End If End Sub Sub DisplayDialog() Dialog "DialogListViewFromScript.xml", "MyDialog1", "DialogEventHandler" End Sub Function DialogEventHandler(dObj, dEvent, dId, dControl) DialogEventHandler = False ' Now we'll add items to the list view If Mark < 1 Then Dim NewLvItem Set newLVItem = dObj.Control("listview1").NewItem newLVItem.Text = "Aaron" & " " & dObj.Control("listview1").Text(1) & " " & dObj.Control("listview1").Text(2) newLVItem.Insert dObj.Control("listview1").Items.Count+1 newLVItem.Text(1) = "Obsidian Blue" newLVItem.Text(2) = "42" Dim NewLvItem2 Set newLVItem2 = dObj.Control("listview1").NewItem newLVItem2.Text = "Jeff" & " " & dObj.Control("listview1").Text(1) & " " & dObj.Control("listview1").Text(2) newLVItem2.Insert dObj.Control("listview1").Items.Count+1 newLVItem2.Text(1) = "Red" newLVItem2.Text(2) = "97" Dim NewLvItem3 Set newLVItem3 = dObj.Control("listview1").NewItem newLVItem3.Text = "Doug" & " " & dObj.Control("listview1").Text(5) & " " & dObj.Control("listview1").Text(6) newLVItem3.Insert dObj.Control("listview1").Items.Count+1 newLVItem.Text(1) = "Orange" newLVItem.Text(2) = "256" Mark = Mark + 1 End If ' The list view items would be read as "Aaron, Favorite Color Obsidian Blue, Favorite Number 42." Select Case dId Case "btn_ok" If dEvent = buttonClicked Then SpeakResult dObj, dEvent, dId, dControl DialogEventHandler = True Exit Function End If Case "btn_cancel" If dEvent = buttonClicked Then Speak "close" Sleep 200 isVisible = 0 dObj.Close DialogEventHandler = True Exit Function End If Case Else If dEvent = dialogCreated Then isVisible = 1 DialogEventHandler = True Exit Function End If End Select End Function Sub SpeakResult(dObj, dEvent, dId, dControl) Dim textToSpeak ' for just first column text ' TextToSpeak = dObj.Control("listview1").Text ' for entire row TextToSpeak = dObj.Control("listview1").Text & " " & dObj.Control("listview1").Text(1) & " " & dObj.Control("listview1").Text(2) Speak "You have chosen " & textToSpeak End Sub From: Chip Orange [mailto:[email protected]] Sent: Friday, October 29, 2010 6:31 AM To: [email protected] Subject: RE: adding new items to a listview Hi Jeff, Not that I blame you, the documentation for these two topics (listview and listviewitem) really could use some reworking for clarity's sake. however, your lines like: newLVItem.Text = "Aaron" & " " & dObj.Control("listview1").Text(1) & " " & dObj.Control("listview1").Text(2) don't seem to mean anything to me; I mean, the portion beyond the string of "Aaron" that is. maybe if you said what the listview should look like it would be clearer to me? thanks. Chip _____ From: Jeff Weiss [mailto:[email protected]] Sent: Thursday, October 28, 2010 11:56 AM To: [email protected] Subject: adding new items to a listview I am trying to figure out how to add additional items to a listview. I want to add the items in my .vbs file. What's wrong with these to items? I am not sure how to increment to the next items: If Mark < 1 Then Dim NewLvItem Set newLVItem = dObj.Control("listview1").NewItem newLVItem.Text = "Aaron" & " " & dObj.Control("listview1").Text(1) & " " & dObj.Control("listview1").Text(2) newLVItem.Insert dObj.Control("listview1").Items.Count + 1 newLVItem.Text(1) = "Obsidian Blue" newLVItem.Text(2) = "42" ' here's the second item I am trying to add: Dim NewLvItem2 Set newLVItem2 = dObj.Control("listview1").NewItem newLVItem2.Text = "Jeff" & " " & dObj.Control("listview1").Text(1) & " " & dObj.Control("listview1").Text(2) newLVItem2.Insert dObj.Control("listview1").Items.Count + 1 newLVItem2.Text(1) = "Red" newLVItem2.Text(2) = "97" Mark = Mark + 1 End if Any help appreciated. Jeff Weiss
