Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Paste a Time Stamp with AutoHotkey


  • Please log in to reply
5 replies to this topic
Double-Down
  • Members
  • 24 posts
  • Last active: Apr 28 2014 01:37 PM
  • Joined: 13 Dec 2010
Hi all,

I realize this is just about the most basic Autohotkey question one can ask, but I'm sitting here baffled as to why I can't get my simple hotstring to work.

I would like to get the following hotstring to post a time stamp whenever I press the letter t 3 times.

; Hotstring to place time stamp in document 
::ttt::
Send, %A_H%:%A_Min% tt 
Return 


My second-grade code above dismembers the hour from the minutes and does not include hour nor the AM or PM. B)

I also tried the following code, which works, but it adds the date (I only want the time):

; Hotstring to enter time stamp in document 
::ttt::
FormatTime, Time
SendInput, %Time%
Return


I've spent hours today running endless Google searches and experimenting with 0 positive results on my end. I would really appreciate it if someone can correct my chicken-scratch code to yield my desired outcome. B) Again, I would like to simply type the letters ttt and have AutoHotkey change this hotstring (H:MM tt) to the time as in “6:15 PM”--I don’t need the date added.

Would really appreciate the help as the built-in help files only confused me further, and the other topics I found on the AutoHotkey website seemed to be explaining very intricate ways of entering dates and times.

Thanks,

D-D

tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
this was just asked a couple weeks ago.

please read the documentation on FormatTime ...

many many samples.
4 descriptive tables.
and good descriptions and information.

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .


Double-Down
  • Members
  • 24 posts
  • Last active: Apr 28 2014 01:37 PM
  • Joined: 13 Dec 2010
HI,

Like I stated in my original post. I read most of that information already and I could not find a way of getting this done. Can you at least verify that indeed this is possible? since I've run out of ideas (hence my posting of this question), I'm ready to assume this can't be done, but it seems so simple that I'm assuming I'm doing all of this wrong. I'm not trying to be lazy about accomplishing this task, I'm simply out of ideas. My screen reader has read your link as a "visited link" confirming that I've already reviewed the material you suggested. Sorry if I'm causing needless repetition, but its been hours and I can't make this work.

Thanks,

D-D

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
; Hotstring to enter time stamp in document 
::ttt::
FormatTime, Time, ,optionsGoHere
SendInput, %Time%
Return

you need to pick what options you want. 12 hour? 24 hour? leading 0?
typical option might be
h:mm tt
Please run the example code from the help file. It really should give you an idea of which example relates to your desire
FormatTime, TimeString
MsgBox The current time and date (time first) is %TimeString%.

FormatTime, TimeString, R
MsgBox The current time and date (date first) is %TimeString%.

FormatTime, TimeString,, Time
MsgBox The current time is %TimeString%.

FormatTime, TimeString, T12, Time
MsgBox The current 24-hour time is %TimeString%.

FormatTime, TimeString,, LongDate
MsgBox The current date (long format) is %TimeString%.

FormatTime, TimeString, 20050423220133, dddd MMMM d, yyyy hh:mm:ss tt
MsgBox The specified date and time, when formatted, is %TimeString%.

FormatTime, TimeString, 200504, 'Month Name': MMMM`n'Day Name': dddd
MsgBox %TimeString%

FormatTime, YearWeek, 20050101, YWeek
MsgBox January 1st of 2005 is in the following ISO year and week number: %YearWeek%

Teach a man to fish...

Double-Down
  • Members
  • 24 posts
  • Last active: Apr 28 2014 01:37 PM
  • Joined: 13 Dec 2010
HI Engunneer,

Yep! That did it!

I see my dumb mistake now. Before posting my request for help I took a long look at the help file and unknowingly significantly modified the original code thinking there was an extra comma for no reason as well as including the word "text" which I didn't know was actually prompting me to enter h:mm tt. (major OOPS)! ...After having found 0 solutions one's mind begins experimenting with magical coding syntax. B)

For anyone else looking for this information, here is the final code:

; Hotstring to enter time stamp in document
::ttt::
FormatTime, Time, ,h:mm tt
SendInput, %Time%
Return

I notice something funky when typing as a period will not be entered if I type a period character immediately after having typed the triple t then follow up with a press of the spacebar. If I press the period key twice followed by the spacebar it will definitely enter punctuation correctly. This is a problem for another time as I'm very happy with my new time stamp and want to leave well enough alone.

For kicks here's the code I use to enter a date stamp:

; Hotstring to enter date stamp 
::ddd::
Send, %A_MM%/%A_DD%/%A_YYYY%
Return 

Thank you tremendously Engunneer for taking the time out of your day to help me.

D-D

tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
don't mean to sound like an arse or anything but

you said "google search" and well, AHK has it's own documentation page. with search features.
you may be interested in a few of these tutorials/guides.

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .