Format The Clipboard Data
The clipboard data will now be available on the Autohotkey script clipboard so we can commence formatting the output. This is done by using Autohotkey variables. The output can be displayed in a number of ways. In this case a simple "MsgBox" dialogue will be used to output the data. The time and date fields provides a way of accessing the current time, as it holds this in a timestamp variable called "A_NOW" and is in the format "YYYYMMDDHH24MISS." By selecting a sub-string of this format the current time and date can be output in various ways.
The clipboard information will be stored in a single dynamic variable, called "vClipout."
Assign the first line of the message "Clipboard Time/Date: <current date>."
This is achieved as follows:
vTimeHour := Substr(A_Now,9,2) ; Start at 9th character, and get the next 2 depicting the hour
vTimeMinutes := Substr(A_Now,11,2) ; Start at 11th character and get the next 2 depicting the minutes
vYearVal := SubStr(A_Now, 1,4) ; Start at first character and get teh next 4 for the year
vMonthVal := SubStr(A_Now,5,2) ; Start at the 5th character and get the next 2 characters for the month
vDayVal := SubStr(A_Now,7,2) ; Start at the 7th character and get the next 2 for the day
vClipout := vMonthVal . "/" . vDayVal . "/" . vYearVal . " " . vTimeHour . ":" . vTimeMinutes . "`n`n============================`n`n" ; Add end newline here.
; The above demonstrates how variables are used in Autohotkey. Dynamic (as opposed to static, explained in later articles) variables are surrounded by "%". Variables can be concatentaed with themself via the ".=" operator
; Finally, we add the clipboard contents and output via a message box:
vClipout := "Clipboard Contents @ " . vClipout . clipboard