DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Problem with AHK time stamping  (Read 7,148 times)

Attronarch

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 148
Problem with AHK time stamping
« on: April 17, 2016, 07:53 AM »
I am using AHK script for text expansion and I've run into some problems with time stamps. Up to now I've been using only one time stamp (date, first one in the code), but after I added two more I messed up everything.

Code excerpt:

Code
:*::date::
FormatTime, CurrentDate,, yyyy-MM-dd ; This is one type of the date format
SendInput, %CurrentDate%

:*::st::
FormatTime, CurrentStartTime,, yyyy-MM-dd    hh:mm:ss ; This is one type of the date format
SendInput, %CurrentStartTime%    START

:*::ft::
FormatTime, CurrentFinishTime,, yyyy-MM-dd    hh:mm:ss ; This is one type of the date format
SendInput, %CurrentFinishTime%    FINISH

They generate:

Code
2016-04-172016-04-17,   09:51:55    START2016-04-17,   09:51:55    FINISH
2016-04-17    09:51:59    START2016-04-17    09:51:59    FINISH
2016-04-17    09:52:01    FINISH

While I would like them to generate:

Code
2016-04-17
2016-04-17    09:51:59    START
2016-04-17    09:52:01    FINISH

What did I do wrong?

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Problem with AHK time stamping
« Reply #1 on: April 17, 2016, 01:11 PM »
I would try adding `n to the end of your Sendinputs.  If that does not work try `r`n  for spacing tabs may be useful...  `t

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Problem with AHK time stamping
« Reply #2 on: April 17, 2016, 04:07 PM »
Those hotstrings work fine for me in a text editor.  What type of app are you trying to use them within?

Attronarch

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 148
Re: Problem with AHK time stamping
« Reply #3 on: April 17, 2016, 04:19 PM »
I would try adding `n to the end of your Sendinputs.  If that does not work try `r`n  for spacing tabs may be useful...  `t

When I add `n, for :date I get:

Code
2016-04-17 
2016-04-17    06:14:10    START 
2016-04-17    06:14:10    FINISH 

for :ts I get:

Code
2016-04-17    06:14:17    START 
2016-04-17    06:14:17    FINISH 

For :tf I get:

Code
2016-04-17    06:14:20    FINISH 

With `r`n it is the same but with added "enters".

What I would like to get is 2016-04-17 for :date, 2016-04-17    06:14:10    START for :ts, and 2016-04-17    06:14:10    FINISH for :tf.

Those hotstrings work fine for me in a text editor.  What type of app are you trying to use them within?

They do work, but they do not produce results I wanted them to (see above).

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Problem with AHK time stamping
« Reply #4 on: April 17, 2016, 04:24 PM »
Ah, I see what you're getting at.  Just add "Return" after each hotstring.

Code: ( autohotkey)
:*::date::
FormatTime, CurrentDate,, yyyy-MM-dd ; This is one type of the date format
SendInput, %CurrentDate%
Return

:*::st::
FormatTime, CurrentStartTime,, yyyy-MM-dd    hh:mm:ss ; This is one type of the date format
SendInput, %CurrentStartTime%    START
Return

:*::ft::
FormatTime, CurrentFinishTime,, yyyy-MM-dd    hh:mm:ss ; This is one type of the date format
SendInput, %CurrentFinishTime%    FINISH
Return

Attronarch

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 148
Re: Problem with AHK time stamping
« Reply #5 on: April 17, 2016, 04:42 PM »
Perfect, thank you very much.

Original address: https://www.donationcoder.com/forum/index.php?topic=42548.0