For a solution that will work in most Windows applications, not just Delphi, you can use Authotkey (free, autohotkey.com). One of its many features is the ability to expand the lines you enter, usually used to automatically correct typos.
I run all my shortcuts with a semicolon, since it almost never leads the lines that I type in real life, so in your example, to insert a sequence of comments-username, I would like to enter a semicolon, slash
;
An Authotkey script (which you can put in a .ahk text file and add the file to Autostart) will look like this:
::;//:: ; this means: when I type ";//", do what follows FormatTime, curDate,, yyyy-MM-dd ; the double comma is intended SendInput // %curDate% %A_UserName% ; variable expansion return
This leads to the following conclusion:
The AHK syntax is a bit tight, but there is an extensive help file.
While editing: this script can be expanded to apply the correct comment syntax depending on the environment in which you are currently working. You must define the title of the active window, find the signature substring ("Delphi"), and select the correct comment character. Thus, you can enter the same hotline to insert a comment regardless of the current environment or language. You can also use SendInput to arrange the caret in the same way that Delphi templates do.
source share