Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inserting current date and time
#1
This appends current contents of Notepad to a file (on a new line), but how do I insert date and time (preferably including the seconds) as well?
 
Code:
Copy      Help
int w=win("Notepad" "Notepad")
act id(15 w) 
key Ca       
_s.getsel(); _s.setclip()
_s.getclip(); _s.setfile("$Documents$\Backup.txt" -1 -1 1)
key D        
 
#2
Date and time where?  the filename or the text?

if in the text something like this
Code:
Copy      Help
str ss s.from(ss.timeformat("{D} {TT}") "[]" _s)
s.setfile("$Documents$\Backup.txt" -1 -1 1)
#3
Yes, got it to work. Thank you!!
#4
Code:
Copy      Help
int w=win("" "Notepad")
act id(15 w)
key Ca
_s.getsel
str ss s.from(ss.timeformat("{D} {TT}") "[]" _s)
s.setfile("$Documents$\Backup.txt" -1 -1 1)
key D
 don't need setclip getclip functions at all here actually don't even need getsel either

Function SaveNotepadtextTofile
Code:
Copy      Help
int w=win("" "Notepad")
int c=id(15 w) ;;editable text 'Text Editor'
_s.getwintext(c)
str ss s.from(ss.timeformat("{D} {TT}") "[]" _s)
s.setfile("$Documents$\Backup.txt" -1 -1 1)
#5
That's an even cleaner solution. I used Key D to deselect the text and now that's not needed either. Thank you!


Forum Jump:


Users browsing this thread: 1 Guest(s)