dddate.ahk

#Windows #AutoHotkey

This script inserts the date into the current cursor position after a hotkey is pressed.

AutoHotKey v1

#SingleInstance force

:R*?:DDD::
    if GetKeyState("LShift", "P") {
        FormatTime, CurrentDateTime, , yyy-MMM-dd
        SendInput %CurrentDateTime%
    }
     else {
        FormatTime, CurrentDateTime, , yyy-MM-dd
        SendInput %CurrentDateTime%
    }
return

:R*?:FFF::
    if GetKeyState("LShift", "P") {
        FormatTime, CurrentDate, , yyyyMMdd
        FormatTime, CurrentTime, , HHmmss-0400
        SendInput %CurrentDate% @ %CurrentTime%
    }
     else {
        FormatTime, CurrentDateTime, , yyyyMMddTHHmmss-0400
        SendInput %CurrentDateTime%
    }
return

AutoHotKey v2

#Requires AutoHotkey v2.0
#SingleInstance force

:R*?:DDD::
{
    if GetKeyState("LShift", "P")
    {
        CurrentDateTime := FormatTime("", "yyy-MMM-dd")
        SendInput(CurrentDateTime)
    }
    else
    {
        CurrentDateTime := FormatTime("", "yyy-MM-dd")
        SendInput(CurrentDateTime)
    }
}

:R*?:FFF::
{
    if GetKeyState("LShift", "P")
    {
        CurrentDate := FormatTime("", "yyyyMMdd")
        CurrentTime := FormatTime("", "HHmmss-0400")
        SendInput(CurrentDate . " @ " . CurrentTime)
    }
    else
    {
        CurrentDateTime := FormatTime("", "yyyyMMddTHHmmss-0400")
        SendInput(CurrentDateTime)
    }
}