Skip to content

Commit 6836c9d

Browse files
committed
v1.107 timestamp option, use TC commander_path, use MenuWidth
1 parent 74a75a7 commit 6836c9d

File tree

9 files changed

+101
-39
lines changed

9 files changed

+101
-39
lines changed

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
### v1.107
4+
5+
* New: Option to show timestamp in clipboard history menu - https://github.com/hi5/CL3/issues/23
6+
See https://www.autohotkey.com/docs/v1/lib/FormatTime.htm#Time_Formats for options (e.g. HH:mm (24hr) or hh:mm tt (12hr AM/PM))
7+
* Fix: Open Template folder - now use commander_path env. variable/registry combined with WinGet ProcessPath/ProcessName, so it should now work with running 32/64 versions. Starts 32bit by default if TC is not running but can be detected.
8+
* Fix: Use MenuWidth setting in DispMenuText() function to check length instead of previously hardcoded value of 60
9+
310
### v1.106
411

512
* Fix: correct path for compiled script (to executable) for tray menu icons

cl3.ahk

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
33
Script : CL3 ( = CLCL CLone ) - AutoHotkey 1.1+ (Ansi and Unicode)
4-
Version : 1.106
4+
Version : 1.107
55
Author : hi5
66
Purpose : A lightweight clone of the CLCL clipboard caching utility which can be found at
77
http://www.nakka.com/soft/clcl/index_eng.html written in AutoHotkey
@@ -40,7 +40,7 @@ SetWorkingDir, %A_ScriptDir%
4040
AutoTrim, off
4141
StringCaseSense, On
4242
name:="CL3 "
43-
version:="v1.106"
43+
version:="v1.107"
4444
CycleFormat:=0
4545
Templates:={}
4646
Global CyclePlugins,History,SettingsObj,Slots,ClipChainData ; CyclePlugins v1.72+, others v1.9.4 for API access
@@ -58,7 +58,7 @@ loop, parse, iconlist, CSV
5858
icon%A_LoopField%:="icon-" A_LoopField ".ico"
5959

6060
; <for compiled scripts>
61-
;@Ahk2Exe-SetFileVersion 1.106
61+
;@Ahk2Exe-SetFileVersion 1.107
6262
;@Ahk2Exe-SetDescription CL3
6363
;@Ahk2Exe-SetCopyright MIT License - (c) https://github.com/hi5
6464
; </for compiled scripts>
@@ -452,7 +452,7 @@ for k, v in History
452452
icon:="res\" iconA
453453
If (A_Index=1) and (ClipboardPrivate = 1) ; indicate to user clipboard has different data as first entry in history (excluded programs)
454454
Indicator:="*"
455-
key:=% "&" Chr(96+A_Index) Indicator ". " DispMenuText(SubStr(text,1,500),lines)
455+
key:=% "&" Chr(96+A_Index) Indicator ". " DispMenuText(SubStr(text,1,500),lines,v.time)
456456
Menu, ClipMenu, Add, %key%, MenuHandler
457457
if (k = 1)
458458
Menu, ClipMenu, Default, %key%
@@ -597,9 +597,9 @@ If (History.MaxIndex() > 20)
597597
Continue
598598

599599
If (MenuAccelerator < 27) and (MenuAcceleratorDone = 0)
600-
key:=% "&" Chr(96+(++MenuAccelerator)) ". " DispMenuText(SubStr(text,1,500),lines)
600+
key:=% "&" Chr(96+(++MenuAccelerator)) ". " DispMenuText(SubStr(text,1,500),lines,v.time)
601601
If (MenuAcceleratorDone = 1)
602-
key:=% " " DispMenuText(SubStr(text,1,500),lines)
602+
key:=% " " DispMenuText(SubStr(text,1,500),lines,v.time)
603603
Menu, SubMenu4, Add, %key%, MenuHandler
604604
Try
605605
Menu, SubMenu4, Icon, %key%, % icon
@@ -646,26 +646,41 @@ If ShowExit
646646
}
647647
Return
648648

649-
DispMenuText(TextIn,lines="1")
649+
DispMenuText(TextIn,lines="1",time="")
650650
{
651-
global MenuWidth,ShowLines,LineTextFormat
651+
global MenuWidth,ShowLines,LineTextFormat,ShowTime,TimeFormat
652+
652653
If (lines=1)
653654
linetext:=LineTextFormat[1]
654655
else
655656
linetext:=LineTextFormat[2]
656657
If (lines = -1)
657658
linetext:=""
659+
658660
TextOut:=RegExReplace(TextIn,"m)^\s*")
659661
TextOut:=RegExReplace(TextOut, "\s+", " ")
660662
StringReplace, TextOut, TextOut, &amp;amp;, &, All
661663
StringReplace, TextOut, TextOut, &, &&, All
662-
If StrLen(TextOut) > 60
664+
665+
If StrLen(TextOut) > MenuWidth
663666
{
664667
TextOut:=SubStr(TextOut,1,MenuWidth) " " Chr(8230) " " SubStr(RTrim(TextOut,".`n"),-10) ; 8230 ...
665668
}
666669
TextOut .= " " Chr(171)
670+
667671
If ShowLines
668-
TextOut .= StrReplace(linetext,"\l",lines)
672+
TextOut .= StrReplace(linetext,"\l",lines)
673+
674+
If ShowTime
675+
{
676+
disptime:=""
677+
If TimeFormat and Time
678+
{
679+
FormatTime, disptime, %time%, %TimeFormat%
680+
TextOut .= " " Chr(128336) " " disptime
681+
}
682+
}
683+
669684
Return LTRIM(TextOut," `t")
670685
}
671686

@@ -783,11 +798,32 @@ Return
783798
TemplateMenuHandler:
784799
If (A_ThisMenuItem = "&0. Open templates folder")
785800
{
786-
IfWinExist, ahk_exe TOTALCMD.EXE
787-
Run, c:\totalcmd\TOTALCMD.EXE /O /T %TemplateFolder%
788-
else
789-
Run, %TemplateFolder%
801+
802+
; try to get Commander_Path, it will be empty if TC is not running (yet)
803+
EnvGet, Commander_Path, Commander_Path
804+
805+
If (Commander_Path = "") ; try to read registry
806+
RegRead Commander_Path, HKEY_CURRENT_USER, Software\Ghisler\Total Commander, InstallDir
807+
808+
WinGet TCName, ProcessName, ahk_class TTOTAL_CMD
809+
If (Commander_Path = "")
810+
WinGet TCPath, ProcessPath, ahk_exe %TCName%
811+
812+
If (TCPath = "") and (Commander_Path <> "")
813+
TCPath:=Commander_Path "\TOTALCMD.EXE"
814+
815+
If (TCPath = "") and (Commander_Path = "")
816+
{
817+
Run, %TemplateFolder%
818+
Return
819+
}
820+
Try
821+
{
822+
If FileExist(TCPath)
823+
Run, %TCPath% /O /T %TemplateFolder%
824+
}
790825
Return
826+
791827
}
792828

793829
ClipText:=Templates[A_ThisMenu,A_ThisMenuItemPos]
@@ -815,7 +851,7 @@ If (ClipText <> Clipboard)
815851
crc:=History[MenuItemPos,"crc"]
816852
else
817853
crc:=crc32(ClipText)
818-
History.Insert(1,{"text":ClipText,"icon": IconExe,"lines": Count+1,"crc":crc})
854+
History.Insert(1,{"text":ClipText,"icon": IconExe,"lines": Count+1,"crc":crc,"time":A_Now})
819855
}
820856
OnClipboardChange("FuncOnClipboardChange", 0)
821857
Clipboard:=ClipText
@@ -860,7 +896,7 @@ If CopyDelay
860896

861897
WinGet, IconExe, ProcessPath , A
862898
If ((History.MaxIndex() = 0) or (History.MaxIndex() = "")) ; just make sure we have the History Object and add "some" text
863-
History.Insert(1,{"text":"Text","icon": IconExe,"lines": 1})
899+
History.Insert(1,{"text":"Text","icon": IconExe,"lines": 1,"time":A_Now})
864900

865901
History_Save:=1
866902

@@ -927,7 +963,7 @@ StrReplace(ClipText, "`n", "`n", Count)
927963

928964
crc:=crc32(ClipText)
929965

930-
History.Insert(1,{"text":ClipText,"icon": IconExe,"lines": Count+1,"crc":crc})
966+
History.Insert(1,{"text":ClipText,"icon": IconExe,"lines": Count+1,"crc":crc,"time":A_Now})
931967

932968
If !AllowDupes
933969
Gosub, CheckHistory
@@ -950,7 +986,7 @@ for k, v in History
950986
if !CurrentCRC ; just to make sure it isn't empty
951987
CurrentCRC:=crc32(v.text)
952988
if !InStr(HaveCRCList, "|" CurrentCRC "|")
953-
newhistory.push({"text":v.text,"icon":v.icon,"lines":v.lines,"crc":CurrentCRC})
989+
newhistory.push({"text":v.text,"icon":v.icon,"lines":v.lines,"crc":CurrentCRC,"time":v.time})
954990
HaveCRCList .= v.crc "|"
955991
if (k >= MaxHistory)
956992
break

docs/ccmdr.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ Example:
7474

7575
`s5` will make the current clipboard contents the 5th slot, you can paste this with <kbd>Right Control</kbd>+<kbd>5</kbd> - see Slots in the docs
7676

77+
`sNAME` can also be used, this will make the `NAME` appear in the SlotsMenu (see settings to define hotkey)
78+
7779
### B
7880

7981
b : "Burst separator (\n, \t, \\, char or word)"

lib/cl3apiclass.ahk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ class CL3API
134134
If !Reverse
135135
{
136136
StrReplace(Data[A_Index],"`n","`n",Count)
137-
History.Insert(1,{"text": Data[A_Index],"IconExe":"","lines":Count+1})
137+
History.Insert(1,{"text": Data[A_Index],"IconExe":"","lines":Count+1,"time":A_Now})
138138
}
139139
else
140140
{
141141
StrReplace(Data[A_Index],"`n","`n",Count)
142-
History.Insert(1,{"text": Data[Data.count()+1-A_Index],"IconExe":"","lines":Count+1})
142+
History.Insert(1,{"text": Data[Data.count()+1-A_Index],"IconExe":"","lines":Count+1,"time":A_Now})
143143
}
144144
}
145145
return 1
@@ -182,7 +182,7 @@ class CL3API
182182
InsertAt(Idx,Data)
183183
{
184184
StrReplace(Data,"`n","`n",Count)
185-
History.InsertAt(Idx,{"text":Data,"IconExe":"","lines":Count+1})
185+
History.InsertAt(Idx,{"text":Data,"IconExe":"","lines":Count+1,"time":A_Now})
186186
History_Save:=1
187187
return 1
188188
}

lib/settings.ahk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Settings()
2525
IniRead, SearchWindowWidth , %ini%, settings, SearchWindowWidth, 595
2626
IniRead, SearchWindowHeight , %ini%, settings, SearchWindowHeight, 300
2727
IniRead, ShowLines , %ini%, settings, ShowLines, 0
28+
IniRead, ShowTime , %ini%, settings, ShowTime, 0
2829
IniRead, AutoReplaceTrayTip , %ini%, settings, AutoReplaceTrayTip, 0
2930
IniRead, CopyDelay , %ini%, settings, CopyDelay, 0
3031
IniRead, PasteDelay , %ini%, settings, PasteDelay, 50
@@ -33,6 +34,7 @@ Settings()
3334
IniRead, BackupTimer , %ini%, settings, BackupTimer, 10
3435
IniRead, Exclude , %ini%, settings, Exclude, 0
3536
IniRead, LineFormat , %ini%, settings, LineFormat, \t(\l line),\t(\l lines)
37+
IniRead, TimeFormat , %ini%, settings, TimeFormat, HH:mm
3638
IniRead, SettingsFolders , %ini%, settings, SettingsFolders, 0
3739
IniRead, ShowSpecial , %ini%, settings, ShowSpecial , 1
3840
IniRead, ShowTemplates , %ini%, settings, ShowTemplates, 1
@@ -125,6 +127,7 @@ Settings_Default()
125127
, SearchWindowHeight: 300
126128
, ActivateApi : 0
127129
, ShowLines : 1
130+
, ShowTime : 0
128131
, AutoReplaceTrayTip: 0
129132
, CopyDelay : 0
130133
, PasteDelay : 50
@@ -134,6 +137,7 @@ Settings_Default()
134137
, ShowMorehistory : 1
135138
, ShowExit : 1
136139
, Exclude : ""
140+
, TimeFormat : "HH:mm"
137141
, LineFormat : "\t(\l line),\t(\l lines)" }
138142
}
139143

lib/settingsGui.ahk

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Gui Settings:Add, Edit, xp+40 yp-3 w40 h20 vhk_slot0, % hk_slot0
6868
Gui Settings:Add, Text, xp-40 yp+27 , Menu:
6969
Gui Settings:Add, Edit, xp+40 yp-3 w40 h20 vhk_slotsmenu , %hk_slotsmenu%
7070

71-
Gui Settings:Add, GroupBox, xp+60 y20 w130 h320 , Other
71+
Gui Settings:Add, GroupBox, xp+60 y20 w130 h320 , Other
7272
Gui Settings:Add, Text, xp+8 yp+24 , Max History:
7373
Gui Settings:Add, Edit, xp+70 yp-3 w40 h20 vMaxHistory Number , %MaxHistory%
7474
Gui Settings:Add, Text, xp-70 yp+25 , Menu width:
@@ -89,7 +89,7 @@ Gui Settings:Add, Text, xp yp+20 , CycleP
8989
Gosub, UpdateCyclePlugins
9090
Gui Settings:Add, Edit, xp-5 yp+15 w125 R5 vEditCyclePlugins , %EditCyclePlugins%
9191

92-
Gui Settings:Add, GroupBox, x5 yp+88 w278 h55 , Exclude programs (CSV: program1.exe,prg2.exe)
92+
Gui Settings:Add, GroupBox, x5 yp+88 w278 h55 , Exclude programs (CSV: program1.exe,prg2.exe)
9393

9494
Gui Settings:Add, Edit, xp+8 yp+20 w260 h20 vExclude , %Exclude%
9595

@@ -109,26 +109,33 @@ Gui Settings:Add, Button, xp+159 yp w100 h25 gSettingsGuiEscape, &Cancel
109109

110110
Gui Settings:Add, GroupBox, xp+110 y20 w100 h412 , Special
111111
Gui Settings:Add, Checkbox, xp+8 yp+24 vActivateApi , Activate API
112-
Gui Settings:Add, Checkbox, xp yp+30 vActivateCmdr , ccmdr plugin
112+
113+
Gui Settings:Add, Checkbox, xp yp+25 vActivateCmdr , ccmdr plugin
113114
Gui Settings:Add, Edit , xp+20 yp+15 w60 h20 vhk_cmdr , %hk_cmdr%
114-
Gui Settings:Add, Checkbox, xp-20 yp+30 vActivateNotes , notes plugin
115+
116+
Gui Settings:Add, Checkbox, xp-20 yp+25 vActivateNotes , notes plugin
115117
Gui Settings:Add, Edit , xp+20 yp+15 w60 h20 vhk_notes , %hk_notes%
116-
Gui Settings:Add, Checkbox, xp-20 yp+30 vActivateBackup , Auto Backup
118+
119+
Gui Settings:Add, Checkbox, xp-20 yp+25 vActivateBackup , Auto Backup
117120
Gui Settings:Add, Edit , xp+20 yp+15 w60 h20 vBackupTimer Number, %BackupTimer%
118-
Gui Settings:Add, Checkbox, xp-20 yp+25 vShowLines , Show lines
119121

122+
Gui Settings:Add, Checkbox, xp-20 yp+25 vShowLines , Show lines
120123
LineFormat:=StrReplace(LineFormat,A_Tab,"\t")
121124
Gui Settings:Add, Edit , xp+20 yp+15 w60 h20 vLineFormat , %LineFormat%
122-
Gui Settings:Add, Checkbox, xp-20 yp+30 vAutoReplaceTrayTip , AutoRepl. TT
125+
126+
Gui Settings:Add, Checkbox, xp-20 yp+25 vShowTime , Show time
127+
Gui Settings:Add, Edit , xp+20 yp+15 w60 h20 vTimeFormat , %TimeFormat%
128+
129+
Gui Settings:Add, Checkbox, xp-20 yp+24 vAutoReplaceTrayTip , AutoRepl. TT
123130
Gui Settings:Add, Text , xp yp+25 , Clipchain HK:
124-
Gui Settings:Add, Edit , xp yp+20 w80 vhk_ClipChainPaste , %hk_ClipChainPaste%
125-
Gui Settings:Add, Text , xp yp+30 , Bypass AutoRepl.`npaste [1st entry]:
126-
Gui Settings:Add, Edit , xp yp+30 w80 vhk_BypassAutoReplace, %hk_BypassAutoReplace%
127-
Gui Settings:Add, Text , xp yp+30 , Clipb. delay (ms)
131+
Gui Settings:Add, Edit , xp yp+15 w80 vhk_ClipChainPaste , %hk_ClipChainPaste%
132+
Gui Settings:Add, Text , xp yp+25 , Bypass AutoRepl.`npaste [1st entry]:
133+
Gui Settings:Add, Edit , xp yp+25 w80 vhk_BypassAutoReplace, %hk_BypassAutoReplace%
134+
Gui Settings:Add, Text , xp yp+25 , Clipb. delay (ms)
128135
Gui Settings:Font, cRed
129136
Gui Settings:Add, Text , xp+80 yp gModHelp2 , ?
130137
Gui Settings:Font, cBlack
131-
Gui Settings:Add, Edit , xp-80 yp+20 w35 Number vCopyDelay , %CopyDelay%
138+
Gui Settings:Add, Edit , xp-80 yp+18 w35 Number vCopyDelay , %CopyDelay%
132139
Gui Settings:Add, Edit , xp+45 yp w35 Number vPasteDelay , %PasteDelay%
133140

134141
If AllowDupes
@@ -143,6 +150,8 @@ If ActivateBackup
143150
GuiControl,, ActivateBackup, 1
144151
If ShowLines
145152
GuiControl,, ShowLines, 1
153+
If ShowTime
154+
GuiControl,, ShowTime, 1
146155
If AutoReplaceTrayTip
147156
GuiControl,, AutoReplaceTrayTip, 1
148157

@@ -230,6 +239,7 @@ IniWrite, %ActivateApi% , %ini%, Settings, ActivateApi
230239
IniWrite, %ActivateBackup% , %ini%, settings, ActivateBackup
231240
IniWrite, %BackupTimer% , %ini%, settings, BackupTimer
232241
IniWrite, %ShowLines% , %ini%, Settings, ShowLines
242+
IniWrite, %ShowTime% , %ini%, Settings, ShowTime
233243
IniWrite, %AutoReplaceTrayTip% , %ini%, Settings, AutoReplaceTrayTip
234244
IniWrite, %CopyDelay% , %ini%, Settings, CopyDelay
235245
IniWrite, %PasteDelay% , %ini%, Settings, PasteDelay
@@ -243,11 +253,11 @@ IniWrite, %ShowExit% , %ini%, Settings, ShowExit
243253

244254
LineFormat:=StrReplace(LineFormat,A_Tab,"\t")
245255
IniWrite, %LineFormat% , %ini%, settings, LineFormat
256+
IniWrite, %TimeFormat% , %ini%, settings, TimeFormat
246257

247258
IniWrite, %ActivateNotes% , %ini%, Plugins, ActivateNotes
248259
IniWrite, %ActivateCmdr% , %ini%, Plugins, ActivateCmdr
249260

250-
251261
Sleep 100
252262
Reload ; if hotkey(s) have changed we'd need to deactivate/reactive all hotkeys, reloading saves us the trouble
253263

plugins/ccmdr.ahk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Command(cmd)
189189
if cmd is number
190190
{
191191
StrReplace(Clipboard,"`n","`n",Count)
192-
History.InsertAt(cmd,{"text": clipboard,"icon": "","lines": Count+1})
192+
History.InsertAt(cmd,{"text": clipboard,"icon": "","lines": Count+1,"time":A_Now})
193193
History.Remove(1)
194194
OnClipboardChange("FuncOnClipboardChange", 0)
195195
Clipboard:=History[1].text
@@ -366,12 +366,12 @@ Command(cmd)
366366
If !Reverse
367367
{
368368
StrReplace(Burst[A_Index],"`n","`n",Count)
369-
History.Insert(1,{"text": Burst[A_Index],"IconExe": "","lines": Count+1})
369+
History.Insert(1,{"text": Burst[A_Index],"IconExe": "","lines": Count+1,"time":A_Now})
370370
}
371371
else
372372
{
373373
StrReplace(Burst[A_Index],"`n","`n",Count)
374-
History.Insert(1,{"text": Burst[burst.count()+1-A_Index],"IconExe": "","lines": Count+1})
374+
History.Insert(1,{"text": Burst[burst.count()+1-A_Index],"IconExe": "","lines": Count+1,"time":A_Now})
375375
}
376376
}
377377
burst:=""

plugins/search.ahk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ OnClipboardChange("FuncOnClipboardChange", 1)
9898
StrReplace(ClipText, "`n", "`n", Count)
9999
History[id,"lines"]:=Count+1
100100
History[id,"crc"]:=crc32(ClipText)
101+
History[id,"time"]:=A_Now
101102
ClipText:=""
102103
ChooseID:=ID
103104
id:=""
@@ -132,7 +133,7 @@ Loop, parse, choice, |
132133
Loop, parse, Removeids, CSV
133134
History.Remove(A_LoopField)
134135
StrReplace(CliptText,"`n","`n",Count)
135-
History.Insert(1,{"text":ClipText,"icon": "res\" iconA, "lines": Count+1 })
136+
History.Insert(1,{"text":ClipText,"icon": "res\" iconA, "lines": Count+1,"time":A_Now})
136137
Gosub, CheckHistory
137138
ClipText:="",Removeids:=""
138139
Return

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CL3 <sup>v1.106</sup> - Clipboard caching utility
1+
# CL3 <sup>v1.107</sup> - Clipboard caching utility
22

33
CL3 started as a lightweight clone of the CLCL clipboard caching utility
44
which can be found at <http://www.nakka.com/soft/clcl/index_eng.html>.
@@ -353,6 +353,7 @@ crc:=crc32(ClipText)
353353
History[1,"text"]:=ClipText
354354
History[1,"lines"]:=Count+1,
355355
History[1,"crc"]:=crc
356+
History[1,"time"]:=A_Now
356357
Clipboard:=ClipText
357358
Sleep, 100
358359
ClipText:="",Count:="",crc:=""
@@ -370,6 +371,7 @@ crc:=crc32(ClipText)
370371
History[1,"text"]:=ClipText
371372
History[1,"lines"]:=Count+1,
372373
History[1,"crc"]:=crc
374+
History[1,"time"]:=A_Now
373375
Clipboard:=ClipText
374376
Sleep, 100
375377
ClipText:="",Count:="",crc:=""

0 commit comments

Comments
 (0)