Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

How To Auto-Fill Current Date and Current Time


  • Please log in to reply
7 replies to this topic
Newbie Scripter
  • Guests
  • Last active:
  • Joined: --
I am not a scripter, so please no laughing at this simple question :oops:

I am looking for a way to auto-fill My Initials, the Current Date, and the Current Time. I have found a way to do this (posted below), but I can't figure out how to get the time to display whether it's AM or PM. I know there is probably a more elegant way to get the information to display that I have gotten to display as well - so any help would be appreciated. Ultimately I want the readout to say (for example):

- TTA 08/20/2008 1:00 PM

This is what I have developed so far (see below - very non-elegant), but need to determine how to get the AM or PM to display at the end of the line. I know I need to use "tt" but am unsure the context.

#x::
Send - TTA %A_MM%/%A_DD%/%A_YYYY% %A_Hour%:%A_Min%

Slanter
  • Members
  • 739 posts
  • Last active: Jul 08 2011 05:26 AM
  • Joined: 28 May 2008
#x::
FormatTime, Time,, MM/DD/YYYY h:mm tt
Send - TTA %Time%
Return
:?:
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.

Newbie Scripter
  • Guests
  • Last active:
  • Joined: --
Thanks for the quick reply Slanter. That did the trick - the only thing is to get it to work right I had to change the date format to MM/dd/yyyy instead of MM/DD/YYYY. This is perfect though, and much more elegant than what I was playing around with. THANKS!!!!

Newbie Scripter
  • Guests
  • Last active:
  • Joined: --
Wow, do I love this utility. We have been asked to enter in specific information into each Help Desk ticket we create. The information is who the ticket is being assigned to, who is assigning the ticket, the current date and time.

Using this utility (with a big dose of help from Slanter) I am now able to enter in all of this information, PLUS get the caret (or cursor) to go to the proper place in the line where I can just type the name of the person the ticket is assigned to.

The code I used is:

FormatTime, Time,, MM/dd/yy hh:mm tt 
Send  Ticket Assigned To%A_Space% - TTA %Time%{left 24}
Return

This enters all of the needed information automatically PLUS sets the cursor at the proper point where all I need to do is type in the person's name that the ticket is being assigned to.

Thought I'd share this in case it helps someone else out in the future. Thanks again Slanter!

BoBo²
  • Guests
  • Last active:
  • Joined: --

where I can just type the name of the person the ticket is assigned to

Check if you can use the default OS variable %USERNAME% to automate this too.

Newbie Scripter
  • Guests
  • Last active:
  • Joined: --
Thanks for the suggestion Bobo. I hadn't thought about using the %Username% variable, but after you suggested it I tried it - it does work. I can't use it to auto-fill the name of the person the ticket is being assigned to since it could be five or so different people, but I can use it to auto-fill my login name instead of my initials. I would just have to modify the {left 24} portion to move the cursor back more spaces since my login name is longer than the three characters I'm using for my initials.

I think for my purposes I'll continue to use the initials because then if more people in my department want to use it, the {left 24} can remain constant if we all use the same format (login names vary in length). This is also why I chose to use the MM/dd/yy format instead of the M/d/yy format because it will keep the numbers I have to move the cusor back constant regardless if it is a single digit or double digit month or date.

Slanter
  • Members
  • 739 posts
  • Last active: Jul 08 2011 05:26 AM
  • Joined: 28 May 2008
Try looking into the StrLen() function, you can do something like this
FormatTime, Time,, MM/dd/yy hh:mm tt

Left := 21 + StrLen(Username)

Send  Ticket Assigned To  - %Username% %Time%{left %Left%}

Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.

Newbie Scripter
  • Guests
  • Last active:
  • Joined: --
Bobo thanks again for the suggestion of using the %username% variable and Slanter thanks for making this work using the StrLen() function the way it should. Your sample script works perfectly for anyone, regardless how long their user name is.

This is much more elegant than what I started playing around with and anyone in our group can use this script 'as-is'. No modification is necessary.

Great utility, great website, great forum!!! Thanks for all the help! :D