Jump to content

Phone Book


Recommended Posts

I wrote this for my wife so she could keep her phone numbers organized. I know theres a million different ways to do things better than how i have done them with this, but meh, use it or dont, its free :>

I created a folder named "phonenumbers" in C. "C:\phonenumbers\" I added the compiled source for entering info, named it "pbei.exe", then added 4 notepad files to the folder. "misc.txt" "friends.txt" "family.txt" "work.txt". and an image, which you could make or remove the code for.

Part 1

CODE
#include <GUIConstants.au3>

#include <GuiTreeView.au3>

GUICreate("Phone Book", 550, 390)

GUICtrlCreatePic("C:\phonebook\phonepic.jpg",165,12, 377,123)

$listview = GUICtrlCreateListView (" Name | Number | Email | Address ",5,150,540,230)

$treeview = GUICtrlCreateTreeView(5, 5, 150, 100, BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)

$generalitem = GUICtrlCreateTreeViewitem("Numbers", $treeview)

GUICtrlSetColor(-1, 0x0000C0)

$misclist = GUICtrlCreateTreeViewitem("Misc", $generalitem)

$friendlist = GUICtrlCreateTreeViewitem("Friends", $generalitem)

$familylist = GUICtrlCreateTreeViewitem("Family", $generalitem)

$worklist = GUICtrlCreateTreeViewitem("Work", $generalitem)

$newinfo = GUICtrlCreateButton("Enter New Information", 5, 115, 150, 25)

GUICtrlSetState($generalitem, BitOr($GUI_EXPAND,$GUI_DEFBUTTON))

GUISetState ()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $misclist

_open()

Case $msg = $friendlist

_open1()

Case $msg = $familylist

_open2()

Case $msg = $worklist

_open3()

Case $msg = $newinfo

_newinfo2()

EndSelect

WEnd

Func _open()

$file = FileOpen("C:\phonebook\misc.txt", 0)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

GUICtrlCreateListViewItem($line,$listview)

Wend

FileClose($file)

EndFunc

Func _open1()

$file = FileOpen("C:\phonebook\friends.txt", 0)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

GUICtrlCreateListViewItem($line,$listview)

Wend

FileClose($file)

EndFunc

Func _open2()

$file = FileOpen("C:\phonebook\family.txt", 0)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

GUICtrlCreateListViewItem($line,$listview)

Wend

FileClose($file)

EndFunc

Func _open3()

$file = FileOpen("C:\phonebook\work.txt", 0)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

GUICtrlCreateListViewItem($line,$listview)

Wend

FileClose($file)

EndFunc

Func _newinfo2()

ShellExecute("pbei.exe", "", "C:\phonebook\")

EndFunc

Part 2

CODE
#include <GUIConstants.au3>

$file = FileOpen("C:\phonebook\misc.txt", 1)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

$file2 = FileOpen("C:\phonebook\friends.txt", 1)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

$file3 = FileOpen("C:\phonebook\family.txt", 1)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

$file4 = FileOpen("C:\phonebook\work.txt", 1)

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

GUICreate("Enter New Information", 410, 300, -1, -1)

$Label1 = GUICtrlCreateLabel("Enter Information, then Save to the group you want it in.", 15, 10, 300, 15)

GUICtrlSetColor(-1,0xE3170D)

$Label1 = GUICtrlCreateLabel("Name:", 10, 30, 130, 15)

GUICtrlSetColor(-1,0x0000FF)

$Input1 = GUICtrlCreateInput("", 10, 45, 390, 20)

$Label2 = GUICtrlCreateLabel("Number:", 10, 70, 130, 15)

GUICtrlSetColor(-1,0x0000FF)

$Input2 = GUICtrlCreateInput("", 10, 85, 390, 20)

$Label3 = GUICtrlCreateLabel("Email:", 10, 110, 130, 15)

GUICtrlSetColor(-1,0x0000FF)

$Input3 = GUICtrlCreateInput("", 10, 125, 390, 20)

$Label4 = GUICtrlCreateLabel("Address:", 10, 150, 130, 15)

GUICtrlSetColor(-1,0x0000FF)

$Input4 = GUICtrlCreateInput("", 10, 165, 390, 20)

$record = GUICtrlCreateButton("Save to Misc", 10, 200, 90, 40)

$record2 = GUICtrlCreateButton("Save to Friends", 110, 200, 90, 40)

$record3 = GUICtrlCreateButton("Save to Family", 210, 200, 90, 40)

$record4 = GUICtrlCreateButton("Save to Work", 310, 200, 90, 40)

$manedit = GUICtrlCreateButton("Edit misc", 10, 260, 90, 30)

$manedit2 = GUICtrlCreateButton("Edit Friends", 110, 260, 90, 30)

$manedit3 = GUICtrlCreateButton("Edit Family", 210, 260, 90, 30)

$manedit4 = GUICtrlCreateButton("Edit Work", 310, 260, 90, 30)

GUISetState ()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $record

_save()

Case $msg = $record2

_save2()

Case $msg = $record3

_save3()

Case $msg = $record4

_save4()

Case $msg = $manedit

_edit()

Case $msg = $manedit2

_edit2()

Case $msg = $manedit3

_edit3()

Case $msg = $manedit4

_edit4()

EndSelect

WEnd

Func _save()

$a = guictrlread($input1)

$b = guictrlread($input2)

$c = guictrlread($input3)

$d = guictrlread($input4)

FileWrite($file, @CRLF)

FileWrite($file, ($a) & "|" & ($:) & "|" & ($c) & "|" & ($d))

FileClose($file)

TrayTip("Phone Book", "Recording information then exiting to save.", 7, 1)

Sleep(2000)

Exit

EndFunc

Func _save2()

$a = guictrlread($input1)

$b = guictrlread($input2)

$c = guictrlread($input3)

$d = guictrlread($input4)

FileWrite($file2, @CRLF)

FileWrite($file2, ($a) & "|" & ($:lmao: & "|" & ($c) & "|" & ($d))

FileClose($file2)

TrayTip("Phone Book", "Recording information then exiting to save.", 7, 1)

Sleep(2000)

Exit

EndFunc

Func _save3()

$a = guictrlread($input1)

$b = guictrlread($input2)

$c = guictrlread($input3)

$d = guictrlread($input4)

FileWrite($file3, @CRLF)

FileWrite($file3, ($a) & "|" & ($:think: & "|" & ($c) & "|" & ($d))

FileClose($file3)

TrayTip("Phone Book", "Recording information then exiting to save.", 7, 1)

Sleep(2000)

Exit

EndFunc

Func _save4()

$a = guictrlread($input1)

$b = guictrlread($input2)

$c = guictrlread($input3)

$d = guictrlread($input4)

FileWrite($file4, @CRLF)

FileWrite($file4, ($a) & "|" & ($:shhh: & "|" & ($c) & "|" & ($d))

FileClose($file4)

TrayTip("Phone Book", "Recording information then exiting to save.", 7, 1)

Sleep(2000)

Exit

EndFunc

Func _edit()

ShellExecute("misc.txt", "", "C:\phonebook\")

EndFunc

Func _edit2()

ShellExecute("friends.txt", "", "C:\phonebook\")

EndFunc

Func _edit3()

ShellExecute("family.txt", "", "C:\phonebook\")

EndFunc

Func _edit4()

ShellExecute("Work.txt", "", "C:\phonebook\")

EndFunc

Link to comment
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
 Share

  • Recently Browsing   0 members

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