LiquidNitrogen Posted February 3, 2012 Posted February 3, 2012 (edited) It's not for Windows Contacts. It's Just a Contact Viewer and Storer. No Special File Types or Anything. There's Still a Bug or 2. expandcollapse popup#include <GUIListView.au3> #include <File.au3> #include <EditConstants.au3> #NoTrayIcon Main() NewContact() EditContact() Func Main() If Not FileExists("bin.txt") Then FileWrite("bin.txt", "") If Not FileExists("data.ini") Then FileWrite("data.ini", "") GUIDelete() GUICreate("Contact Manager", 520, 330, -1, -1) Global $ContactList = GUICtrlCreateListView("", 10, 10, 200, 280) _GUICtrlListView_AddColumn($ContactList, "Contacts", 200) Global $BinLines = _FileCountLines("bin.txt") For $i = 1 To $BinLines _GUICtrlListView_AddItem($ContactList, FileReadLine("bin.txt", $i)) Next $Select = GUICtrlCreateButton("View ->", 230, 130, 60, 30) $InfoDisp = GUICtrlCreateEdit("Name: " & @CRLF & @CRLF & "Cell Number: " & @CRLF & @CRLF & "Work Number: " & @CRLF & @CRLF & "Home Number: " & @CRLF & @CRLF & "City: " & @CRLF & @CRLF & "State: " & @CRLF & @CRLF & "Zip Code: " & @CRLF & @CRLF & "Address: ", 310, 10, 200, 280, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) $NewContact = GUICtrlCreateButton("New Contact", 120, 295, 80, 30) $EditContact = GUICtrlCreateButton("Edit Contact", 220, 295, 80, 30) $DeleteContact = GUICtrlCreateButton("Delete Contact", 320, 295, 80, 30) $About = GUICtrlCreateButton("About", 10, 295, 80, 30) $Exit = GUICtrlCreateButton("Exit", 430, 295, 80, 30) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 Exit Case $Select $SelMark = _GUICtrlListView_GetSelectionMark($ContactList) If _GUICtrlListView_GetSelectedCount($ContactList) > 0 Then $Selection = _GUICtrlListView_GetItemText($ContactList, $SelMark) $Name = IniRead("data.ini", $Selection, "name", "Error!") $Cell = IniRead("data.ini", $Selection, "cell", "None") $Work = IniRead("data.ini", $Selection, "work", "None") $Home = IniRead("data.ini", $Selection, "home", "None") $City = IniRead("data.ini", $Selection, "city", "None") $State = IniRead("data.ini", $Selection, "state", "None") $Zip = IniRead("data.ini", $Selection, "zip", "None") $Address = IniRead("data.ini", $Selection, "address", "None") GUICtrlSetData($InfoDisp, "Name: " & $Name & @CRLF & @CRLF & "Cell Number: " & $Cell & @CRLF & @CRLF & "Work Number: " & $Work & @CRLF & @CRLF & "Home Number: " & $Home & @CRLF & @CRLF & "City: " & $City & @CRLF & @CRLF & "State: " & $State & @CRLF & @CRLF & "Zip Code: " & $Zip & @CRLF & @CRLF & "Address: " & $Address) Else MsgBox(16, "Error!", "Select a Contact First!") EndIf Case $NewContact NewContact() Case $DeleteContact If _GUICtrlListView_GetSelectedCount($ContactList) > 0 Then $SelMark = _GUICtrlListView_GetSelectionMark($ContactList) $Selection = _GUICtrlListView_GetItemText($ContactList, $SelMark) $Confirm = MsgBox(36, "Confirm Delete", "Are you Sure you Want to Delete the Contact for " & $Selection & "?") If $Confirm = 6 Then For $i = 1 To $BinLines If FileReadLine("bin.txt", $i) = $Selection Then IniDelete("data.ini", $Selection) _FileWriteToLine("bin.txt", $i, "", 1) Main() EndIf Next EndIf Else MsgBox(16, "Error!", "Select a Contact First!") EndIf Case $EditContact If _GUICtrlListView_GetSelectedCount($ContactList) > 0 Then EditContact() Else MsgBox(16, "Error!", "Select a Contact First!") EndIf Case $About MsgBox(0, "About", "Contact Manager v1.0" & @LF & @LF & "Created By ReaperX") Case $Exit Exit EndSwitch WEnd EndFunc ;==>Main Func NewContact() GUICreate("New Contact", 250, 330, -1, -1) GUICtrlCreateLabel("Enter the Information for the Contact", 35, 10) GUICtrlCreateLabel("Name:", 50, 50) $NewName = GUICtrlCreateInput("", 88, 49, 120, 18) GUICtrlCreateLabel("Cell Number:", 20, 80) $NewCell = GUICtrlCreateInput("", 88, 79, 120, 18) GUICtrlCreateLabel("Home Number:", 10, 110) $NewHome = GUICtrlCreateInput("", 88, 109, 120, 18) GUICtrlCreateLabel("Work Number:", 10, 140) $NewWork = GUICtrlCreateInput("", 88, 139, 120, 18) GUICtrlCreateLabel("City:", 60, 170) $NewCity = GUICtrlCreateInput("", 88, 169, 120, 18) GUICtrlCreateLabel("State:", 50, 200) $NewState = GUICtrlCreateInput("", 88, 199, 120, 18) GUICtrlCreateLabel("Zip:", 60, 230) $NewZip = GUICtrlCreateInput("", 88, 229, 120, 18) GUICtrlCreateLabel("Address:", 40, 260) $NewAddress = GUICtrlCreateInput("", 88, 259, 120, 18) $Create = GUICtrlCreateButton("Create", 40, 290, 80, 30) $Cancel = GUICtrlCreateButton("Cancel", 130, 290, 80, 30) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 GUIDelete() ExitLoop Case $Create If GUICtrlRead($NewName) = "" Or GUICtrlRead($NewName) = " " Then MsgBox(16, "Error!", "A Name is Required!") GUIDelete() NewContact() EndIf If GUICtrlRead($NewCell) = "" And GUICtrlRead($NewHome) = "" And GUICtrlRead($NewWork) = "" Then MsgBox(16, "Error!", "At least 1 Phone Number is Required!") GUIDelete() NewContact() EndIf $BinLines = _FileCountLines("bin.txt") _FileWriteToLine("bin.txt", $BinLines + 1, GUICtrlRead($NewName), 1) IniWrite("data.ini", GUICtrlRead($NewName), "name", GUICtrlRead($NewName)) IniWrite("data.ini", GUICtrlRead($NewName), "cell", GUICtrlRead($NewCell)) IniWrite("data.ini", GUICtrlRead($NewName), "home", GUICtrlRead($NewHome)) IniWrite("data.ini", GUICtrlRead($NewName), "work", GUICtrlRead($NewWork)) IniWrite("data.ini", GUICtrlRead($NewName), "city", GUICtrlRead($NewCity)) IniWrite("data.ini", GUICtrlRead($NewName), "state", GUICtrlRead($NewState)) IniWrite("data.ini", GUICtrlRead($NewName), "zip", GUICtrlRead($NewZip)) IniWrite("data.ini", GUICtrlRead($NewName), "address", GUICtrlRead($NewAddress)) MsgBox(0, "OK", "New Contact Created for " & GUICtrlRead($NewName) & "!") GUIDelete() Main() Case $Cancel GUIDelete() ExitLoop EndSwitch WEnd EndFunc ;==>NewContact Func EditContact() Global $ContactList, $BinLines GUICreate("Edit Contact", 250, 330, -1, -1) $SelMark = _GUICtrlListView_GetSelectionMark($ContactList) $Selection = _GUICtrlListView_GetItemText($ContactList, $SelMark) GUICtrlCreateLabel("Edit the Information for the Contact", 40, 10) GUICtrlCreateLabel("Name:", 50, 50) $NewName = GUICtrlCreateInput(IniRead("data.ini", $Selection, "name", "Error!"), 88, 49, 120, 18) GUICtrlCreateLabel("Cell Number:", 20, 80) $NewCell = GUICtrlCreateInput(IniRead("data.ini", $Selection, "cell", "Error!"), 88, 79, 120, 18) GUICtrlCreateLabel("Home Number:", 10, 110) $NewHome = GUICtrlCreateInput(IniRead("data.ini", $Selection, "home", "Error!"), 88, 109, 120, 18) GUICtrlCreateLabel("Work Number:", 10, 140) $NewWork = GUICtrlCreateInput(IniRead("data.ini", $Selection, "work", "Error!"), 88, 139, 120, 18) GUICtrlCreateLabel("City:", 60, 170) $NewCity = GUICtrlCreateInput(IniRead("data.ini", $Selection, "city", "Error!"), 88, 169, 120, 18) GUICtrlCreateLabel("State:", 50, 200) $NewState = GUICtrlCreateInput(IniRead("data.ini", $Selection, "state", "Error!"), 88, 199, 120, 18) GUICtrlCreateLabel("Zip:", 60, 230) $NewZip = GUICtrlCreateInput(IniRead("data.ini", $Selection, "zip", "Error!"), 88, 229, 120, 18) GUICtrlCreateLabel("Address:", 40, 260) $NewAddress = GUICtrlCreateInput(IniRead("data.ini", $Selection, "address", "Error!"), 88, 259, 120, 18) $Save = GUICtrlCreateButton("Save", 40, 290, 80, 30) $Cancel = GUICtrlCreateButton("Cancel", 130, 290, 80, 30) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 GUIDelete() Main() Case $Save $Confirm = MsgBox(36, "Confirm Save", "Are you Sure you Wish to Save the Contact Info?") If $Confirm = 6 Then If GUICtrlRead($NewName) = "" Or GUICtrlRead($NewName) = " " Then MsgBox(16, "Error!", "A Name is Required!") GUIDelete() NewContact() EndIf For $i = 1 To $BinLines If FileReadLine("bin.txt", $i) = $Selection Then _FileWriteToLine("bin.txt", $i, GUICtrlRead($NewName), 1) EndIf Next IniWrite("data.ini", GUICtrlRead($NewName), "name", GUICtrlRead($NewName)) IniWrite("data.ini", GUICtrlRead($NewName), "cell", GUICtrlRead($NewCell)) IniWrite("data.ini", GUICtrlRead($NewName), "home", GUICtrlRead($NewHome)) IniWrite("data.ini", GUICtrlRead($NewName), "work", GUICtrlRead($NewWork)) IniWrite("data.ini", GUICtrlRead($NewName), "city", GUICtrlRead($NewCity)) IniWrite("data.ini", GUICtrlRead($NewName), "state", GUICtrlRead($NewState)) IniWrite("data.ini", GUICtrlRead($NewName), "zip", GUICtrlRead($NewZip)) IniWrite("data.ini", GUICtrlRead($NewName), "address", GUICtrlRead($NewAddress)) MsgBox(0, "OK", "Contact for " & $Selection & " Has been Updated!") GUIDelete() Main() EndIf Case $Cancel GUIDelete() ExitLoop EndSwitch WEnd EndFunc ;==>EditContact Edited February 3, 2012 by ReaperX Formerly ReaperX
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now