Jump to content


Photo

FoneBook v1.0 : Personal PhoneBook Manager !


  • Please log in to reply
1 reply to this topic

#1 Aravind

Aravind
  • Members
  • 66 posts

Posted 18 December 2009 - 03:45 AM

Hi There!

Ok, here goes. I don't think there is a phone book manager developed in AHK & i thought of building one. This is basically a phonebook(FoneBook :) ) completely designed in AHK with a database file encryption!!. The encryption i used is TEA. More info on TEA can be found on the forums.


Download These Files. Your're Going To Need These !
Download Included Images

Download The Compiled Working Program

Note : You Might Need To Change The FileInstall Paths For The Script To Work

Here is the code for the Main program :

#singleinstance,ignore 
;Coded/Developed By Aravind.V.S
#notrayicon 
#errorstdout
FileCreateDir,%A_Temp%\DELTATemp\
FileInstall,N:\XA\edit.jpg,%A_Temp%\DELTATemp\edit.jpg,1
FileInstall,N:\XA\save.png,%A_Temp%\DELTATemp\save.png,1
FileInstall,N:\XA\export.png,%A_Temp%\DELTATemp\export.png,1
FileInstall,N:\XA\settings.png,%A_Temp%\DELTATemp\settings.png,1
FileInstall,N:\XA\user.png,%A_Temp%\DELTATemp\user.png,1
FileInstall,N:\XA\add.png,%A_Temp%\DELTATemp\add.png,1
FileInstall,N:\XA\abt.jpg,%A_Temp%\DELTATemp\abt.jpg,1
FileInstall,N:\XA\logo.jpg,%A_Temp%\DELTATemp\logo.jpg,1
FileInstall,N:\XA\contacts.jpg,%A_Temp%\DELTATemp\contacts.jpg,1
FileInstall,N:\XA\info.jpg,%A_Temp%\DELTATemp\info.jpg,1
REGWRITE,REG_DWORD,HKEY_CLASSES_ROOT,fbf_auto_file,EditFlags,00000000
REGWRITE,REG_DWORD,HKEY_CLASSES_ROOT,fbf_auto_file,BrowserFlags,00000008
REGWRITE,REG_SZ,HKEY_CLASSES_ROOT,fbf_auto_file,NeverShowExt,1
REGWRITE,REG_SZ,HKEY_CLASSES_ROOT,fbf_auto_file\DefaultIcon,,%A_ScriptFullPath%,1
REGWRITE,REG_SZ,HKEY_CLASSES_ROOT,ft000001,,FoneBook Database File
REGWRITE,REG_SZ,HKEY_CLASSES_ROOT,ft000001\DefaultIcon,,%A_ScriptFullPath%,1
q:=","
Gui,+toolwindow +Border +alwaysontop
Gui,color,FFFFFF
Gui, +LastFoundExist
WindowID := WinExist()
GUI,Add,Picture,w442 h70,%A_Temp%\DELTATemp\contacts.jpg
Gui, Add, ListView,gMyListView sort grid x0 y85 r20 w499 h300 gMyListView , Name|Primary Number|Work Number|Home Number
Gui,Add,Picture,gsave x37 y400 w64 h64,%A_Temp%\DELTATemp\save.png
Gui,Add,Text,cBlue x30 y465,Save Phone Book
Gui,Add,Picture,gbackup x158 y402 w64 h64,%A_Temp%\DELTATemp\export.png
Gui,Add,Text,cBlue x140 y465,Backup Phonebook
Gui,Add,Picture,gsettings x270 y402 w64 h64,%A_Temp%\DELTATemp\settings.png
Gui,Add,Text,cBlue x258 y465,Phonebook Settings
Gui,Add,Picture,gadd x382 y402 w64 h64,%A_Temp%\DELTATemp\add.png
Gui,Add,Text,cBlue x372 y465,Add New Contact
Splashimage,%A_Temp%\DELTATemp\logo.jpg,b
RunWait,pfengine.exe DECODE dbfile01.fbf dbfile.fbf,%A_ScriptDir%,UseErrorLevel
If ErrorLevel = ERROR
goto,error
else
FileDelete,dbfile01.fbf
Sleep,1555
FileRead,dbfile,dbfile.fbf
Loop,Read,dbfile.fbf
{
Colors =%A_LoopReadLine%
StringSplit, ColorArray, Colors, `,

 LV_Add("",colorarray1, colorarray2,colorarray3,colorarray4)
}

LV_ModifyCol()
LV_ModifyCol(5, "Integer")
soundplay,%A_Windir%\media\notify.wav
Gui, Show,Hide x185 y35 h480 w500,Contacts
splashimage off
Splashimage,%A_Temp%\DELTATemp\abt.jpg,b x10 y550
goto,MyListView
return

MyListView:
if A_GuiEvent = DoubleClick
Gui,2:Destroy
{
    LV_GetText(Rowtext, A_EventInfo)
    LV_GetText(ColText1,A_EventInfo,2)
    LV_GetText(ColText2,A_EventInfo,3)
    LV_GetText(ColText3,A_EventInfo,4)
Gui,2:+Owner +alwaysontop
GUI,2:+Toolwindow
Gui,2:Color,FFFFFF
Gui,2:Font,s12,Calibri
Gui, 2:Add, Picture, x1 y0 w315 h101 ,%A_Temp%\DELTATemp\info.jpg
Gui, 2:Add, Text,cBlack,Name :  %RowText% `nPrimary Number : %coltext1% `nWork Number  : %coltext2% `nHome Number : %coltext3%
Gui, 2:Add, Picture,gedit x240 y120 w64 h64,%A_Temp%\DELTATemp\user.png
Gui, 2:Show, x695 y506 h200 w315,Contact Details
Gui, 2:Font
Gui, 2:add, Text, cBlue x240 y186,Edit Contact
DllCall("AnimateWindow","UInt",WindowID ,"Int", 500,"UInt", 0x80000)
Return
}
return

GuiClose:
FileDelete,dbfile01.fbf
FileRemoveDir,%A_Temp%\DELTATemp,1
Runwait,pfengine.exe Encode dbfile.fbf dbfile01.fbf,%A_ScriptDir%,UseErrorLevel
If ErrorLevel = ERROR
goto,error
else
FileDelete,dbfile.fbf
DllCall("AnimateWindow","UInt",  WindowID  ,"Int", 500,"UInt", 0x90000)
ExitApp

Edit:
Gui,3:Destroy
Gui,3:Color,FFFFFF
Gui,3:+toolwindow +alwaysontop
Gui,3:Add, Picture, x1 y0 w400 h113 ,%A_Temp%\DELTATemp\edit.jpg
Gui,3:Add, Text, x6 y130 w40 h20 , Name :
Gui,3:Add, Edit, vname x46 y127 w240 h20 , %rowtext%
Gui,3:Add, Text, x6 y157 w90 h20 , Primary Number:
Gui,3:Add, Edit, vpnum x86 y155 w200 h20 , %coltext1%
Gui,3:Add, Text, x6 y189 w70 h20 , Work Number:
Gui,3:Add, Edit, vwnum x86 y187 w200 h20 , %coltext2%
Gui,3:Add, Text, x6 y219 w80 h20 , Home Number:
Gui,3:Add, Edit, vhnum x86 y217 w200 h20 , %coltext3%
Gui,3:Add, Button,gsave x296 y189 w100 h30 , Save Changes
Gui,3:Add, Button,gcancel x296 y220 w100 h30 , Cancel
soundplay,%A_Windir%\media\notify.wav
Gui,3:Show,x305 y150 h273 w404,Edit Contact
return

save:
gui,submit
StringReplace,o,dbfile,%rowtext%%q%%coltext1%%q%%coltext2%%q%%coltext3%,%name%%q%%pnum%%q%%wnum%%q%%hnum%
FileDelete,dbfile.fbf
fileappend,
(
%o%
),dbfile.fbf
Reload
return

Backup:
gui,1:-alwaysontop
FileSelectFile,fileroot,16 1,%A_Mydocuments%,Export File To,FoneBook Backup File(*.fbf)
If fileroot =
{
 gui,+alwaysontop
return
}
else
FileDelete,bck.fbf
fileappend,
(
%dbfile%
),bck.fbf
RunWait,pfengine.exe encode bck.fbf bck.001,%A_ScriptDir%
FileMove,%A_ScriptDir%\bck.001,%fileroot%.fbf,1
FileDelete,bck.fbf
gui,1:+alwaysontop
return

Cancel:
gui,destroy
return

Settings:
Gui,-alwaysontop
Msgbox,0,FoneBook 1.0,Sorry! This Area Is Under Construction!
Gui,+alwaysontop
return

Add:
Gui,4:Destroy
Gui,4:Color,FFFFFF
Gui,4:+toolwindow +alwaysontop
Gui,4:Add, Picture, x1 y0 w400 h113 ,%A_Temp%\DELTATemp\edit.jpg
Gui,4:Add, Text, x6 y130 w40 h20 , Name :
Gui,4:Add, Edit, va x46 y127 w240 h20
Gui,4:Add, Text, x6 y157 w90 h20 , Primary Number:
Gui,4:Add, Edit, vb x86 y155 w200 h20
Gui,4:Add, Text, x6 y189 w70 h20 , Work Number:
Gui,4:Add, Edit, vc x86 y187 w200 h20
Gui,4:Add, Text, x6 y219 w80 h20 , Home Number:
Gui,4:Add, Edit, vd x86 y217 w200 h20
Gui,4:Add, Button,gsave2 x296 y189 w100 h30 , Save Changes
Gui,4:Add, Button,gcancel x296 y220 w100 h30 , Cancel
soundplay,%A_Windir%\media\notify.wav
Gui,4:Show, x305 y150 h273 w404,Add New Contact
return

save2:
gui,submit
FileAppend,
(
%a%%q%%b%%q%%c%%q%%d%%q%`n
),dbfile.fbf
reload
return

Error:
msgbox,262160,Error!,Cannot Find The Decoding Engine Component! Reinstalling May Fix This Problem `n`n`t`t     <--Technical Details--> `nComponent Description : TEA Encryption/Decryption Engine `n`nComponent Name : pfengine.exe `n`nError Code : fnf02 `n`nSolution : Reinstall The Program or Copy `"pfengine.exe`" Into Program Directory
exitapp

Here Is the code for pfengine.exe

;TEA Text Encryption System
;CommandLine Encoder/Decoder
#notrayicon
#singleInstance,OFF
#ErrorStdout
SetBatchLines -1
StringCaseSense Off
AutoTrim Off

k1 := 0x11111111               
k2 := 0x22222222
k3 := 0x33333333                 
k4 := 0x44444444
k5 := 0x12345678                


If 1 = Encode
   GoSub Encrypt
Else IF 1 = Decode
   GoSub Decrypt
else
goto,info
ExitApp


ENCRYPT:
   i = 9                         ; pad-index, force restart
   p = 0                         ; counter to be encrypted
   Loop Read,%2%,%3%
   {
      L =                        ; processed line
      Loop % StrLen(A_LoopReadLine)
      {
         i++
         IfGreater i,8, {        ; all 9 pad values exhausted
            u := p
            v := k5              ; another secret
            p++                  ; increment counter
            TEA(u,v, k1,k2,k3,k4)
            Stream9(u,v)         ; 9 pads from encrypted counter
            i = 0
         }
         StringMid c, A_LoopReadLine, A_Index, 1
         a := Asc(c)
         if a between 32 and 126
         {                       ; chars > 126 or < 31 unchanged
            a += s%i%
            IfGreater a, 126, SetEnv, a, % a-95
            c := Chr(a)
         }
         L = %L%%c%              ; attach encrypted character
      }
      FileAppend %L%`n
   }
Return

DECRYPT:
   i = 9                         ; pad-index, force restart
   p = 0                         ; counter to be encrypted
   Loop Read,%2%,%3%
   {
      L =                        ; processed line
      Loop % StrLen(A_LoopReadLine)
      {
         i++
         IfGreater i,8, {        ; all 9 pad values exhausted
            u := p
            v := k5              ; another secret
            p++                  ; increment counter
            TEA(u,v, k1,k2,k3,k4)
            Stream9(u,v)         ; 9 pads from encrypted counter
            i = 0
         }
         StringMid c, A_LoopReadLine, A_Index, 1
         a := Asc(c)
         if a between 32 and 126
         {                       ; chars > 126 or < 31 unchanged
            a -= s%i%
            IfLess a, 32, SetEnv, a, % a+95
            c := Chr(a)
         }
         L = %L%%c%              ; attach encrypted character
      }
      FileAppend %L%`n
   }
Return


TEA(ByRef y,ByRef z,k0,k1,k2,k3) ; (y,z) = 64-bit I/0 block
{                                ; (k0,k1,k2,k3) = 128-bit key
   IntFormat = %A_FormatInteger%
   SetFormat Integer, D          ; needed for decimal indices
   s := 0
   d := 0x9E3779B9
   Loop 32
   {
      k := "k" . s & 3           ; indexing the key
      y := 0xFFFFFFFF & (y + ((z << 4 ^ z >> 5) + z  ^  s + %k%))
      s := 0xFFFFFFFF & (s + d)  ; simulate 32 bit operations
      k := "k" . s >> 11 & 3
      z := 0xFFFFFFFF & (z + ((y << 4 ^ y >> 5) + y  ^  s + %k%))
   }
   SetFormat Integer, %IntFormat%
   y += 0
   z += 0                        ; Convert to original ineger format
}

Stream9(x,y)                     ; Convert 2 32-bit words to 9 pad values
{                                ; 0 <= s0, s1, ... s8 <= 94
   Local z                       ; makes all s%i% global
   s0 := Floor(x*0.000000022118911147) ; 95/2**32
   Loop 8
   {
      z := (y << 25) + (x >> 7) & 0xFFFFFFFF
      y := (x << 25) + (y >> 7) & 0xFFFFFFFF
      x  = %z%
      s%A_Index% := Floor(x*0.000000022118911147)
   }
}

Info:
Msgbox,262160,Error!,Direct Execution Not Supported!
exitapp

There is no copyright & stuff like that ok?? You can modify it as you like! i thought to give A professional look & feel :wink:

The database system used in the program may be the worst system you may have come across. Yes! i know.

A New FoneBook With A Number Of Modifications & A Database Using INI File Is Coming Soon! I'm Working On It Currently

Does Anyone Have Any Idea On A Better UI??
Comments Are Welcome!

#2 fedtegreve

fedtegreve
  • Members
  • 79 posts

Posted 12 January 2012 - 01:37 PM

Hi Aravind.

I think I can use some of your script to redesign my own script:
http://www.autohotke...d edit funktion

Its a password script to record password for Browsers, PuTTYs and others.
It is a very poor listing view, if I want to change on old password, and would like it to be something like your phonebook.

I tried your phonebook, but could see how to change an existing value.
Do you know how to change values in a listview?
If one has got a new number.

Thanks
Ben