Sign in to follow this  
Followers 0
ameer

need help building 'account profiles' GuiCtrlListView

1 post in this topic

#1 ·  Posted (edited)

Hi, im new to this AutoIT. I've compiled a few program using AutoIT already, and this is the best programming software i've used.
 
I need to make a simple program to manage my online game account. It can list down account profiles it read from .ini, and display them in listwindow, with Edit/Delete/Save button.
 
I've Created GUI for the program already, i just dont know how to make the 'Edit/Save/Delete' functioning.

I know what to do with other button/functions, i just need help with listview.

I need to make it when you click Edit button on selected profile, a small window popup for editing.

INI file setting would be :

[ID1]
ID=
Pass=
Path=
[ID2]
ID=
Pass=
Path=

So GUICtrlCreateListViewItem would read info from this file, and display them on the list view.

I've always wanted to do somtin like this lol but i just dont know how, i been googling for weeks and still no clue how



Opt("GUIOnEventMode", 1)
$Form2 = GUICreate("Form1", 655, 344, 472, 179)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form2Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form2Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form2Restore")
$TITLE = "Test-Profile"
$OPTIONS = GuiCreate($TITLE, 655, 344, 472, 179)
GUICtrlSetColor(-1, 16711680)
$INI = "SFDFI.DAT"
$Group1 = GUICtrlCreateGroup("Profiles", 240, 0, 409, 257)
$List1 = GUICtrlCreateListView("Name|Email|Password|Path", 320, 32, 321, 201)
GUICtrlSendMsg($List1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg($List1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg($List1, $LVM_SETCOLUMNWIDTH, 2, 100)
GUICtrlSendMsg($List1, $LVM_SETCOLUMNWIDTH, 3, 100)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($List1), 1, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($List1), 2, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($List1), 3, 2)
$LIST1 = GUICtrlCreateListViewItem("ID1|" & IniRead($INI, "ID1", "ID", ""), $LIST1)
$LIST2 = GUICtrlCreateListViewItem("ID2|" & IniRead($INI, "ID2", "Pass", ""), $LIST1)
$List1_1 = GUICtrlCreateListViewItem("ID2|", $List1)
$List1_2 = GUICtrlCreateListViewItem("ID3|", $List1)
$List1_3 = GUICtrlCreateListViewItem("ID4|", $List1)
$List1_4 = GUICtrlCreateListViewItem("ID5|", $List1)
GUICtrlSetOnEvent($List1, "List1Click")
$Edit = GUICtrlCreateButton("Edit", 248, 48, 59, 25)
GUICtrlSetOnEvent($Edit, "EditClick")
$Save = GUICtrlCreateButton("Save", 248, 80, 59, 25)
GUICtrlSetOnEvent($Save, "SaveClick")
$Delete = GUICtrlCreateButton("Delete", 248, 112, 59, 25)
GUICtrlSetOnEvent($Delete, "DeleteClick")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("Test Profiles", 8, 16, 227, 30)
GUICtrlSetFont($Label1, 18, 800, 0, "Times New Roman")
GUICtrlSetColor($Label1, 0xFF0000)
GUICtrlSetOnEvent($Label1, "Label1Click")
$Group2 = GUICtrlCreateGroup("Group2", 8, 128, 225, 129)
$Profile = GUICtrlCreateButton("Profile", 24, 152, 75, 25)
GUICtrlSetOnEvent($Profile, "ProfileClick")
$Refresh = GUICtrlCreateButton("Refresh", 24, 184, 75, 25)
GUICtrlSetOnEvent($Refresh, "RefreshClick")
$Button1 = GUICtrlCreateButton("Auto Scan", 24, 216, 75, 25)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Label2 = GUICtrlCreateLabel("Create New Profile", 112, 152, 92, 25, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetOnEvent($Label2, "Label2Click")
$Label3 = GUICtrlCreateLabel("Refresh Profiles Data", 112, 184, 104, 25, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetOnEvent($Label3, "Label3Click")
$Label4 = GUICtrlCreateLabel("Scan Game Folder", 112, 216, 92, 25, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetOnEvent($Label4, "Label4Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$DIR = GUICtrlCreateInput("DIR", 8, 272, 321, 21)
GUICtrlSetOnEvent($DIR, "DIRChange")
GUICtrlSetTip($DIR, "Browse SF Directory")
$Browse = GUICtrlCreateButton("Browse", 336, 272, 75, 25)
GUICtrlSetOnEvent($Browse, "BrowseClick")
$About = GUICtrlCreateButton("About", 8, 304, 75, 25)
GUICtrlSetOnEvent($About, "AboutClick")
$DONE = GUICtrlCreateButton("Done", 568, 304, 75, 25)
GUICtrlSetOnEvent($Done, "DoneClick")
$Exit = GUICtrlCreateButton("Exit", 96, 304, 75, 25)
GUICtrlSetOnEvent($Exit, "ExitClick")
$List2 = GUICtrlCreateList("", 56, 80, 129, 19)
GUICtrlSetOnEvent($List2, "List2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $MSG = GUIGetMsg()
        Select
            Case $MSG = $GUI_EVENT_CLOSE
                Exit

Func AboutClick()

EndFunc

I have a sample autoIT script from an open source program my friend wrote long time ago, it has similiar listview i wanted to make. I tried copied and paste and make some editing here & there but it wont work.

Here's her code.

$LISTVIEW = GUICtrlCreateListView(" Num |     Email      |      PW      |       Path      |  ID  ", 216, 112, 329, 185)
    $LIST1 = GUICtrlCreateListViewItem("No1|" & IniRead($HOTKEYFILE, "NUM1", "pos", ""), $LISTVIEW)
    $LIST2 = GUICtrlCreateListViewItem("No2|" & IniRead($HOTKEYFILE, "NUM2", "pos", ""), $LISTVIEW)
    $LIST3 = GUICtrlCreateListViewItem("No3|" & IniRead($HOTKEYFILE, "NUM3", "pos", ""), $LISTVIEW)
    $LIST4 = GUICtrlCreateListViewItem("No4|" & IniRead($HOTKEYFILE, "NUM4", "pos", ""), $LISTVIEW)
    $LIST5 = GUICtrlCreateListViewItem("No5|" & IniRead($HOTKEYFILE, "NUM5", "pos", ""), $LISTVIEW)
    $LIST6 = GUICtrlCreateListViewItem("No6|" & IniRead($HOTKEYFILE, "NUM6", "pos", ""), $LISTVIEW)
    $LIST7 = GUICtrlCreateListViewItem("No7|" & IniRead($HOTKEYFILE, "NUM7", "pos", ""), $LISTVIEW)
    $LIST8 = GUICtrlCreateListViewItem("No8|" & IniRead($HOTKEYFILE, "NUM8", "pos", ""), $LISTVIEW)
    $LIST9 = GUICtrlCreateListViewItem("No9|" & IniRead($HOTKEYFILE, "NUM9", "pos", ""), $LISTVIEW)
    $LIST0 = GUICtrlCreateListViewItem("No0|" & IniRead($HOTKEYFILE, "NUM0", "pos", ""), $LISTVIEW)
    $EDITLISTVIEW = GUICtrlCreateButton("Edit", 152, 136, 57, 17, 0)
    $DELETELISTVIEW = GUICtrlCreateButton("Delete", 152, 160, 57, 17, 0)
    $SAVELISTVIEW = GUICtrlCreateButton("Save", 152, 184, 57, 17, 0)
    $ABOUTBUTTON = GUICtrlCreateButton("About", 80, 328, 57, 25, 0)
    $DONEBUTTON = GUICtrlCreateButton("Done", 488, 328, 57, 25, 0)
    GUISetState(@SW_SHOW)
    While 1
        $MSG = GUIGetMsg()
        Select
            Case $MSG = $GUI_EVENT_CLOSE
                Exit
            Case $MSG = $EDITLISTVIEW
                $QPSEL = GUICtrlRead($LISTVIEW)
                If Not $QPSEL = 0 Then
                    $QPSELDATA = GUICtrlRead($QPSEL)
                    $QPCURRENTSEL = StringReplace(StringTrimLeft($QPSELDATA, 6), "|", ",")
                    $QPCHILD = GUICreate("Edit Hotkey", 180, 80, -1, -1, -1, -1, $OPTIONS)
                    GUICtrlCreateLabel("Enter Coordinates", 0, 5, 180, 30, $ES_CENTER)
                    GUICtrlCreateLabel("(Format: name,x,y,z)", 20, 57)
                    $EDITQP = GUICtrlCreateInput($QPCURRENTSEL, 15, 30, 150, 22)
                    $APPLYQP = GUICtrlCreateButton("Apply", 120, 55, 40, 20)
                    GUISetState()
                    While 1
                        $MSGQP = GUIGetMsg()
                        Select
                            Case $MSGQP = $GUI_EVENT_CLOSE
                                ExitLoop
                            Case $MSGQP = $APPLYQP
                                GUICtrlSetData($QPSEL, StringTrimRight($QPSELDATA, StringLen($QPSELDATA) - 6) & StringReplace(GUICtrlRead($EDITQP), ",", "|"))
                                ExitLoop
                        EndSelect
                    WEnd
                    GUIDelete($QPCHILD)
                Else
                    Sleep(10)
                EndIf
            Case $MSG = $DELETELISTVIEW
                $QPSEL = GUICtrlRead($LISTVIEW)
                If Not $QPSEL = 0 Then
                    $QPSELDATA = GUICtrlRead($QPSEL)
                    GUICtrlSetData($QPSEL, StringTrimRight($QPSELDATA, StringLen($QPSELDATA) - 6) & " | | |")
                Else
                    Sleep(10)
                EndIf
            Case $MSG = $SAVELISTVIEW
                IniWrite($HOTKEYFILE, "NUM1", "pos", StringTrimLeft(GUICtrlRead($LIST1), 6))
                IniWrite($HOTKEYFILE, "NUM2", "pos", StringTrimLeft(GUICtrlRead($LIST2), 6))
                IniWrite($HOTKEYFILE, "NUM3", "pos", StringTrimLeft(GUICtrlRead($LIST3), 6))
                IniWrite($HOTKEYFILE, "NUM4", "pos", StringTrimLeft(GUICtrlRead($LIST4), 6))
                IniWrite($HOTKEYFILE, "NUM5", "pos", StringTrimLeft(GUICtrlRead($LIST5), 6))
                IniWrite($HOTKEYFILE, "NUM6", "pos", StringTrimLeft(GUICtrlRead($LIST6), 6))
                IniWrite($HOTKEYFILE, "NUM7", "pos", StringTrimLeft(GUICtrlRead($LIST7), 6))
                IniWrite($HOTKEYFILE, "NUM8", "pos", StringTrimLeft(GUICtrlRead($LIST8), 6))
                IniWrite($HOTKEYFILE, "NUM9", "pos", StringTrimLeft(GUICtrlRead($LIST9), 6))
                IniWrite($HOTKEYFILE, "NUM0", "pos", StringTrimLeft(GUICtrlRead($LIST0), 6))
            Case $MSG = $HELPBUTTON
                SHOWHELP()
            Case $MSG = $ABOUTBUTTON
                $ABOUTGUI = GUICreate("About", 150, 100, -1, -1, -1, -1, $OPTIONS)
                GUICtrlCreateLabel($TITLE & @CRLF & @CRLF & "edited." & @CRLF & $DATE & @CRLF & @CRLF & "© edited.", 0, 5, 150, 95, $ES_CENTER)
                GUISetState()
                While 1
                    $ABOUTMSG = GUIGetMsg()
                    Select
                        Case $ABOUTMSG = $GUI_EVENT_CLOSE
                            ExitLoop
                    EndSelect
                WEnd
                GUIDelete($ABOUTGUI)
            Case $MSG = $DONEBUTTON Or _IsPressed("0D") And WinActive($TITLE)
                IniWrite($HOTKEYFILE, "NUM1", "pos", StringTrimLeft(GUICtrlRead($LIST1), 6))
                IniWrite($HOTKEYFILE, "NUM2", "pos", StringTrimLeft(GUICtrlRead($LIST2), 6))
                IniWrite($HOTKEYFILE, "NUM3", "pos", StringTrimLeft(GUICtrlRead($LIST3), 6))
                IniWrite($HOTKEYFILE, "NUM4", "pos", StringTrimLeft(GUICtrlRead($LIST4), 6))
                IniWrite($HOTKEYFILE, "NUM5", "pos", StringTrimLeft(GUICtrlRead($LIST5), 6))
                IniWrite($HOTKEYFILE, "NUM6", "pos", StringTrimLeft(GUICtrlRead($LIST6), 6))
                IniWrite($HOTKEYFILE, "NUM7", "pos", StringTrimLeft(GUICtrlRead($LIST7), 6))
                IniWrite($HOTKEYFILE, "NUM8", "pos", StringTrimLeft(GUICtrlRead($LIST8), 6))
                IniWrite($HOTKEYFILE, "NUM9", "pos", StringTrimLeft(GUICtrlRead($LIST9), 6))
                IniWrite($HOTKEYFILE, "NUM0", "pos", StringTrimLeft(GUICtrlRead($LIST0), 6))
Edited by ameer

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