Jump to content

Diary


Kreatorul
 Share

Recommended Posts

I don't know if this has been done before but I didn't worked on anything lately so today I did this Diary. It's secure so you are the only one who can read the diary. I hope you like it cause it gave me a headache. :whistle:

#include <GUIConstants.au3>
#include <String.au3>
#include <File.au3>

If RegReaD("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password") = "" Then
    If @error = 2 Then
    MsgBox(0, "Wrong Password", "You entered a wrong password")
        Exit
        EndIf
    Else
        $pass=Inputbox("Password", "Enter the password for your diary", "", "*")
            If _StringEncrypt(0, RegReaD("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password"), "bla") = $pass Then 
        Sleep(10)
    Else
        MsgBox(0,"Wrong pass", "You entered a wrong password")
        Exit
    EndIf
EndIf

If RegReaD("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password") = "" Then 
    $pass1=InputBox("New User", "Enter a password to protect your diary", "", "*")
    $pass2=InputBox("Confirm", "Type the password again to confirm", "", "*")
    If $pass1=$pass2 Then 
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password", "REG_SZ",  _StringEncrypt(1, $pass2, "bla"))
        Else
        MsgBox(0, "Wrong Password", "The password to confirm is different from the initial password")
        Exit
        EndIf
    EndIf
    
#Region ### START Koda GUI section ### Form=D:\Documents and Settings\Kreatorul\My Documents\AForm1.kxf
$Form1 = GUICreate("Dear Diary", 640, 610, -1, -1)

$menu=GuiCtrlCreateMenu("Diary")
$mopen=GuiCtrlCreateMenuItem("Open", $menu)
$msave=GuiCtrlCreateMenuItem("Save", $menu)
$separator1 = GUICtrlCreateMenuitem ("",$menu,2)
$mexit=GuiCtrlCreateMenuItem("Exit", $menu)
$menu1=GuiCtrlCreateMenu("Help")
$help=GuiCtrlCreateMenuItem("Help", $menu1)
$about=GuiCtrlCreateMenuItem("About", $menu1)

$Tab1 = GUICtrlCreateTab(0, 0, 645, 609)
$TabSheet1 = GUICtrlCreateTabItem("Diary")
$Label1 = GUICtrlCreateLabel("Dear Diary", 253, 30, 123, 37)
GUICtrlSetFont(-1, 20, 800, 6, "Monotype Corsiva")
GUICtrlSetColor(-1, 0xFF0000)
GuiCtrlCreateLabel("Tip: Writing a new diary with a date that has already been used replaces your old diary, so if you want to update open the diary" & @crlf & "previously saved, update it and then save it.", 16, 555)
$Open = GUICtrlCreateInput("", 16, 109, 136, 21)
$Label2 = GUICtrlCreateLabel("Open a previously saved diary", 16, 77, 185, 24)
GUICtrlSetFont(-1, 13, 400, 6, "Monotype Corsiva")
GUICtrlSetColor(-1, 0xFF0000)
$Label3 = GUICtrlCreateLabel("Enter the date in the D-M-Y format.", 160, 113, 168, 17)
$Label4 = GUICtrlCreateLabel("New Diary", 16, 173, 73, 24)
GUICtrlSetFont(-1, 13, 400, 6, "Monotype Corsiva")
GUICtrlSetColor(-1, 0xFF0000)
$Date = GUICtrlCreateInput("", 16, 203, 136, 21)
$Label5 = GUICtrlCreateLabel("Enter the date in the D-M-Y format.", 161, 207, 168, 17)
$Opend = GUICtrlCreateButton("Open", 16, 135, 46, 21, 0, $WS_EX_STATICEDGE)
$Diary = GUICtrlCreateEdit("", 16, 255, 606, 286)
GUICtrlSetData(-1, "Start writing your diary here!")
GUICtrlSetFont(-1, 12, 400, 2, "Monotype Corsiva")
$save = GUICtrlCreateButton("Save", 16, 230, 46, 21, 0, $WS_EX_STATICEDGE)
$TabSheet2 = GUICtrlCreateTabItem("Calendar")
$MonthCal1 = GUICtrlCreateMonthCal("2007/02/25", 10, 30, 616, 545)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(20)
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $save
            FileDelete(@ScriptDir & "\journals\" & GuiCtrlRead($date) & ".dia")
            $encr=_StringEncrypt(1, GuiCtrlRead($diary), _StringEncrypt(0, RegReaD("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password"), "bla"))
            $file=FileOpen(@ScriptDir & "\journals\" & GuiCtrlRead($date) & ".dia", 9)
            FileWrite($file, $encr)
            FileClose($file)
        Case $Opend
            GuiCtrlSetData($diary, _StringEncrypt(0, FileRead(@ScriptDir & "\journals\" & GuiCtrlRead($open) & ".dia"), _StringEncrypt(0, RegReaD("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password"), "bla")))
        Case $mopen
            GuiCtrlSetData($diary, _StringEncrypt(0, FileRead(@ScriptDir & "\journals\" & GuiCtrlRead($open) & ".dia"), _StringEncrypt(0, RegReaD("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password"), "bla")))
        Case $msave
            FileDelete(@ScriptDir & "\journals\" & GuiCtrlRead($date) & ".dia")
            $encr=_StringEncrypt(1, GuiCtrlRead($diary), _StringEncrypt(0, RegReaD("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password"), "bla"))
            $file=FileOpen(@ScriptDir & "\journals\" & GuiCtrlRead($date) & ".dia", 9)
            FileWrite($file, $encr)
            FileClose($file)
        Case $mexit
            Exit
        Case $help
            MsgBox(0, "Help", "If you want to write a new diary simply enter the date in the specific field, write the diary and save it." & @crlf & "Tip: Writing a new diary with a date that has already been used replaces your old diary, so if you want to update open the diary" & @crlf & "previously saved, update it and then save it.")
        Case $about
            MsgBox(0, "About", "Coding by Kreatorul in AutoIt. For any comments or sugestions contact me at bal_dabac@yahoo.com")
    EndSwitch
WEnd
Edited by Kreatorul
Link to comment
Share on other sites

I was going to do this. But it was aimed at girls. This works though :whistle:

Edit: I suggest replacing

$Form1 = GUICreate("Dear Diary", 640, 610, 202, 178)
oÝ÷ Ùh­«­¢+Ø(ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½ÐíÈ¥ÉäÅÕ½Ðì°ØÐÀ°ØÄÀ°´Ä°´Ä¤(

And it will automatically center your program on the desktop.

Edited by Secure_ICT
Link to comment
Share on other sites

$pass=Inputbox("Password", "Enter the password for your diary", "", "*")
            If _StringEncrypt(0, RegReaD("HKEY_LOCAL_MACHINE\SOFTWARE\DearDiary", "password"), "bla") = $pass Then
        Sleep(10)

i noticed you used "bla" as your encrypt key, perhaps you could use a MD5 hash on the password and use that as the encrypt key, instead of "bla" :whistle:

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

This is nice, I especially like the 12 month calendar.

Some suggestions follow:

  • The tip at the bottom of the screen (BOS) is too terse, non-computer people would be confused. I had to read it twice. Check the punctuation. (Same for the Help box)
  • Why not use the "FileOpenDialog ( )" function to select the file to open instead of requiring the user to type it in from memory?
    • Alternatively you could read the "journals" folder and populate a ComboBox for the user to select from.
    • If you used the "yyyy-mm-dd" format, the files would almost always be in date order for the user.
    • You could also use a key logger to allow the user to type in a date and with each character they type, re-populate a list of days until the one of interest appears. If you added a field for "Key Words" you could use this same method to search the Key Word fields to re-populate a list of the records with those words. DO NOT ASK for help with a key logger, if you develop one DO NOT POST IT, you will be in deep doodoo. I'm probably going to get some flack for mentioning one here, even though this would be a legitimate use of one.
  • You could use the calendar UDF to save the file by the date the user selects from a popup calendar of the current month, this would insure that the format is always the same. This would also let you remove the date format instructions.
    • You should remove one of "date format instructions" and relocate the other in any case.
  • You might want to add a config dialog and allow the user to select colors and fonts they like.
    • An option to change passwords would be appropriate too.
  • Given your tip at the BOS, you might want to popup a warning message box if the user attempts to overwrite an existing file.
  • I didn't check to see if you can set a style for wordwrap, but you should.
  • Instead of having a file for each day, you could put them all in one file, encrypt the date and use the date as the KEY field. This would add to the security.
    • Alternatively you could encrypt the date and use that for the file name if you don't want to use a single file.
    • Using either 7.0 or 7.1 above, you could use the" FileSetTime ( )" function to obscure the dates of all data files so Mr. or Mrs Nosey would have nearly nothing to go on.
All the suggestions not withstanding, I do like your Diary.

Gene

PS. Obviously the foregoing is a stream of conciousness kind of thing.

{edit 2/27/07} As regards dates, if you make the program handle the dates, you can extend them to the time as well. hh:mm:ss would virtually guarantee no date-time collisions, and all entries would be chronological. That would make it difficult for most users to purposly mis-date an entry. You could disallow any post dated entries to stymie anyone who would set the computer clock ahead to make an entry and then set it back to the correct time and date. If there is an open Internet connection, you could include a freebie Inet time-n-date setter and compare the Inet Time and date to the computer time and date.

Edited by Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

  • 4 weeks later...

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...