Here's
TimeStamp 2.1!
Use the tray menu or hotkeys to send user defined times and dates to the active window.
Doubleclick the tray icon to send the last used timestamp.
Use the Settings menu in the tray to change the timestamps and hotkeys.
Default hotkeys are F1 and F2.
Skrommel
;TimeStamp.ahk
; Use the tray menu or hotkeys to send user defined times and dates to the active window.
; Doubleclick the tray icon to send the last used timestamp.
; Use the Settings menu in the tray to change the timestamps and hotkeys.
;Skrommel @ 2008
#SingleInstance,Force
#Persistent,On
#NoEnv
SendMode,Input
SetWorkingDir,%A_ScriptDir%
SetBatchLines,-1
SetWinDelay,0
SetKeyDelay,0
AutoTrim,Off
applicationname=TimeStamp
Gosub,INIFILE
Gosub,MENU
string:=stamp1
Gui,+LastFound
guiid:=WinExist()
DllCall("RegisterShellHookWindow",UInt,guiid)
msgnum:=DllCall("RegisterWindowMessage",Str,"SHELLHOOK")
OnMessage(msgnum,"SHELLMESSAGE" )
OnMessage(0x404,"TRAYMESSAGE")
OnMessage(0x200,"WM_MOUSEMOVE")
OnExit,EXIT
Return
MENU:
Menu,Tray,NoStandard
Menu,Tray,DeleteAll
Menu,Tray,Add,%applicationname%,SEND
Menu,Tray,Default,%applicationname%
Menu,Tray,Add
stamps=0
Loop,99
{
IniRead,stamp,%applicationname%.ini,Settings,stamp%A_Index%
If stamp=ERROR
Continue
stamps+=1
stamp%stamps%:=stamp
string:=stamp
Gosub,EXPAND
IniRead,hotkey,%applicationname%.ini,Settings,hotkey%A_Index%
If hotkey=ERROR
hotkey=
Else
{
hotkey%stamps%:=hotkey
Hotkey,%hotkey%,SEND,On
}
Menu,Tray,Add,&%stamps% - %hotkey% - %timestring%,SEND
}
Menu,Tray,Add
WinGetTitle,title,ahk_id %lastactiveid%
If title=
WinGet,title,ProcessName,ahk_id %lastactiveid%
StringLeft,shorttitle,title,50
If (shorttitle<>title)
shorttitle.="..."
Menu,Tray,Add,Active window: %shorttitle%,ACTIVATE
Menu,Tray,Add
Menu,Tray,Add,&Settings...,SETTINGS
Menu,Tray,Add,&About...,ABOUT
Menu,Tray,Add,E&xit,EXIT
Menu,Tray,Tip,%applicationname%
Return
ACTIVATE:
WinActivate,ahk_id %lastactiveid%
Return
SEND:
If (A_TimeSinceThisHotkey<100 And A_TimeSinceThisHotkey<>-1)
{
Loop,%stamps%
{
If (hotkey%A_Index%<>A_ThisHotkey)
Continue
string:=stamp%A_Index%
Gosub,EXPAND
Send,%timestring%
Break
}
}
Else
{
If A_ThisMenuItemPos=1
Gosub,EXPAND
Else
If A_ThisMenuItemPos>2
{
menu:=A_ThisMenuItemPos-2
string:=stamp%menu%
Gosub,EXPAND
}
WinActivate,ahk_id %lastactiveid%
WinWaitActive,ahk_id %lastactiveid%,,5
If ErrorLevel=0
{
Send,%timestring%
}
}
Return
SHELLMESSAGE(wParam,lParam)
{
Global lastactiveid
If wParam<>4
Return
IfWinNotExist,ahk_id %lParam%
Return
WinGetClass,class,ahk_id %lParam%
If class in Shell_TrayWnd
{
Gosub,MENU
Return
}
lastactiveid:=lParam
}
TRAYMESSAGE(wParam,lParam)
{
If lParam In 517
Gosub,MENU
Return
}
EXPAND:
StringGetPos,pos,string,"
If pos=0
timepos=3
else
timepos=1
StringSplit,timearray,string,"
LOOP1:
FormatTime,week,,YWeek
StringRight,week,week,2
week+=0
FormatTime,day,,YDay
FormatTime,longday,,dddd
StringLower,dllower,longday
StringLower,dltitle,longday,T
StringUpper,dlupper,longday
FormatTime,shortday,,ddd
StringLower,dslower,shortday
StringLower,dstitle,shortday,T
StringUpper,dsupper,shortday
FormatTime,longmonth,,MMMM
StringLower,mllower,longmonth
StringLower,mltitle,longmonth,T
StringUpper,mlupper,longmonth
FormatTime,shortmonth,,MMM
StringLower,mslower,shortmonth
StringLower,mstitle,shortmonth,T
StringUpper,msupper,shortmonth
time=timearray%timepos%
time:=%time%
If time=
Goto,NEXT1
StringReplace,time,time,nl,&&&,All
StringReplace,time,time,tab,|||,All
StringReplace,time,time,week,@@@@,All
StringReplace,time,time,day,@@@,All
StringReplace,time,time,dddd,!!!!,All
StringReplace,time,time,Dddd,$!!!,All
StringReplace,time,time,DDDD,$$$$,All
StringReplace,time,time,ddd,!!!,All
StringReplace,time,time,Ddd,$!!,All
StringReplace,time,time,DDD,$$$,All
StringReplace,time,time,mmmm,££££,All
StringReplace,time,time,Mmmm,§£££,All
StringReplace,time,time,MMMM,§§§§,All
StringReplace,time,time,mmm,£££,All
StringReplace,time,time,Mmm,§££,All
StringReplace,time,time,MMM,§§§,All
FormatTime,time,,%time%
StringReplace,time,time,&&&,`n,All
StringReplace,time,time,|||,%A_Tab%,All
StringReplace,time,time,@@@@,%week%,All
StringReplace,time,time,@@@,%day%,All
StringReplace,time,time,!!!!,%dllower%,All
StringReplace,time,time,$!!!,%dltitle%,All
StringReplace,time,time,$$$$,%dlupper%,All
StringReplace,time,time,!!!,%dslower%,All
StringReplace,time,time,$!!,%dstitle%,All
StringReplace,time,time,$$$,%dsupper%,All
StringReplace,time,time,££££,%mllower%,All
StringReplace,time,time,§£££,%mltitle%,All
StringReplace,time,time,§§§§,%mlupper%,All
StringReplace,time,time,£££,%mslower%,All
StringReplace,time,time,§££,%mstitle%,All
StringReplace,time,time,§§§,%msupper%,All
timearray%timepos%=%time%
NEXT1:
timepos+=2
If timepos<=%timearray0%
Goto,LOOP1
timestring=
timepos=1
LOOP2:
time=timearray%timepos%
time:=%time%
timestring=%timestring%%time%
timepos+=1
If timepos<=%timearray0%
Goto,LOOP2
Return
SETTINGS:
Run,TimeStamp.ini
Return
ABOUT:
Gui,99:Destroy
Gui,99:Margin,20,20
Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
Gui,99:Font,W700
Gui,99:Add,Text,x+10 yp+10 Bold,%applicationname% v2.1
Gui,99:Font,W400
Gui,99:Add,Text,y+10,Sends user defined times and dates to the active window.
Gui,99:Add,Text,xp y+5,Doubleclick the tray icon to send the last used date and time.
Gui,99:Add,Text,y+10,Use the Settings menu to change the timestamps and hotkeys.
Gui,99:Add,Picture,xm y+20 G1HOURSOFTWARE Icon2,%applicationname%.exe
Gui,99:Add,Text,x+10 yp,For more tools, information and donations, please visit
Gui,99:Font,W700 CBlue
Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
Gui,99:Font,W400 CBlack
Gui,99:Add,Picture,xm y+20 GDONATIONCODER Icon7,%applicationname%.exe
Gui,99:Add,Text,x+10 yp,Please support the contributors at
Gui,99:Font,W700 CBlue
Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
Gui,99:Font,W400 CBlack
Gui,99:Add,Picture,xm y+20 GAUTOHOTKEY Icon6,%applicationname%.exe
Gui,99:Add,Text,x+10 yp,This tool was made using the powerful
Gui,99:Font,W700 CBlue
Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
Gui,99:Font,W400 CBlack
Gui,99:Show,,%applicationname% - About
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
Gui,99:+LastFound
aboutid:=WinExist()
Return
1HOURSOFTWARE:
Run,www.1HourSoftware.com
Return
DONATIONCODER:
Run,www.DonationCoder.com
Return
AUTOHOTKEY:
Run,www.AutoHotkey.com
Return
WM_MOUSEMOVE(wParam,lParam)
{
Global hCurs
Global aboutid
MouseGetPos,,,mwin,mctrl
If mwin in %aboutid%
If mctrl in Static8,Static11,Static14
DllCall("SetCursor","UInt",hCurs)
Return
}
99GuiEscape:
99GuiClose:
Gui,99:Destroy
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCurs)
Return
EXIT:
DllCall("DeregisterShellHookWindow",UInt,guiid)
ExitApp
INIFILE:
IfNotExist,%applicationname%.ini
FileAppend,
(
[Settings]
stamp1=H:mm:ss" - "dddd" "d.MM.yyy" - d"day" w"weeknl
hotkey1=F1
stamp2=yyy.MM.d" "tabH:mm:ss
hotkey2=F2
;TimeStamp.ini
;
;Hotkeys
;^=Ctrl !=Alt +=Shift #=Window
;
;Examples:
;
;^F1=Ctrl-F1
;+!j=Shift-Alt-j
;
;
;Formatting (case sensitive)
;
;nl NewLine
;tab Tab
; Surround regular text with ""
;
;Date Formats (case sensitive)
;
;d Day of the month without leading zero (1 - 31)
;dd Day of the month with leading zero (01 – 31)
;ddd Lowercase abbreviated name for the day of the week (e.g. mon)
;Ddd Like ddd, but Titlecase
;DDD Like ddd, but UPPERCASE
;dddd Lowercase full name for the day of the week (e.g. monday)
;Dddd Like ddd, but Titlecase
;DDDD Like ddd, but UPPERCASE
;M Month without leading zero (1 – 12)
;MM Month with leading zero (01 – 12)
;mmm Lowercase abbreviated month name (e.g. jan)
;Mmm Like mmm, but Titlecase
;MMM Like mmm, but UPPERCASE
;mmmm Full month name (e.g. january)
;Mmmm Like mmmm, but Titlecase
;MMMM Like mmmm, but UPPERCASE
;y Year without century, without leading zero (0 – 99)
;yy Year without century, with leading zero (00 - 99)
;yyyy Year with century. Example: 2005
;gg Period/era string for the current user's locale (blank if none)
;Day Day of the year
;Week Week of the year
;
;Time Formats (case sensitive)
;
;h Hours without leading zero; 12-hour format (1 - 12)
;hh Hours with leading zero; 12-hour format (01 – 12)
;H Hours without leading zero; 24-hour format (0 - 23)
;HH Hours with leading zero; 24-hour format (00– 23)
;m Minutes without leading zero (0 – 59)
;mm Minutes with leading zero (00 – 59)
;s Seconds without leading zero (0 – 59)
;ss Seconds with leading zero (00 – 59)
;t Single character time marker, such as A or P (depends on locale)
;tt Multi-character time marker, such as AM or PM (depends on locale)
;
;Examples:
;
;H:mm:ss" - "dddd" "d.MM.yyy" - d"day" w"week = 10:49:05 - saturday 14.06.2008 - d166 w24
;yyy.MM.d" "nlH:mm:ss = 2008.06.14
; 10:49:36
)
,%applicationname%.ini
Return