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 

Creating a simple journal...

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
gutini
Guest





PostPosted: Fri Jan 04, 2008 1:55 am    Post subject: Creating a simple journal... Reply with quote

I would like to create a simple ongoing journal using hotkeys. The key features that I have been trying to put together are the following:

-Open a given text file with certain hotkey.
-Save and Close given text file with the SAME hotkey.

(The way I have it coded, the same text opens each time the hotkey is struck; I want it to open and close not open twice)

-Print the date and time on the next line each time the file is opened with the hotkey.

I envision a simple on-going journal. Any additional features are welcome.

Thanks!

Lance.
Back to top
DerRaphael



Joined: 23 Nov 2007
Posts: 456
Location: Heidelberg, Germany

PostPosted: Fri Jan 04, 2008 2:24 am    Post subject: Reply with quote

this code uses win+t as hotkey and checks if a notepad with the myfile.txt is already open. if not, it opens upon activation a myfile.txt from A_ScriptDir. After file is opened/created (@1st start) it inserts a linebreak, a timestamp taken from A_Now and formated via RegExReplace, and another linebreak at the end of file. otherwise it sends ctrl+s for saving and alt+f4 for closing.

Code:
#t::
 oldSTMM := A_TitleMatchMode
 SetTitleMatchMode, 2
 if !(WinExist("myfile.txt" ahk_class Notepad)) {
   run, "notepad.exe" myfile.txt
   WinWaitActive, myfile.txt ahk_class Notepad
   Send, % RegExReplace(A_Now
       , "(\d{4})(\d\d)(\d\d)(\d\d)(\d\d).+"
       , "^{End}{Enter}$1/$2/$3@$4:$5{Enter}")
 } else {
   WinWaitActive, myfile.txt ahk_class Notepad
   Send, ^s!{f4}
 }
 SetTitleMatchMode, %oldSTMM%
return


took less than 5 mins or so to get it tested and running ...
greets
derRaphael
_________________


Last edited by DerRaphael on Fri Jan 04, 2008 2:38 am; edited 2 times in total
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 456
Location: Heidelberg, Germany

PostPosted: Fri Jan 04, 2008 2:34 am    Post subject: Reply with quote

would have been nice, if u had posted your code, it'd be reviewed, corrected and tweaked where neccessary so you might have learned from given results. instead you explained some idea and let others (like me) code. anyways ... since u didnt show yours, i show mine and just show off how lil space needed for such task (this one still can be tweaked)

if you need another timestamp feel free to peek at the other timestamp version i posted the other day here:
http://www.autohotkey.com/forum/viewtopic.php?t=26298
(the one with "AM":"PM" in its code)

derRaphael
_________________
Back to top
View user's profile Send private message
gutini
Guest





PostPosted: Fri Jan 04, 2008 4:35 am    Post subject: Reply with quote

I'm new to programming, and I'm having trouble substituting the given time stamp with the AM/PM version.

I also am trying to put in an if statement that if nothing is typed, nothing is saved.

Thanks.
Back to top
gutini
Guest





PostPosted: Fri Jan 04, 2008 4:42 am    Post subject: Reply with quote

To clarify, I want to not save the txt file when nothing additional (besides the time stamp) is written. It's as if I wanted to edit my journal and I couldn't think of anything to write, so I don't want to save anything. However, I want to be able to exit just as easily.
Back to top
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Fri Jan 04, 2008 11:12 am    Post subject: Reply with quote

hello lance
I use this to copy a link/url and writes it with remark and date to the same textfile (as csv)
I use this to read collected urls with a listview and start link

Code:
!b::
   {
   ;-- alt+b copies url and writes with comment and date to a file---
   F181=_savedlinks1.txt
   clipboard=
   send,!s
   sleep,200
   send,^c
   CL=%clipboard%
   if CL=
     return
   InputBox, UserInput, comments
   if errorlevel<>0
      return
   stringmid,ST,A_now,1,12
   FileAppend,%userinput%;%clipboard%;%ST%;;`r`n,%F181%
   Splashimage,,b w600 h150 x100 Y400 CWsilver m9 b fs10 zh0,%clipboard%
   Sleep,900
   Splashimage, off
   return
   }


another script, saves marked text to xy.ahk
Code:
;F12_AHK.AHK   2005-10-06 garry
;mark a AHK script in the forum and press F12
;script will be saved  YYYYMMDDHHMMSS.AHK
F12::
F1=%A_NOW%.AHK
P1=%A_Desktop%\            ;here your path
Formattime,TS,,longdate
Formattime,TT,T12,time

clipboard=
Send ^c
Sleep,100
FileAppend,;--------- saved at %TS% %TT% --------------`r`n%clipboard%`r`n,%P1%\%F1%
Splashimage,,b w600 h150 x100 Y400 CWsilver m9 b fs10 zh0,%clipboard%
Sleep,900
Splashimage, off

return
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 175
Location: CO, USA

PostPosted: Fri Jan 04, 2008 12:18 pm    Post subject: Reply with quote

I'll offer up the Journal script I wrote a while back. It uses a pop-up GUI to quickly capture the Title/Subject, Content (Description) and Tag(s) for quick searching. Each entry appends to my journal.txt file without actually opening the file. It adds a date/time stamp and separator. I wrote it to be simple, fast, effective.

Code:
MyJournal = %A_MyDocuments%\My Scratch Pad\LRS_Journal.txt
;------------------------------------------------------------
;Hotkey to capture My Jounal entries:
;------------------------------------------------------------
#J::
FormatTime, RightNow
{
; Simple input-box
Gui, Add, Text, x6 y27 w50 h20 , Title:
Gui, Add, Text, x6 y67 w50 h20 , Content:
Gui, Add, Text, x6 y147 w50 h20 , Tags:
Gui, Add, Edit, x66 y27 w380 h20 vTitleName ; Topic variable,
Gui, Add, Edit, x66 y67 w380 h70 vContentText ; Content variable,
Gui, Add, Edit, x66 y147 w380 h20 vTagList ; Tag list variable. Separate tags commas.,
Gui, Add, Button, x106 y187 w100 h30 , Enter ; The label ButtonEnter will be run when the button is pressed.
Gui, Add, Button, x296 y187 w100 h30 , Cancel ; The label ButtonCancel will can action but keep script running.
Gui, Show, x350 y182 h236 w461, New Journal Entry
Return ; End of auto-execute section. The script is idle until the user does something.

GuiClose:
ButtonCancel:
      Gui,Destroy
     ExitApp
      
   ButtonEnter:
   Gui, Submit  ; Save the input from the user to each control's associated variable.

   FileAppend, TITLE: %TitleName%`nTAGS: %TagList%`nTIME: %RightNow%`nCONTENT: %ContentText%`n----------------------------------------------------------------------`n, %MyJournal%
  Gui,Destroy
   ExitApp
}   


Here's the GUI pop-up: (By the way, how do you center an image in a post?)


_________________
Lars


Last edited by TotalBalance on Tue Jan 08, 2008 10:17 am; edited 3 times in total
Back to top
View user's profile Send private message
damajha



Joined: 23 Oct 2006
Posts: 31

PostPosted: Sat Jan 05, 2008 7:14 am    Post subject: Reply with quote

Is there a way, instead of it exiting after you enter a entry, but to simply clear itself and continue to idle until the hotkey is pressed again?
Back to top
View user's profile Send private message
TotalBalance



Joined: 22 Jan 2007
Posts: 175
Location: CO, USA

PostPosted: Sat Jan 05, 2008 7:32 am    Post subject: Reply with quote

I'm sure there is. I don't need it to work that way but perhaps others can guide you how to.
_________________
Lars
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Sat Jan 05, 2008 11:13 am    Post subject: Reply with quote

script from TotalBalance, clear editfields and don't exit

Code:
MyJournal = LRS_Journal.txt
!J::
FormatTime, RightNow
Gui, Add, Text, x6 y27 w50 h20 , Title:
Gui, Add, Text, x6 y67 w50 h20 , Content:
Gui, Add, Text, x6 y147 w50 h20 , Tags:
Gui, Add, Edit, x66 y27 w380 h20 vTitleName ; Topic variable,
Gui, Add, Edit, x66 y67 w380 h70 vContentText ; Content variable,
Gui, Add, Edit, x66 y147 w380 h20 vTagList ; Tag list variable. Separate tags commas.,
Gui, Add, Button, x106 y187 w100 h30 , Enter ; The label ButtonEnter will be run when the button is pressed.
Gui, Add, Button, x296 y187 w100 h30 , Cancel ; The label ButtonCancel will can action but keep script running.
Gui, Show, x350 y182 h236 w461, New Journal Entry
Return ; End of auto-execute section. The script is idle until the user does something.

GuiClose:
;ButtonCancel:
      Gui,Destroy
     ExitApp

   ButtonEnter:
   Gui, Submit  ; Save the input from the user to each control's associated variable.

   FileAppend, TITLE: %TitleName%`nTAGS: %TagList%`nTIME: %RightNow%`nCONTENT: %ContentText%`n----------------------------------------------------------------------`n, %MyJournal%
  ButtonCancel:
  GuiControl, ,Titlename,
  GuiControl, ,ContentText,
  GuiControl, ,TagList,
  Gui,Destroy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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