AutoHotkey Community

It is currently May 26th, 2012, 6:28 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Note Taker
PostPosted: March 2nd, 2008, 11:38 am 
Offline

Joined: June 23rd, 2007, 2:44 am
Posts: 136
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 March 2nd, 2008, 12:09 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2008, 11:49 am 
Offline

Joined: January 19th, 2007, 9:09 pm
Posts: 147
#Include file LocateTB.ahk cannot be opened...

_________________
Image
Watch my css video!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2008, 12:09 pm 
Offline

Joined: June 23rd, 2007, 2:44 am
Posts: 136
forgot about that


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 24 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group