Jump to content

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

How to insert current date into a hotkey


  • Please log in to reply
17 replies to this topic
duraleigh
  • Members
  • 4 posts
  • Last active: Sep 16 2007 12:16 PM
  • Joined: 14 Sep 2007
Hi, folks,

Apologies for something so simple....I'm brand new at this. Tried FAQ's and searched but couldn't find my answer.

I currently have a hotkey that returns a text string. I would like that string to include the current date as well.

Here's the line from my script:

#5::send We have received your payment for the test kit refills and/or individual tests.......Thank you.{enter}{enter}Your order will ship to you by USPS Priority Mail on

I would like for the current date to be inserted at the end of that text.

Thanks in advance

BoBo¨
  • Guests
  • Last active:
  • Joined: --
Check out:

A_YYYY
A_MM
A_DD
A_Now
FormatTime


Good luck. 8)

Carlol
  • Members
  • 163 posts
  • Last active: Aug 03 2010 03:45 AM
  • Joined: 14 Aug 2006
Here are some examples to work with:

:R*?:ddd::
FormatTime, CurrentDateTime,, dd/MM/yy
SendInput %CurrentDateTime%
return
:R*?:xxx::
FormatTime, CurrentDateTime,, yyMMddHHmmss
SendInput %CurrentDateTime%
return
:R*?:aaa::
FormatTime, CurrentDateTime,, yyMMdd
SendInput %CurrentDateTime%
return
:R*?:jjd::
FormatTime, CurrentDateTime,, dd-MM-yy
SendInput %CurrentDateTime%
return
:R*?:yyy::
FormatTime, CurrentDateTime,, dd-MM-yy HH:mm
SendInput %CurrentDateTime%
return

Meaning if you write ddd it will produce 14/09/07 and so on, I'm sure you will be able to adapt the idea to your situation :~)

duraleigh
  • Members
  • 4 posts
  • Last active: Sep 16 2007 12:16 PM
  • Joined: 14 Sep 2007
Hi, again, folks,

Thanks for the prompt responses. I'm such a rookie at this I could make nothing work. Whatever I put at the end, I simply get that exact text returned to me.

Here's the complete line.

#5::send We have received your payment for the test kit refills and/or individual tests.......Thank you.{enter}{enter}Your order will ship to you by USPS Priority Mail on

I am trying to get the current date to insert at the end of that line and must be missing brackets or something to make the commands you provided commands instead of just text.

Perhaps you could just add what I need onto this:

USPS Priority Mail on....

Again, I'm sorry to be such a rookie. Thanks in advance once more.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

#5::send We have...

#n::
Run Notepad
return
In the final line above, "return" serves to finish the hotkey. However, if a hotkey needs to execute only a single line, that line can be listed to the right of the double-colon. In other words, the return is implicit:

#n::Run Notepad

See Hotkeys Intro.

tonne
  • Members
  • 1654 posts
  • Last active: May 06 2014 06:22 PM
  • Joined: 06 Jun 2006
Did anyone actually answer your question?
To use the built in variables, i.e., A_MM (Current 2-digit month (01-12)) it must be enclosed in % as:
#5::send We have received your payment for the test kit refills and/or individual tests.......Thank you.{enter}{enter}Your order will ship to you by USPS Priority Mail on %A_MM%/%A_DD%/%A_YYYY%

Tou can in most cases use SendInput instead of Send - it will be much faster.

duraleigh
  • Members
  • 4 posts
  • Last active: Sep 16 2007 12:16 PM
  • Joined: 14 Sep 2007
tonne,

Thank you! Thank you! works like a charm.

I think the problem was other posters just couldn't understand how dumb I really was....you did! :lol: :lol:

Great tip on sendinput, too...makes a big difference.

Now that I understand the basic idea, I can apply this and several other ideas as well....Thanks again!! :lol: :lol:

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Great tip on sendinput, too...makes a big difference.

Here's a tip to save typing:
SendMode, Input
This is present by default in scripts created by New -> AutoHotkey Script. It makes 'Send' synonymous with 'SendInput' (normally 'Send' is synonymous with 'SendEvent'.)

duraleigh
  • Members
  • 4 posts
  • Last active: Sep 16 2007 12:16 PM
  • Joined: 14 Sep 2007
Thanks for the tip.

Instead of the current date, How can I display the drop-down calendar (datetime, I think) in which I could select a future date by clicking on it.

Like the above question, I would like for that selected date to appear at the end of the text.

Also, like the above question, I hope you can insert the exact characters for me. I've been trying to figure it out but I just don't know enough (yet) to make it work.

I am appreciative of your help.

tonne
  • Members
  • 1654 posts
  • Last active: May 06 2014 06:22 PM
  • Joined: 06 Jun 2006
Study the section on GUI in the help file:
#5::
  Gui, Add, MonthCal, vDate
  Gui, Add, Button,Default,OK
  Gui, Show
  Return

ButtonOK:
  Gui,Submit
  SendInput Text, then date %date%
  Return


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
You'll probably want to format the date between Gui,Submit and SendInput.
FormatTime, date, %date%, MM/dd/yyyy
:)

ruddym
  • Members
  • 7 posts
  • Last active: Feb 05 2008 05:51 PM
  • Joined: 09 Jan 2008
I suggest appending the following to tonne's script.

GuiClose:
  Gui, Destroy
  Return
GuiEscape:
  Gui, Destroy
  Return

This terminates the GUI if you close the window or press Escape rather than choosing OK. Also, under the ButtonOK subroutine, add

Gui, Destroy

...before the Return line. Otherwise you get an execution error the next time you activate the calendar GUI.

Cheers!

etyrnal_
  • Guests
  • Last active:
  • Joined: --
how do i use this in a Replacement case?

i.e. i'd like to use word replacement in such a way that when i type 2dd into a document it replces the 2dd with todays date?

::2dd::Send, %A_MM%/%A_DD%/%A_YYYY%



does NOT work

Zaelia
  • Members
  • 754 posts
  • Last active: Jan 17 2015 02:38 AM
  • Joined: 31 Oct 2008
::2dd::

Send, %A_MM%/%A_DD%/%A_YYYY%

return


scotty
  • Guests
  • Last active:
  • Joined: --
Hi folks, I'm hoping you guys can help...

in my script file I have :
::sphead::
(
-- ====================================================================================
-- ====================================================================================
-- OBJECT NAME:   
--
-- AUTHOR:  	 Scott       
--
-- DATE:         %A_MM%/%A_DD%/%A_YYYY% 
--
-- DESCRIPTION:   
--
-- UPDATES:       
-- ====================================================================================
-- ====================================================================================
)

You've probably guessed that I'm expecting "%A_MM%/%A_DD%/%A_YYYY%" to be replaced with today's date, but unfortunately, it just gets output as exactly as it is in the script...

Can anyone point me in the right direction to getting this working please ?