NotesTREE - Notes manage script

Post your working scripts, libraries and tools
leo007
Posts: 50
Joined: 26 Oct 2019, 04:56

NotesTREE - Notes manage script

10 Dec 2019, 13:14

Hi Everyone
I made a Note taking scripted that main propose is to easily store and manage temporary notes and categorize them.
GUI is intuitive, minimalistic have and light style.
I find it to be very useful to myself so I'm sharing it with community.
my script is inspired by Jack Dunning RecipeTree script.

Screenshot Example:
https://imgur.com/nZWQ8d6

recommendation make it autostart with windows.
when you need to take fast note in any screen just twice click F2.
when you want to close just click Esc and the content text is automatically stored.
you can always decide via GUI to keep it on top or not and there are shortcuts for each button.

Code: Select all


#SingleInstance, force       ; Skips dialog box and replaces old instance automatically.
#Persistent                  ; Keeps a script permanently running (until user closes it or ExitApp Command).
#NoEnv                       ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input               ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
DetectHiddenWindows, On      ; Hidden windows are detected.


; Author: Leo007 (inspired by Jack Dunning RecipeTree script.)


; SHORTCUTS
; ---------
; F2 x 2           → Open NotesTREE
; Esc              → Minimize
; Ctrl + S         → Save
; Ctrl Up          → Move Note Up
; Ctrl Down        → Move Note Down
; Ctrl + LButton   → Rename Section / Note
; Delete           → Delete section / Note
; Ctrl + Shift + N → Create Note
; Ctrl + N         → Create Note


; ============================================= [ GENERAL GUI SETTINGS ] =====================================================

#NoTrayIcon
Gui, -Caption
Gui, Font, s10, Segoe UI
Gui, default
Gui +AlwaysOnTop +Resize

; ================================================= [ CONTEXT MENU ] =========================================================

Menu, SectionMenu, Add, 📒 | Add Section, AddSection
Menu, SectionMenu, Add, 📄 | Add Note, AddNote
Menu, SectionMenu, Add, ❌ | Delete Note, DeleteItem

Menu, NoteMenu, Add, 📄 | Add Note, AddNote
Menu, NoteMenu, Add, ▲ | Move Up, ^Up
Menu, NoteMenu, Add, ▼ | Move Down, ^Down
Menu, NoteMenu, Add, ❌ | Delete Note, DeleteItem

; ========================================================= [ GUI ] =========================================================

Gui, Add, TreeView, w230 y43 vMyTreeView gMyTreeView h400 AltSubmit -ReadOnly
Gui, Add, Edit, ys vMyEdit gMyEdit w450 h400

Gui, Font, cBB8D76 s11, Segoe Print
Gui Color, cF3F1D2
Gui, Add, Button, xm w1 h1

; BUTTONS
Gui, Add, Button, xm w110 h35 xm y4 gNEW_SECTION , Section 📒
Gui, Add, Button, xm w120 h35 x+1 y4  gNEW_NOTE , Note 📄
Gui, Add, Button, xm w110 h35 x+1 y4 vclear  gCLEAR, CLEAR 🗑

; DRAG
Gui, Add, Text, xm w160 h35 x+1 y6 center gDRAG_MOVE, Drag Click 📌

; ALWAYS ON TOP
Gui, Font, cBB8D76 s8, Segoe Print
Gui, add, text, x+5 y12, Always On Top
Gui, Add, Radio,  x+8 y12 Checked Group v_Rad1 gALWAYS_ON_TOP, Yes
Gui, Add, Radio, x+8 y12 v_Rad2 gALWAYS_ON_TOP, No
Gui, Font,

 Loop, Read, NotesTREE.csv
{
    Loop, Parse, A_LoopReadLine , CSV
      {
        RowData%A_Index% := A_LoopField
      }
        StringReplace, RowData4, RowData4,|,`n, All

      If RowData2 = 0
      {
        SectionID := TV_Add(RowData3,0,"Sort")
        %RowData1% := SectionID
        %SectionID% := RowData1
        RowText := SectionID . "text"
        %RowText% := RowData4
      }
      Else
      {
        Note := RowData1 . RowData2
        SubSectionID := TV_Add(RowData3, %Rowdata1%)
        %SubSectionID% := Note
        RowText := SubSectionID . "text"
        %RowText% := RowData4
      }
}

$F2:: ; Shortcut [ F2 x 2 ]
  If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500)
    Gui, Show,, NotesTREE  ; Show the window and its TreeView.
    Return

; ========================================================= [ VIEW ] =========================================================

MyEdit:
 Gui, Submit, NoHide
 Text := TV_GetSelection() . "text"
 %Text% := MyEdit
Return

MyTreeView:
 TV_GetText(TreeText, TV_GetSelection())
 Unit := TV_GetSelection()
 Text := TV_GetSelection() . "text"
 GuiControl, , MyEdit, % %Text%
Return

GuiContextMenu:  ; Launched in response to a right-click or press of the Apps key.
If A_GuiControl <> MyTreeView  ; Display the menu only for clicks inside the ListView.
    return

; Show the menu at the provided coordinates, A_GuiX and A_GuiY.  These should be used
; because they provide correct coordinates even if the user pressed the Apps key
ItemId := A_EventInfo
TV_Modify(ItemID, "Select")

If TV_GetParent(A_EventInfo) = 0 {
  Menu, SectionMenu, Show , %A_GuiX%, %A_GuiY%
}
Else {
 Menu, NoteMenu, Show , %A_GuiX%, %A_GuiY%
}
return


GuiSize:  ; Expand or shrink the TreeView in response to the user's resizing of the window.
if A_EventInfo = 1  ; The window has been minimized.  No action needed.
    return
; Otherwise, the window has been resized or maximized. Resize the ListView to match.
GuiControl, Move, MyTreeView, % " H" . (A_GuiHeight - 55) ;"W" . (A_GuiWidth - 20) .
GuiControl, Move, MyEdit, % "W" . (A_GuiWidth - 270) . " H" . (A_GuiHeight - 55)
GuiControl, Move, Button1, % "y" . (A_GuiHeight - 45)
Return


; ======================================================= [ FUNCTIONS ] =========================================================

AddSection() {
  SectionID := TV_Add("Section",0,"Sort")
  %SectionID%text := ""
  ; TV_Modify(SectionID, "Select Bold")
  TV_Modify(SectionID, "Select")
  Return
}


AddNote(i) {
  If TV_GetParent(i) = 0
      NewAdd :=TV_Add("...", i)
  Else
      NewAdd :=TV_Add("...", TV_GetParent(i), i)

    %NewAdd%text := ""
    TV_Modify(NewAdd, "Select")
  Return
}


ToolTipMassage(){
  ToolTip, Saved, 625, 60
  Sleep, 400
  ToolTip,
  Return
}


UpdateFile() {
  FileMove, NotesTREE.csv, NotesTREE.bak, 1
  R = 1
  ItemID = 0  ; Causes the loop's first iteration to start the search at the top of the tree.
  Loop
    {
      ItemID := TV_GetNext(ItemID, "Full")
      if not ItemID  ; No more items in tree.
          break
      TV_GetText(ItemText, ItemID)
      If TV_GetParent(ItemID) = 0
        {
        ParentCode := "R" . R
        ChildCode := 0
        R += 1
        C = 1
        }
      Else
        {
        ChildCode := "C" . C
        C += 1
        }
      TextValue := %ItemID%text
            StringReplace, TextValue, TextValue,", "", All
            StringReplace, TextValue, TextValue,`n,|, All
      FileAppend, "%ParentCode%"`,"%ChildCode%"`,"%ItemText%"`,"%TextValue%" `n, NotesTREE.csv
    }
}


; ================================================ [ CONTEXT MENU ACTION ] ===================================================

AddSection:
  AddSection()
  Return


AddNote:
  AddNote(ItemID)
  Return


DeleteItem:
  TV_Delete(ItemID)
  Return


#IfWinActive, NotesTREE


^Up:: ; UP
  {
    ThisOne := TV_GetSelection()
    If TV_GetPrev(ThisOne) != 0 && TV_GetParent(ThisOne) != 0
      {
        TV_GetText(MoveName,ThisOne)
        EditText := % %Thisone%text
        If TV_GetPrev(TV_GetPrev(ThisOne)) != 0
        {
          NewAdd :=TV_Add(MoveName, TV_GetParent(ThisOne), TV_GetPrev(TV_GetPrev(ThisOne)))
        }
        Else
        {
          NewAdd :=TV_Add(MoveName, TV_GetParent(ThisOne), "First")
        }
        %NewAdd%text := EditText
        TV_Delete(ThisOne)
        TV_Modify(NewAdd, "Select")
      }
    Return
  }


  ^Down:: ; DOWN
  {
    ThisOne := TV_GetSelection()
    If TV_GetNext(ThisOne) != 0  && TV_GetParent(ThisOne) != 0
      {
        TV_GetText(MoveName,ThisOne)
        EditText := % %Thisone%text
        NewAdd := TV_Add(MoveName, TV_GetParent(ThisOne), TV_GetNext(ThisOne))
        %NewAdd%text := EditText
        TV_Delete(ThisOne)
        TV_Modify(NewAdd, "Select")
      }
    Return
  }

; ==================================================== [ BUTTONS ACTION ] ===================================================

NEW_SECTION:
  AddSection()
  Return


NEW_NOTE:
  ThisOne := TV_GetSelection()
  AddNote(ThisOne)
  Return


DRAG_MOVE:
  PostMessage, 0xA1, 2,,, A
  Return


CLEAR:
  SendInput, {Tab 3}
  Sleep, 50
  SendInput, ^a{BackSpace}
  Return


ALWAYS_ON_TOP:
	Gui, Submit, NoHide
	If(_Rad1==1)
    Gui, +AlwaysOnTop
	else If (_Rad2==1)
    Gui, -AlwaysOnTop
	Return


; =================================================== [ SHORTCUTS ACTIONS] ======================================================

Delete:: ; DELETE
  ThisOne := TV_GetSelection()
  TV_Delete(ThisOne)
  Return


^+n:: ; CREATE SECTION
  AddSection()
  Return


^n:: ; CREATE NOTE
  ThisOne := TV_GetSelection()
  AddNote(ThisOne)
  Return


^LButton:: ; FAST RENAME
  Send, {F2}
  Return


^s:: ; FAST RENAME
  UpdateFile()
  ToolTipMassage()
  Return


Esc:: ; MINIMIZE
  UpdateFile()
  ToolTipMassage()
  Gui, hide
  Return
  


Any suggestion on script modification and optimisation are very welcomed)
Last edited by leo007 on 11 Dec 2019, 11:31, edited 6 times in total.
User avatar
TheDewd
Posts: 1446
Joined: 19 Dec 2013, 11:16
Location: USA

Re: NotesTREE - fast temporary Notes manage script

10 Dec 2019, 13:42

FYI -- The unicode emoji characters display differently on different versions of Windows.

https://i.imgur.com/ReCRupD.png

Edition: Windows 10 Enterprise (64-bit)
Version: 1803
OS build: 17134.1069
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
leo007
Posts: 50
Joined: 26 Oct 2019, 04:56

Re: NotesTREE - fast temporary Notes manage script

10 Dec 2019, 14:11

as I see the first 2 of them aren't displayed correctly.
I checked the unicode number of my emoji icons:
first is (U+1F4D2)
Second is (U+1F4C4)
I think you might fit them relatively in this case.
hope it helped

by the way I modified names and there relative variables to more efficient.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: TheProdigyC2 and 27 guests