Myriam Diaz Martinez
Myriam Diaz Martinez

Reputation: 131

Add Date Stamp and a String Fast using AutoHotKeys

I am trying to add a date stamp followed by Last Name, First Name followed by a text. Such as:

::ABC:: 
FormatTime, ClipBoard,, dd-MMM-yyyy 'Last Name, First Name;'
ClipSaved := ClipboardAll 
Clipboard =  
(

Text 
) 
Send ^v 
sleep 100 
Clipboard := ClipSaved 
ClipSaved = 
return

But it doesn't work. I am using this version because I need it to be reliable/not cut the text as it has happened before with:

::ABC::
Clipboard =   
FormatTime, ClipBoard,, dd-MMM-yyyy'; Last Name, First Name; '
SendInput, %ClipBoard%
(

Text
)
Return

Any ideas?

Upvotes: 0

Views: 56

Answers (2)

Relax
Relax

Reputation: 10568

::ABC:: 
ClipSaved := ClipboardAll  ; save the entire clipboard to the variable ClipSaved
Clipboard := ""   ; empty the clipboard
; https://autohotkey.com/docs/commands/_EscapeChar.htm#Escape_Sequences
; ";" must be escaped 
; quote '  must be enclosed in quotes 
FormatTime, ClipBoard,, dd-MMM-yyyy '''''Last Name, First Name`;'''''
TextToAppend =   ; append this text to the clipboard
(

Text 
)
clipboard = %clipboard%%TextToAppend%
Send ^v
sleep 100 
Clipboard := ClipSaved  ; restore original clipboard
ClipSaved := ""  ; free the memory
return

Upvotes: 1

JoeRagu
JoeRagu

Reputation: 71

Are firstname and lastname variables?

If so, just use:

SendInput, % ClipBoard " " firstName " " lastName

Upvotes: 0

Related Questions