Skip to content

Commit d4e12bf

Browse files
committed
v1.112 Define alternative Paste shortcuts in INI
1 parent 06248d6 commit d4e12bf

File tree

6 files changed

+85
-19
lines changed

6 files changed

+85
-19
lines changed

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### v1.112
4+
5+
* New: Define alternative Paste shortcuts in PasteShortCuts.ini (e.g. Shift+Insert for console programs)
6+
37
### v1.111
48

59
* New: Limit entries in Yank entry sub-menu for valid history entries

cl3.ahk

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
33
Script : CL3 ( = CLCL CLone ) - AutoHotkey 1.1+
4-
Version : 1.111
4+
Version : 1.112
55
Author : hi5
66
Purpose : CL3 started as a lightweight clone of the CLCL clipboard caching utility
77
which can be found at http://www.nakka.com/soft/clcl/index_eng.html.
@@ -42,7 +42,7 @@ SetWorkingDir, %A_ScriptDir%
4242
AutoTrim, off
4343
StringCaseSense, On
4444
name:="CL3 "
45-
version:="v1.111"
45+
version:="v1.112"
4646
CycleFormat:=0
4747
Templates:={}
4848
Global CyclePlugins,History,SettingsObj,Slots,ClipChainData ; CyclePlugins v1.72+, others v1.9.4 for API access
@@ -60,7 +60,7 @@ loop, parse, iconlist, CSV
6060
icon%A_LoopField%:="icon-" A_LoopField ".ico"
6161

6262
; <for compiled scripts>
63-
;@Ahk2Exe-SetFileVersion 1.111
63+
;@Ahk2Exe-SetFileVersion 1.112
6464
;@Ahk2Exe-SetDescription CL3 Clipboard Manager
6565
;@Ahk2Exe-SetProductName CL3
6666
;@Ahk2Exe-SetProductVersion Compiled with AutoHotkey v%A_AhkVersion%
@@ -87,6 +87,7 @@ Suspend, Off
8787

8888
Settings()
8989
Settings_Hotkeys()
90+
Settings_PasteShortCuts()
9091
HistoryRules()
9192

9293
ahk_icons_path:=A_AhkPath
@@ -571,6 +572,7 @@ If ShowTemplates
571572
MenuAccelerator:=0
572573
Loop, parse, templatefolderFiles, |
573574
{
575+
FileEncoding, UTF-8
574576
FileRead, a, %TemplateFolder%%subtemplatefolder%\%A_LoopField%
575577
Templates[subtemplatefolder,A_Index]:=a
576578
if (Mod(MenuAccelerator,26)=0)
@@ -734,17 +736,32 @@ DispToolTipText(TextIn,Format=0,time=0)
734736

735737
PasteIt(source="")
736738
{
737-
global StartTime,PasteTime,ActiveWindowID,oldttext,ttext,ClipboardOwnerProcessName,ClipboardPrivate
739+
global StartTime,PasteTime,ActiveWindowID,oldttext,ttext,ClipboardOwnerProcessName,ClipboardPrivate,PasteShortCuts
740+
PasteKey:="^v"
738741
StartTime:=A_TickCount
739742
If ((StartTime - PasteTime) < 75) ; to prevent double paste after using #f/#v in combination
740743
Return
741744
;@Ahk2Exe-IgnoreBegin
742745
#Include *i %A_ScriptDir%\plugins\PastePrivateRules.ahk
743746
;@Ahk2Exe-IgnoreEnd
747+
744748
WinActivate, ahk_id %ActiveWindowID%
749+
WinGet, CurrentProcessName, ProcessName, A
750+
StringLower, CurrentProcessName, CurrentProcessName ; needed due to "StringCaseSense, On" set at startup
751+
752+
for k, v in PasteShortCuts
753+
{
754+
If CurrentProcessName in % v.programs
755+
PasteKey:=v.key
756+
}
757+
745758
If PasteDelay
746759
Sleep % PasteDelay
747-
Send ^v
760+
761+
If (PasteKey = "") or (PasteKey = "[SEND]")
762+
SendRaw % clipboard
763+
else
764+
Send % PasteKey
748765

749766
PasteTime := A_TickCount
750767
oldttext:="", ttext:="", ActiveWindowID:="",ClipboardOwnerProcessName:=""

lib/settings.ahk

+21
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,27 @@ Settings_Hotkeys()
296296
; Hotkey, %hk_notes%, off
297297
}
298298

299+
Settings_PasteShortCuts()
300+
{
301+
global PasteShortCuts:=[]
302+
i:=A_ScriptDir "\PasteShortCuts.ini"
303+
If !FileExist(i)
304+
Return
305+
IniRead, OutputVarSectionNames, %i%
306+
Loop, parse, OutputVarSectionNames, `n, `r
307+
{
308+
IniRead, OutputVarPrograms, %i%, %A_LoopField%, Programs, 0
309+
IniRead, OutputVarKey, %i%, %A_LoopField%, Key, 0
310+
StringLower, OutputVarPrograms, OutputVarPrograms ; needed due to "StringCaseSense, On" set at startup
311+
OutputVarPrograms:=Trim(RegExReplace(OutputVarPrograms,"ms)\s*,\s*",","),",") ; trim spaces between program names e.g. program.exe , anotherprogram.exe
312+
If OutputVarPrograms not in 0,error
313+
PasteShortCuts[A_LoopField,"programs"]:=OutputVarPrograms
314+
If OutputVarKey not in 0,Error
315+
PasteShortCuts[A_LoopField,"key"]:=Trim(OutputVarKey,Chr(34))
316+
OutputVarPrograms:="",OutputVarKey:=""
317+
}
318+
}
319+
299320
Settings_menu:
300321
#Include %A_ScriptDir%\lib\SettingsGui.ahk
301322

license.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 hi5 <https://github.com/hi5>
3+
Copyright (c) 2013-2025 hi5 <https://github.com/hi5>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

readme.md

+37-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# CL3 <sup>v1.111</sup> - Clipboard caching utility
1+
# CL3 <sup>v1.112</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>.
5-
But some unique [features](#features) have been added making it more versatile "text only" Clipboard manager.
5+
But some unique [features](#features) have been added making it a more versatile "text only" Clipboard manager.
66

7-
Intended for AutoHotkey Unicode (64-bit version of AutoHotkey is automatically Unicode).
7+
Intended for AutoHotkey Unicode (the 64-bit version of AutoHotkey is automatically Unicode).
88

9-
💡 Relies standard copy/paste shortcuts for the applications you are using, so <kbd>Ctrl</kbd>+<kbd>c</kbd> and <kbd>Ctrl</kbd>+<kbd>v</kbd>, and right click "copy" via mouse actions.
10-
Programs that rely on other shortcuts to store/restore clipboard contents may not work (e.g. vim).
9+
💡 Relies on standard copy/paste shortcuts for the applications you are using, so <kbd>Ctrl</kbd>+<kbd>c</kbd> and <kbd>Ctrl</kbd>+<kbd>v</kbd>, and right click "copy" via mouse actions.
10+
Programs that rely on other shortcuts to store and restore clipboard contents may not work (e.g. vim).
1111

1212
💬 Forum thread [https://autohotkey.com/boards/viewtopic.php?f=6&t=814](https://autohotkey.com/boards/viewtopic.php?f=6&t=814)
1313

@@ -62,11 +62,11 @@ _CL3 gets its name from CLCL CLone = CL3_
6262
- Limited history (18 items+26 items in secondary menu, does remember more entries in XML history file)
6363
- Search history (v1.2+)
6464
- 10 Slots with options to save/load several sets (v1.2+)
65-
- Cycle through clipboard - forwards and backwards - with tooltip preview (v1.3+). Cycle through plugins (v1.8+)
65+
- Cycle through the clipboard history - forwards and backwards - with tooltip preview (v1.3+). Cycle through plugins (v1.8+)
6666
- ClipChain with preview GUI, paste items in predefined order, save/load several sets (v1.5+) [Wiki](https://github.com/hi5/CL3/wiki/ClipChain)
6767
- Supports FIFO (first in first out) pasting (v1.7) [#3](https://github.com/hi5/CL3/issues/3)
6868
- Remove (yank) entries from history
69-
- No duplicate entries in clipboard (automatically removed)
69+
- No duplicate entries in the clipboard history (automatically removed)
7070
- Templates: simply text files which are read at start up
7171
- Plugins: AutoHotkey functions (scripts) defined in separate files
7272

@@ -156,7 +156,7 @@ The text file will be placed in the CL3 script folder.
156156

157157
You can use the AutoReplace plugin to modify the text in the clipboard using a find/replace rule before adding
158158
it to the history. You can use StringReplace or a Regular Expression. Settings are stored in _AutoReplace.xml_
159-
**Note: very experimental plugin. The plugin interface (GUI) needs to refined, entire process should be improved.
159+
**Note: very experimental plugin. The plugin interface (GUI) needs to be refined, entire process should be improved.
160160
A Listview would be more logical and flexible. But for now it does the job, albeit crudely.**
161161

162162
Feedback available via "Tray Tip" - see settings.
@@ -206,7 +206,7 @@ d. 1
206206

207207
If you start FIFO at 'D' pressing <kbd>Ctrl</kbd>+<kbd>v</kbd> four times will paste 1, 2, 3, 4.
208208
After pasting the last (here fourth) item, FIFO stops.
209-
TrayTips will appear at the start and stop of a FIFO cycle.
209+
TrayTips will appear at the start and end of a FIFO cycle.
210210

211211
### Sort [v1.94+]
212212

@@ -217,7 +217,7 @@ See [Sort](https://www.autohotkey.com/docs/commands/Sort.htm) documentation for
217217

218218
If you select the yank option in the menu you will be presented with a
219219
simple **a** to **r** menu to indicate which of the most recent items you wish to
220-
delete.
220+
delete. To delete the entire history select "Clear History" (v1.111+)
221221

222222
## Cycle through clipboard history [v1.3+]
223223

@@ -258,8 +258,8 @@ Some ideas for further development you may wish to consider:
258258
- ~~Extending the number of menu entries in the secondary menu ("more history")~~ _v1.100+_
259259
- Include rich text formats
260260
- Include images - rough guide to add it (very alpha) here https://www.autohotkey.com/boards/viewtopic.php?p=314319#p314319
261-
- Introduce various paste methods, also for specific programs
262-
for example send each character individually
261+
- ~~Introduce various paste methods, also for specific programs?
262+
for example send each character individually~~ _v1.112+_
263263
- More (default) plugins:
264264
- Improved title case (various scripts are available which could replace the current basic one)
265265
- Strip HTML
@@ -343,7 +343,7 @@ Apart from plugins, `plugins\MyPlugins.ahk` is also a useful method to add addit
343343

344344
1. Copy or Cut and Append to clipboard
345345

346-
Some text editors already offer this functionality, but you make it available everywhere using CL3.
346+
Some text editors already offer this functionality, but you can make it available everywhere using CL3.
347347
Add the following code for copy and/or cut to `plugins\MyPlugins.ahk`
348348

349349
```autohotkey
@@ -415,11 +415,35 @@ Return
415415
Add an optional include file that "does something" before it actually pastes.
416416
The file is not present in the repository and a new file has to be created in `cl3\plugins\` with the name `PastePrivateRules.ahk`
417417

418+
Examples:
419+
418420
* Pasting file(s) from CL3 history https://www.autohotkey.com/boards/viewtopic.php?p=314316#p314316 using `ClipboardSetFiles()` and `If WinActive()`
419421
* Append to File name in "Open/Save as" dialogs - https://github.com/hi5/CL3/issues/14
422+
* Paste in putty.exe (as of v1.112 can be care of using PasteShortCuts.ini) - https://github.com/hi5/CL3/issues/27
420423

421424
Note: your `PastePrivateRules.ahk` will never be part of this GitHub repository so anything you add won't be overwritten if you update CL3 in the future.
422425

426+
# PasteShortCuts.ini
427+
428+
Note: a default setup can be found in `res\PasteShortCuts.ini` (online [here](https://github.com/hi5/CL3/blob/master/res/PasteShortCuts.ini)) - copy the file to the CL3 folder and restart CL3.
429+
430+
To setup CL3 for programs where you don't want to use the standard Windows shortcut (Ctrl+v) to paste
431+
create or edit `PasteShortCuts.ini` in the CL3 program folder. Details below and in the ini file as well.
432+
433+
```ini
434+
[SectionName] - Create a section (any name)
435+
Programs= CSV list of program executables
436+
Key= Use AHK notation (^=ctrl +=shift !=alt), if KEY is empty or "[SEND]" (no quotes)
437+
CL3 will use SendRaw to send the clipboard to the application - results may vary
438+
```
439+
Terminal programs often prefer <kbd>Shift</kbd>+<kbd>Insert</kbd> (`+{Ins}`) as Paste shortcut
440+
441+
Using `PastePrivateRules.ahk` is another option, see examples listed above.
442+
443+
# Experimental
444+
445+
* [HistoryRules](https://github.com/hi5/CL3/blob/master/docs/HistoryRules.md) to allow CL3 to filter clipboard content before adding it to history, allowing or skipping text.
446+
423447
# Changelog
424448

425449
The changelog is available here: [changelog.md](changelog.md)

res/PasteShortCuts.ini

1.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)