AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Note Taker

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
viciouskinid



Joined: 23 Jun 2007
Posts: 136

PostPosted: Sun Mar 02, 2008 10:38 am    Post subject: Note Taker Reply with quote

Just a simple notepad. I like it. please post any suggestions.

Code:



#Persistent
#SingleInstance

 #Include %A_ScriptDir%\LocateTB.ahk


FileRead, SavedNotes,%A_ScriptDir%\Notes_Files\Notes.txt
;Process Priority,,Realtime



GUI_H=120
GUI_W=335



WinGetPos , XTB, YTB, WidthTB, HeightTB,  ahk_class Shell_TrayWnd, , , 
com=,



GUI_X:=0
GUI_Y:=0



GUI_H1:=GUI_H+24
GUI_W1:=GUI_W+6

GUI_X:=LocateTB(GUI_H1,GUI_W1,"X")

GUI_Y:=LocateTB(GUI_H1,GUI_W1,"Y")

menu, tray,  NoStandard
menu, tray, Click, 1
menu, tray, add, Show/Hide, Show_Hide
menu, tray, Default ,Show/Hide

; Create submenu
Menu, NoteSubmenu, Add, , ;learn how to delete submenus
menu, tray, add, Notes, :NoteSubmenu
menu, tray,Disable, Notes




menu, tray, add, Exit




Gui, +ToolWindow AlwaysOnTop
Gui, Add, Text, x5 y5 w30 h20, Title:

Gui, Add, Button,Default vS x-0 w40 h20, Save

Gui, Add, Button, vC x-0 w40 h20, Clear

Gui, Add, Button, vD x-0 y82 w40 h20, Delete ;delete y
GuiControl, Hide, D
 
Gui, Add, Button, vBullet x-0 y110 w40 h10,•

Gui, Add, Edit, vTITLE x40 y5 w290 R1 ,Enter Title For Note
Gui, Add, Edit, vNOTE x40 y30 w290 R6 ,Enter Note
gui, font, s6,

gosub,LoadNotes
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

~^s::

IfWinActive, Note Taker
{
gosub,ButtonSave
}
Return


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 

Button•:
GuiControl, Focus, NOTE
send,• %A_Space% 
Return



LoadNotes:

NoteNum1:=ExtractInfo("Max",0)
if NoteNum1>=1
{
menu, tray,Enable, Notes
}

loop,%NoteNum1%
{
NoteTitle:=ExtractInfo("Title",A_Index)
SubTITLE=%A_Index%-%NoteTitle%
Menu, NoteSubmenu, Add, %SubTITLE%, NoteHandler
}
Return





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ButtonClear:
GuiControl,, TITLE,
GuiControl,, NOTE,


if EditingNoteNo
{
GuiControl, Hide, D
EditingNoteNo=
}
Return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



ButtonSave:

gui,submit,nohide ;update variable with input text
NoteNum1:=ExtractInfo("Max",0)
NoteNum2:=NoteNum1+1

if TITLE=
{
StringLeft, TITLE, NOTE, 10
   if NOTE=
   {
   msgbox, Please enter a note.
   Return
   }
}

if EditingNoteNo ;save over existing
{
;replace existing title
StringReplace, SavedNotes, SavedNotes,  %SubTITLE%`r`n%NoteText1%, %EditingNoteNo%~%TITLE%`r`n%NOTE%

;save savednotes to file
FileDelete,  %A_ScriptDir%\Notes_Files\Notes.txt
FileAppend , %SavedNotes%,  %A_ScriptDir%\Notes_Files\Notes.txt ;save new notes



temptitle=%EditingNoteNo%-%TITLE%
if A_ThisMenuItem!=%temptitle%
{
Menu, NoteSubmenu, Rename, %A_ThisMenuItem%, %EditingNoteNo%-%TITLE%
}
gosub,ButtonClear



; GuiControl, Hide, D
; EditingNoteNo=
} else { ;save new

   if NoteNum1=
   {
   NoteNum2:=1
   menu, tray,Enable, Notes
   FileAppend , %NoteNum2%~%TITLE%`r`n%NOTE%, %A_ScriptDir%\Notes_Files\Notes.txt

   }else{
   NoteNum2:=NoteNum1+1
   FileAppend , `r`n%NoteNum2%~%TITLE%`r`n%NOTE%, %A_ScriptDir%\Notes_Files\Notes.txt
   }

FileRead, SavedNotes,%A_ScriptDir%\Notes_Files\Notes.txt
SubTITLE=%NoteNum2%-%TITLE%
Menu, NoteSubmenu, Add, %SubTITLE%, NoteHandler
msgbox, Note Entitled: "%TITLE%" has been saved.
}
gosub,ButtonClear
Gui, cancel
Return


ButtonDelete:

;---------------------------------------------------------------------


;remove deleted note from saved notes.
StringReplace, SavedNotes, SavedNotes,  %SubTITLE%`r`n%NoteText%`r`n,
StringReplace, SavedNotes, SavedNotes,  `r`n%SubTITLE%`r`n%NoteText%,

;fix numbering----------------------------------------------------
SavedNotes:=ExtractInfo("FixNum",0)

;save savednotes to file
FileDelete,  %A_ScriptDir%\Notes_Files\Notes.txt
FileAppend , %SavedNotes%,  %A_ScriptDir%\Notes_Files\Notes.txt ;save new notes


Menu, NoteSubmenu, Delete, %A_ThisMenuItem%,
gosub,ButtonClear

Return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

NoteHandler:
gosub,ButtonClear
StringSplit, Number, A_ThisMenuItem,-
GuiControl,, TITLE, %Number2%
EditingNoteNo=%Number1%
EditingNoteTitle=%Number2%
NoteText:=ExtractInfo("Note",Number1)
GuiControl,, NOTE, %NoteText%
NoteText1=%NoteText%
GuiControl, show, D
Gui, Show, h%GUI_H% w%GUI_W% x%GUI_X% y%GUI_Y%, Note Taker

SubTITLE=%EditingNoteNo%~%EditingNoteTitle%
;`
Return


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Show_Hide:

IfWinExist,Note Taker
{
Gui, cancel
gosub,ButtonClear
}else{

Gui, Show, h%GUI_H% w%GUI_W% x%GUI_X% y%GUI_Y%, Note Taker
}
return

Exit:
WinClose , Note Taker
ExitApp
return

GuiClose:
Gui, cancel
return



EmptyArray(Number)
{
global
   loop
   {
      if Number%A_Index%=
      {
      Return
      }else{
      Number%A_Index%=
      }
   }
}



ExtractInfo(Para,Num)
{
global

NextNoteNum:=1

NoteText=
   Loop, parse, SavedNotes, `n, `r
   {
   StringSplit, Number, A_LoopField,~
      if Number2
      {
      NoteNum:=Number1
      
         if Para=FixNum
         {
            if NoteNum!=%NextNoteNum% ;fix numbers so they are consecutive
            {
            ;change number
            StringReplace, SavedNotes, SavedNotes,  %NoteNum%~,%NextNoteNum%~
            Menu, NoteSubmenu, Rename, %NoteNum%-%Number2%, %NextNoteNum%-%Number2%
            
            NoteNum:=NextNoteNum
            }
         }
      
         if Para!=Max
         {
         
         NoteCurNum:=Number1 ;store current note number
            if Number1=%Num% ;find the appropriate note number
            {
            NoteTitle:=Number2 ;save note title
            ;NoteTextLine:=A_Index+1
            }
            
         }
      NextNoteNum:=NoteNum+1
      }
      else if NoteNum=%Num%
      {
         if NoteText=
         {
         NoteText=%Number1%
         }
         else
         {
         NoteText=%NoteText%`n%Number1%
         }
      }

      EmptyArray(Number)
   }

   if Para=Max
   {
   Return NoteNum
   }
   else if Para=Title
   {
   Return NoteTitle
   }
   else if Para=Note
   {
   Return NoteText
   }
   else if Para=FixNum
   {
   ;msgbox,%SavedNotes%
   Return SavedNotes
   }
}


http://www.autohotkey.net/~viciouskinid/LocateTB.ahk


Last edited by viciouskinid on Sun Mar 02, 2008 11:09 am; edited 1 time in total
Back to top
View user's profile Send private message
Jero3n



Joined: 19 Jan 2007
Posts: 151

PostPosted: Sun Mar 02, 2008 10:49 am    Post subject: Reply with quote

#Include file LocateTB.ahk cannot be opened...
_________________

Watch my css video!
Back to top
View user's profile Send private message
viciouskinid



Joined: 23 Jun 2007
Posts: 136

PostPosted: Sun Mar 02, 2008 11:09 am    Post subject: Reply with quote

forgot about that
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group