Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I make that when I press Ctrl+D on my computer the User initials and time stamp show up in flowing format: <RL mm/dd/yyy hh:mm:ss>. The time and date should be the current time and date.

share|improve this question
2  
Show up where?​ –  Ignacio Vazquez-Abrams Oct 5 '11 at 19:19

2 Answers 2

This AutoIt code will put the timestamp in your clipboard for you to paste wherever you want. It uses the currently logged in username, it is impossible to get the initials of the person at the computer unless it is stored somewhere to pull from. If we new more about how you intended to use this, we could probably give a better solution.

HotKeySet("^D", "PasteDate") ;Control+D

While 1
    Sleep(100)
WEnd

Func PasteDate()
    ClipPut(@UserName & " " & @MON & "/" & @MDAY & "/" & StringRight(@YEAR, 2) & " " & @HOUR & ":" & @MIN & ":" & @SEC)
EndFunc
share|improve this answer

The only way I can think to get the initials is if you have Microsoft Office installed, and if users have entered their full name in the Options, then their initials will be stored in the user preferences, and so available in the registry. If so, it should be possible to access this registry value in AutoHotKey, using the RegRead function.

The registry key that stores the user initials is:

HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo

To show the reading of this registry value, the following code gets the registry value, and displays it:

!+^b::
    RegRead, Initials, HKEY_CURRENT_USER, Software\Microsoft\Office\Common\UserInfo, UserInitials
    MsgBox, Initials are: %Initials%
Return

The documentation I linked to above has more info about error-checking, to see if this key is actually available. You could always fall back on the username, as MaQleod suggested, if the initials aren't available this way.


And for an alternative way of formatting the date... In AutoHotKey, and probably AutoIt too, you can use FormatTime and CurrentDateTime to get nice control over formatting.

For example, the following are different short-cuts that I use, to insert the date in different formats, for different situation:

; Today - paste in date - separated with slashes - suitable for, e.g. OneNote
+^!T::
    FormatTime, CurrentDateTime,, dd/MM/yyyy
    SendInput %CurrentDateTime%
Return

; Today - paste in date - separated with underscores - suitable for, e.g. filenames
+^!Y::
    FormatTime, CurrentDateTime,, yyyy_MM_dd
    SendInput %CurrentDateTime%
Return

; Today - paste in date and time - separated with underscores - suitable for, e.g. filenames
+^!U::
    FormatTime, CurrentDateTime,, yyyy_MM_dd_HH_mm
    SendInput %CurrentDateTime%
Return

; Today - as above, but with fewer underscores
+^!I::
    FormatTime, CurrentDateTime,, yyyyMMdd_HHmm
    SendInput %CurrentDateTime%
Return

; Today - paste in date and time - in same format that OneNote 2007 generates, e.g. 04/01/2011, 22:56
+^!O::
    FormatTime, CurrentDateTime,, dd/MM/yyyy, HH:mm
    SendInput %CurrentDateTime%
Return

So, stringing all that together gives:

^d::
    RegRead, Initials, HKEY_CURRENT_USER, Software\Microsoft\Office\Common\UserInfo, UserInitials
    Send <
    Send, %Initials%{SPACE}
    FormatTime, CurrentDateTime,, MM/dd/yyyy HH:mm:ss
    SendInput %CurrentDateTime%
    Send >
Return

Having loaded that code in to AutoHotKey, when I hit Control + D, it is as though I typed:

<CM 10/05/2011 23:57:37>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.