format a date inside clipboard

Get help with using AutoHotkey and its commands and hotkeys
feliperrds
Posts: 8
Joined: 25 Mar 2019, 07:52

format a date inside clipboard

29 Mar 2019, 18:25

Hello to everyone :yawn:
It's possible format a value inside the "Ctrl+C" clipboard?
Ex. i copy a value (DD/MM/YYYY) so i format (DD/MM/YYYY) in a (YYYYMMDD) inside clipboard, then i press Ctrl+V it ill paste the same value formatted (YYYYMMDD)
Rohwedder
Posts: 3787
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: format a date inside clipboard

30 Mar 2019, 02:55

Hallo,
try this:
(only exactly the copied date)

Code: Select all

#Persistent
OnClipboardChange("format_a_date")
return
format_a_date()
{ ;formats "30/03/2019" to "20190330"
	If RegExMatch(ClipBoard, "\A(\d\d)/(\d\d)/(\d\d\d\d)\z",D)
		ClipBoard := D3 D2 D1
}
or that:
(all dates at once)

Code: Select all

#Persistent
OnClipboardChange("format_all_dates")
return
format_all_dates()
{ ;formats all "30/03/2019" to "20190330"
	If RegExMatch(ClipBoard, "\d\d/\d\d/\d\d\d\d")
		ClipBoard := RegExReplace(ClipBoard, "(\d\d)/(\d\d)/(\d\d\d\d)", "$3$2$1") 
}

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Gio, Google [Bot], grossermanitu, mikeyww and 61 guests