TimeStamper onto clipboard for fast file/note tagging

Post your working scripts, libraries and tools for AHK v1.1 and older
studleylee
Posts: 5
Joined: 27 Feb 2015, 13:00

TimeStamper onto clipboard for fast file/note tagging

Post by studleylee » 09 Mar 2023, 17:28

This is a simple TimeStamper utility I made to help tag filenames or notes with a current timestamp while in a SaveAs dialog or anywhere.

Once you run the script, the dialog comes up with the current timestamp in the edit area and automatically placed on the clipboard.
You can leave the dialog open while you work and by hitting the refresh button, the timestamp will be refreshed and copied onto the clipboard
for pasting into any app or dialog. The edit area adds new stamps by appending a new line at the bottom so history can be kept if needed.
There's also a clear button to clear the edit area.

The bottom dropdown allows for different formats to used. The code can be edited easily to add your own styles.
BR, Lee Studley

Code: Select all


; 20221229152524 : 2022-12-29-15-25 v1  Hacked "OpenWindowList5.ahk"
; to be TimeStamp to editwindow, selected,
; so can ctrl-c to clipboard
; for paste into a filename when using SaveAs dialogs etc in any app.
; _2023-01-03-11-55-31_ v1-a added format choice dropdownlist.fixed clearing.
; _20230104135940_ v1-b added new format "text": _2023-Jan-Wed-15-39-39_
; _20230104135940_ v1-c fixed and added new format "text": _2023-Jan-Wed-15-39-39_20230104153939

; NOTE: Calling the AltTab_window_list() function makes an array of window IDs:
; AltTab_ID_List_0 = the number of windows found
; AltTab_ID_List_1 to AltTab_ID_List_%AltTab_ID_List_0% contain the window IDs.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
Gui, New , , TimeStamper v1.c
Gui, Add, Edit, r30 w450 vEditSumString,
Gui, Add, Button,default,&Refresh ; The label  (if it exists) will be run when the button is pressed.
Gui, Add, Button,default,&Clear   ; The label  (if it exists) will be run when the button is pressed.
Gui, Add, DropDownList, vFormatChoice, text|_yyyy-MM-dd-HH-mm-ss_|_yyyyMMddHHmmss_||_yyyyMMdd-HH-mm-ss_|_yyyyMMdd-HHmmss_

; notepad++ ctrl+1= 1st tab, ctrl+shft+pgdn=next tab...
; hippoedit alt+left=next alt+right=next
;   # Win (Windows logo key)
;   ! Alt
;   ^ Control
;   + Shift
;   & An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey.
;

;f_Hotkey = ~MButton
; old f_Hotkey =  ^+o   ;control:shift:o
;f_Hotkey =    !+o   ;alt:shift:o   note:better common pattern on laptop and desktop
;f_Hotkey_alt =  !+o   ;alt:shift:o


BacktoTop:

;Get format and current local time, parse it, store lt in variables for the GUI Time
Gui, Submit, NoHide

FormatChoiceStr = %FormatChoice%

CDateDense =

if ( FormatChoice == "text") {
	FormatTime, CDateDense,,_yyyyMMddHHmmss_
	FormatChoiceStr = _yyyy-MMM-ddd-HH-mm-ss
}
FormatTime, CDate,,%FormatChoiceStr%

;FormatTime, CDate,,_yyyyMMdd-HHmmss_       ;_20221229-16-06-22_
;FormatTime, CDate,,_yyyy-MM-dd-HH-mm-ss_   ;_2022-12-29-16-22_
;FormatTime, CDate,,_yyyyMMddHHmmss_        ;_20221229160622_
;FormatTime, CDate,,_yyyy-MMM-ddd-HH-mm-ss_ ;_2023-Jan-Wed-13-56-51_

Loop, parse, CDate, -,
{
	if A_Index = 1
		CYear=%A_LoopField%
	else if A_Index = 2
		CMonth=%A_LoopField%
	else if A_Index = 3
		CDay=%A_LoopField%
	else if A_Index = 4
		CHour=%A_LoopField%
	else if A_Index = 5
		CMin=%A_Loopfield%
    else
		CSec=%A_Loopfield%
}

Loop, parse, CDateDense, -,
{
	if A_Index = 1
		CYear=%A_LoopField%
	else if A_Index = 2
		CMonth=%A_LoopField%
	else if A_Index = 3
		CDay=%A_LoopField%
	else if A_Index = 4
		CHour=%A_LoopField%
	else if A_Index = 5
		CMin=%A_Loopfield%
    else
		CSec=%A_Loopfield%
}



;SumString = %A_Now%  ;formateed as:  20221229152524
SumString = %SumString%`n%CDate%%CDateDense%
Clipboard = %CDate%%CDateDense%

GuiControl,, EditSumString, %SumString%
;LV_ModifyCol()  ; Auto-size each column to fit its contents.
Gui, Show, AutoSize Center
return

GuiClose:
Exitapp

ButtonRefresh:
goto BacktoTop

ButtonClear:
EditSumString =
SumString =
Clipboard =
goto BacktoTop

~*Esc::
ExitApp

[Mod edit: Topic moved to appropriate AHK v1 section]
Attachments
TimeStamper_v1c_20230104154151_ .zip
(1.48 KiB) Downloaded 22 times
image.png
image.png (60.99 KiB) Viewed 303 times

Return to “Scripts and Functions (v1)”