Jump to content

Note Taker


Recommended Posts

This is a little note-taking program that I made. It has features like Autosave (so you don't have to click save) and Open Folder which opens all of the .bnote (banananote) files in a folder. I don't think that it will work correctly unless it is compiled, so I attatched the .exe.

#include <GUIConstants.au3>
#include <Array.au3>
#include <GUIEdit.au3>
#include <File.au3>
#include <FileRegister.au3>
If IniRead(@ScriptDir & "\BananaNotesData.data", "Main", "1st", 1) = 1 Then
    If MsgBox(4, "BananaNotes", "Would you like to associate the .bnote filetype with BananaNotes?") = 6 Then
        FileRegister("bnote", '"' & @ScriptFullPath & '" "%1"', "Open in BananaNotes", 1, @ScriptFullPath & ',0', "BananaNote")
    EndIf
    IniWrite(@ScriptDir & "\BananaNotesData.data", "Main", "1st", 0)
EndIf
If FileExists(@ScriptDir & "\BananaNotes Readme.txt") = 0 Then
    _FileCreate(@ScriptDir & "\BananaNotes Readme.txt")
    $file = FileOpen(@ScriptDir & "\BananaNotes Readme.txt", 1)
    FileWriteLine($file, "BananaNotes Copyright 2007 Banana Fred Software")
    FileWriteLine($file, "To use Find/Replace, press Ctrl+f")
    FileWriteLine($file, "To open all of the BananaNotes in a folder, press Ctrl+o")
    FileWriteLine($file, "Support at bananafred@gmail.com or www.bananafredsoft.com")
    FileClose($file)
EndIf
HotKeySet("^f", "FindReplace")
HotKeySet("^o", "OpenFolder")
$conts = _ArrayCreate("")
$dirs = _ArrayCreate("")
$nums = _ArrayCreate("")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("BananaNotes", 628, 384, 193, 115)
$title = "BananaNotes"
$List1 = GUICtrlCreateListView("Title                |Date         ", 8, 32, 163, 344)
$Label1 = GUICtrlCreateLabel("Title:", 138, 8, 35, 17)
$edtNotes = GUICtrlCreateEdit("", 178, 32, 447, 313)
$inpName = GUICtrlCreateInput("", 178, 8, 447, 21)
$Button2 = GUICtrlCreateButton("Delete", 266, 352, 81, 25, 0)
$Button1 = GUICtrlCreateButton("New", 178, 352, 81, 25, 0)
$Button3 = GUICtrlCreateButton("Open", 354, 352, 73, 25, 0)
$dir = GUICtrlCreateLabel("", 354 + 73 + 7, 357, 500)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$prev = ""
$latestd = IniRead(@ScriptDir & "\BananaNotesData.data", "Main", "Latest", "")
If $cmdline[0] <> 0 Then
    $writeto = $cmdline[1]
    If iniread($writeto, "Main", "Date", "") = "" Then
        IniWrite($writeto, "Main", "Date", @MON & "/" & @MDAY & "/" & @YEAR)
    EndIf
    _ArrayAdd($conts, GUICtrlCreateListViewItem(IniRead($writeto, "Main", "Name", "") & "|" & IniRead($writeto, "Main", "Date", ""), $List1))
    _ArrayAdd($dirs, $writeto)
    GUICtrlSetTip($conts[_arraysearch($dirs, $writeto)], $writeto)
    GUICtrlSetData($edtNotes, StringReplace(iniread($writeto, "Main", "Notes", ""), "\n", @CRLF))
    GUICtrlSetData($inpName, iniread($writeto, "Main", "Name", ""))
    GUICtrlSetData($dir, $writeto)
    IniWrite(@ScriptDir & "\BananaNotesData.data", "Main", "Latest", $writeto)
    If StringLen($writeto) > 40 Then
        GUICtrlSetData($dir, StringReplace($writeto, stringmid($writeto, 4, stringlen($writeto) - 40), "..."))
    EndIf
    $title = IniRead($writeto, "Main", "Name", "")
    $on1 = 1
ElseIf FileExists($latestd) Then
    $writeto = $latestd
    _ArrayAdd($conts, GUICtrlCreateListViewItem(IniRead($writeto, "Main", "Name", "") & "|" & IniRead($writeto, "Main", "Date", ""), $List1))
    _ArrayAdd($dirs, $writeto)
    GUICtrlSetTip($conts[_arraysearch($dirs, $writeto)], $writeto)
    GUICtrlSetData($edtNotes, StringReplace(iniread($writeto, "Main", "Notes", ""), "\n", @CRLF))
    GUICtrlSetData($inpName, iniread($writeto, "Main", "Name", ""))
    GUICtrlSetData($dir, $writeto)
    IniWrite(@ScriptDir & "\BananaNotesData.data", "Main", "Latest", $writeto)
    If StringLen($writeto) > 40 Then
        GUICtrlSetData($dir, StringReplace($writeto, stringmid($writeto, 4, stringlen($writeto) - 40), "..."))
    EndIf
    $title = IniRead($writeto, "Main", "Name", "")
    $on1 = 1
Else
    $writeto = ""
    $on1 = 0
EndIf
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button3
            $opend = FileOpenDialog("Open a BananaNote", "", "BananaNotes (*.bnote)")
            If FileExists($opend) Then
                $writeto = $opend
                _ArrayAdd($conts, GUICtrlCreateListViewItem(IniRead($writeto, "Main", "Name", "") & "|" & IniRead($writeto, "Main", "Date", ""), $List1))
                _ArrayAdd($dirs, $writeto)
                GUICtrlSetTip($conts[_arraysearch($dirs, $writeto)], $writeto)
                GUICtrlSetData($edtNotes, StringReplace(iniread($writeto, "Main", "Notes", ""), "\n", @CRLF))
                GUICtrlSetData($inpName, iniread($writeto, "Main", "Name", ""))
                GUICtrlSetData($dir, $writeto)
                IniWrite(@ScriptDir & "\BananaNotesData.data", "Main", "Latest", $writeto)
                $on1 = 1
            Else
                MsgBox(0, "BananaNotes Error", "The file you specified does not exist.")
            EndIf
        Case $Button1
            $writeto = FileSaveDialog("Create a BananaNote", "", "BananaNotes (*.bnote)") & ".bnote"
            IniWrite($writeto, "Main", "Date", @MON & "/" & @MDAY & "/" & @YEAR)
            _ArrayAdd($conts, GUICtrlCreateListViewItem(IniRead($writeto, "Main", "Name", "Untitled") & "|" & IniRead($writeto, "Main", "Date", ""), $List1))
            _ArrayAdd($dirs, $writeto)
            GUICtrlSetData($inpName, "Untitled")
            GUICtrlSetData($edtNotes, "")
            GUICtrlSetData($dir, $writeto)
            IniWrite(@ScriptDir & "\BananaNotesData.data", "Main", "Latest", $writeto)
            If StringLen($writeto) > 40 Then
                GUICtrlSetData($dir, StringReplace($writeto, stringmid($writeto, 4, stringlen($writeto) - 40), "..."))
            EndIf
            $on1 = 1
        Case $Button2
            If MsgBox(4, "Confirm Delete", "Are you sure that you want to delete '" & GUICtrlRead($inpName) & "'?") = 6 Then
                FileDelete($writeto)
                GUICtrlSetData($inpName, "")
                GUICtrlSetData($edtNotes, "")
                GUICtrlDelete($conts[_arraysearch($dirs, $writeto)])
                GUICtrlSetData($dir, "")
                $writeto = ""
                $on1 = 0
            EndIf
        EndSwitch
        $c = GUIGetCursorInfo($Form1)
        If BitAND(_ispressed("01"), $c[4] = $List1) then
            $writeto = $dirs[_ArraySearch($conts, GUICtrlRead($List1))]
            GUICtrlSetData($edtNotes, StringReplace(IniRead($writeto, "Main", "Notes", ""), "\n", @CRLF))
            GUICtrlSetData($inpName, IniRead($writeto, "Main", "Name", ""))
            GUICtrlSetData($dir, $writeto)
            If StringLen($writeto) > 30 Then
                GUICtrlSetData($dir, StringReplace($writeto, stringmid($writeto, 4, stringlen($writeto) - 20), "..."))
            EndIf
            $on1 = 1
        EndIf
    If BitAND(GUICtrlRead($edtNotes) & GUICtrlRead($inpName) <> $prev, $on1 = 1) then
        IniWrite($writeto, "Main", "Notes", StringReplace(guictrlread($edtNotes), @CRLF, "\n"))
        IniWrite($writeto, "Main", "Name", GUICtrlRead($inpName))
        $prev = GUICtrlRead($edtNotes) & GUICtrlRead($inpName)
        GUICtrlSetData($conts[_ArraySearch($dirs, $writeto)], guictrlread($inpName & "|" & iniread($writeto, "Main", "Date", "")))
        WinSetTitle($title, wingettext($title), IniRead($writeto, "Main", "Name", ""))
        $title = IniRead($writeto, "Main", "Name", "")
    EndIf
WEnd
Func FindReplace ()
    _GUICtrlEditFind($Form1, $edtNotes, True)
EndFunc
Func OpenFolder ()
    $folder = FileSelectFolder("Select the folder holding the files that you would like to open.", "")
    $file = FileFindFirstFile($folder & "\*.bnote")
    While 1
        $writeto = FileFindNextFile($file)
        If @error Then ExitLoop
        _ArrayAdd($conts, GUICtrlCreateListViewItem(IniRead($writeto, "Main", "Name", "") & "|" & IniRead($writeto, "Main", "Date", ""), $List1))
        _ArrayAdd($dirs, $writeto)
        GUICtrlSetTip($conts[_arraysearch($dirs, $writeto)], $writeto)
        GUICtrlSetData($edtNotes, StringReplace(iniread($writeto, "Main", "Notes", ""), "\n", @CRLF))
        GUICtrlSetData($inpName, iniread($writeto, "Main", "Name", ""))
        GUICtrlSetData($dir, $writeto)
        IniWrite(@ScriptDir & "\BananaNotesData.data", "Main", "Latest", $writeto)
        $on1 = 1
    WEnd
EndFunc

EDIT: Whoops. Just ignore the copyright. You can use the code for whatever, as long as you give credit.

EDIT: Key controls are Ctrl+o for Open Folder, and Ctrl+f for find/replace.

Edited by BananaFredSoft
Link to comment
Share on other sites

include FileRegister.au3 :whistle:

Func FileRegister($ext, $cmd, $verb, $def = 0, $icon = "", $desc = "")
    $loc = RegRead("HKCR\." & $ext, "")
    If @error Then
        RegWrite("HKCR\." & $ext, "", "REG_SZ", $ext & "file")
        $loc = $ext & "file"
    EndIf
    $curdesc = RegRead("HKCR\" & $loc, "")
    If @error Then
        If $desc <> "" Then
            RegWrite("HKCR\" & $loc, "", "REG_SZ", $desc)
        EndIf
    Else
        If $desc <> "" And $curdesc <> $desc Then
            RegWrite("HKCR\" & $loc, "", "REG_SZ", $desc)
            RegWrite("HKCR\" & $loc, "olddesc", "REG_SZ", $curdesc)
        EndIf
        If $curdesc = "" And $desc <> "" Then
            RegWrite("HKCR\" & $loc, "", "REG_SZ", $desc)
        EndIf
    EndIf
    $curverb = RegRead("HKCR\" & $loc & "\shell", "")
    If @error Then
        If $def = 1 Then
            RegWrite("HKCR\" & $loc & "\shell", "", "REG_SZ", $verb)
        EndIf
    Else
        If $def = 1 Then
            RegWrite("HKCR\" & $loc & "\shell", "", "REG_SZ", $verb)
            RegWrite("HKCR\" & $loc & "\shell", "oldverb", "REG_SZ", $curverb)
        EndIf
    EndIf
    $curcmd = RegRead("HKCR\" & $loc & "\shell\" & $verb & "\command", "")
    If Not @error Then
        RegRead("HKCR\" & $loc & "\shell\" & $verb & "\command", "oldcmd")
        If @error Then
            RegWrite("HKCR\" & $loc & "\shell\" & $verb & "\command", "oldcmd", "REG_SZ", $curcmd)
        EndIf
    EndIf
    RegWrite("HKCR\" & $loc & "\shell\" & $verb & "\command", "", "REG_SZ", $cmd)
    If $icon <> "" Then
        $curicon = RegRead("HKCR\" & $loc & "\DefaultIcon", "")
        If @error Then
            RegWrite("HKCR\" & $loc & "\DefaultIcon", "", "REG_SZ", $icon)
        Else
            RegWrite("HKCR\" & $loc & "\DefaultIcon", "", "REG_SZ", $icon)
            RegWrite("HKCR\" & $loc & "\DefaultIcon", "oldicon", "REG_SZ", $curicon)
        EndIf
    EndIf
EndFunc
Func FileUnRegister($ext, $verb)
    $loc = RegRead("HKCR\." & $ext, "")
    If Not @error Then
        $oldicon = RegRead("HKCR\" & $loc & "\shell", "oldicon")
        If Not @error Then
            RegWrite("HKCR\" & $loc & "\DefaultIcon", "", "REG_SZ", $oldicon)
        Else
            RegDelete("HKCR\" & $loc & "\DefaultIcon", "")
        EndIf
        $oldverb = RegRead("HKCR\" & $loc & "\shell", "oldverb")
        If Not @error Then
            RegWrite("HKCR\" & $loc & "\shell", "", "REG_SZ", $oldverb)
        Else
            RegDelete("HKCR\" & $loc & "\shell", "")
        EndIf
        $olddesc = RegRead("HKCR\" & $loc, "olddesc")
        If Not @error Then
            RegWrite("HKCR\" & $loc, "", "REG_SZ", $olddesc)
        Else
            RegDelete("HKCR\" & $loc, "")
        EndIf
        $oldcmd = RegRead("HKCR\" & $loc & "\shell\" & $verb & "\command", "oldcmd")
        If Not @error Then
            RegWrite("HKCR\" & $loc & "\shell\" & $verb & "\command", "", "REG_SZ", $oldcmd)
            RegDelete("HKCR\" & $loc & "\shell\" & $verb & "\command", "oldcmd")
        Else
            RegDelete("HKCR\" & $loc & "\shell\" & $verb)
        EndIf
    EndIf
EndFunc
Edited by microsoft
Link to comment
Share on other sites

Thanks for posting that.

By the way, how could I do wordwrap in the Edit control?

include FileRegister.au3 :whistle:

Func FileRegister($ext, $cmd, $verb, $def = 0, $icon = "", $desc = "")
    $loc = RegRead("HKCR\." & $ext, "")
    If @error Then
        RegWrite("HKCR\." & $ext, "", "REG_SZ", $ext & "file")
        $loc = $ext & "file"
    EndIf
    $curdesc = RegRead("HKCR\" & $loc, "")
    If @error Then
        If $desc <> "" Then
            RegWrite("HKCR\" & $loc, "", "REG_SZ", $desc)
        EndIf
    Else
        If $desc <> "" And $curdesc <> $desc Then
            RegWrite("HKCR\" & $loc, "", "REG_SZ", $desc)
            RegWrite("HKCR\" & $loc, "olddesc", "REG_SZ", $curdesc)
        EndIf
        If $curdesc = "" And $desc <> "" Then
            RegWrite("HKCR\" & $loc, "", "REG_SZ", $desc)
        EndIf
    EndIf
    $curverb = RegRead("HKCR\" & $loc & "\shell", "")
    If @error Then
        If $def = 1 Then
            RegWrite("HKCR\" & $loc & "\shell", "", "REG_SZ", $verb)
        EndIf
    Else
        If $def = 1 Then
            RegWrite("HKCR\" & $loc & "\shell", "", "REG_SZ", $verb)
            RegWrite("HKCR\" & $loc & "\shell", "oldverb", "REG_SZ", $curverb)
        EndIf
    EndIf
    $curcmd = RegRead("HKCR\" & $loc & "\shell\" & $verb & "\command", "")
    If Not @error Then
        RegRead("HKCR\" & $loc & "\shell\" & $verb & "\command", "oldcmd")
        If @error Then
            RegWrite("HKCR\" & $loc & "\shell\" & $verb & "\command", "oldcmd", "REG_SZ", $curcmd)
        EndIf
    EndIf
    RegWrite("HKCR\" & $loc & "\shell\" & $verb & "\command", "", "REG_SZ", $cmd)
    If $icon <> "" Then
        $curicon = RegRead("HKCR\" & $loc & "\DefaultIcon", "")
        If @error Then
            RegWrite("HKCR\" & $loc & "\DefaultIcon", "", "REG_SZ", $icon)
        Else
            RegWrite("HKCR\" & $loc & "\DefaultIcon", "", "REG_SZ", $icon)
            RegWrite("HKCR\" & $loc & "\DefaultIcon", "oldicon", "REG_SZ", $curicon)
        EndIf
    EndIf
EndFunc
Func FileUnRegister($ext, $verb)
    $loc = RegRead("HKCR\." & $ext, "")
    If Not @error Then
        $oldicon = RegRead("HKCR\" & $loc & "\shell", "oldicon")
        If Not @error Then
            RegWrite("HKCR\" & $loc & "\DefaultIcon", "", "REG_SZ", $oldicon)
        Else
            RegDelete("HKCR\" & $loc & "\DefaultIcon", "")
        EndIf
        $oldverb = RegRead("HKCR\" & $loc & "\shell", "oldverb")
        If Not @error Then
            RegWrite("HKCR\" & $loc & "\shell", "", "REG_SZ", $oldverb)
        Else
            RegDelete("HKCR\" & $loc & "\shell", "")
        EndIf
        $olddesc = RegRead("HKCR\" & $loc, "olddesc")
        If Not @error Then
            RegWrite("HKCR\" & $loc, "", "REG_SZ", $olddesc)
        Else
            RegDelete("HKCR\" & $loc, "")
        EndIf
        $oldcmd = RegRead("HKCR\" & $loc & "\shell\" & $verb & "\command", "oldcmd")
        If Not @error Then
            RegWrite("HKCR\" & $loc & "\shell\" & $verb & "\command", "", "REG_SZ", $oldcmd)
            RegDelete("HKCR\" & $loc & "\shell\" & $verb & "\command", "oldcmd")
        Else
            RegDelete("HKCR\" & $loc & "\shell\" & $verb)
        EndIf
    EndIf
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...