Hi, I use a script to enter current date. However is there a way to format a typed date. So if I type 030619 will send 03/06/19. Or even better if possible 03/06/19 (Mon). So format date / and have the day in brackets.
Would you send control A, then copy to clipboard and paste formatted somehow?
Manny thanks
Format typed date
-
- Posts: 53
- Joined: 01 Jun 2019, 09:02
Re: Format typed date
Code: Select all
FormatTime formatted, % convert("030619"), dd/MM/yyyy (ddd)
MsgBox % formatted
convert(ddmmyy) {
RegExMatch(ddmmyy, "(..)(..)(..)", $)
return "20" $3 $2 $1
}
Re: Format typed date
Here's a full script, select the 6-digit date, then press Ctrl+Q.
Code: Select all
^q:: ;convert date - 'ddMMyy' to 'dd/MM/yy (ddd)'
Clipboard := ""
SendInput, ^c
ClipWait, 3
if ErrorLevel
{
MsgBox, % "error: failed to retrieve clipboard text"
return
}
vDate := Clipboard
if !RegExMatch(vDate, "^\d{6}$")
{
MsgBox, % "error: invalid date: " vDate
return
}
vDate := RegExReplace(vDate, "(..)(..)(..)", "20$3$2$1")
FormatTime, vDate, % vDate, dd/MM/yy (ddd)
;FormatTime, vDate, % vDate, ddd dd MMM yyyy ;an alternative
SendInput, % vDate
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 53
- Joined: 01 Jun 2019, 09:02
Re: Format typed date
Hi, thats superb thanks so much.
Who is online
Users browsing this forum: just me and 130 guests