Last active
August 22, 2024 05:24
-
-
Save davebrny/1d1cf0b3041b031ce06bfe44a10cd289 to your computer and use it in GitHub Desktop.
π (autohotkey) - microscopic clipboard manager (text only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#noEnv | |
#singleInstance, force | |
history := [] | |
history_total = 20 | |
truncate = 65 | |
return ; end of auto-execute | |
$^c:: ; add to clipboard history | |
$^x:: | |
clipboard := "" | |
send % "^{" . trim(a_thisHotkey, "$^") . "}" | |
clipWait, 0.3 | |
if (clipboard) | |
{ | |
for index, value in history | |
if (value = clipboard) ; if already in history | |
history.removeAt(index) | |
history.insertAt(1, clipboard) | |
if (history.maxIndex() > history_total) | |
history.pop() | |
} | |
return | |
#c:: ; add to clipboard but not history | |
#x:: | |
send % "^{" . trim(a_thisHotkey, "#") . "}" | |
return | |
#v:: ; show clipboard history | |
loop, % history.maxIndex() { | |
menu_item := strReplace(history[a_index], "`n", " ``n ", line_count) | |
line_number := (line_count) ? (a_tab "[" (line_count + 1) " lines]") : ("") | |
if (strLen(menu_item) > truncate) | |
menu_item := subStr(menu_item, 1, (truncate // 2)) " . . . . " subStr(menu_item, -(truncate // 2)) | |
menu, tiny_clipboard, add, % menu_item . line_number, history_select | |
} | |
menu, tiny_clipboard, useErrorLevel | |
menu, tiny_clipboard, show | |
menu, tiny_clipboard, delete | |
return | |
history_select: | |
if getKeyState("ctrl", "p") | |
history.removeAt(a_thisMenuItemPos) ; remove from history | |
else { | |
clipboard := history[a_thisMenuItemPos] | |
send ^{v} | |
} | |
return | |
/* | |
[script info] | |
version = 1.4.2 | |
description = microscopic clipboard manager | |
author = davebrny | |
source = https://gist.github.com/davebrny/1d1cf0b3041b031ce06bfe44a10cd289 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add to history
ctrl+c and ctrl+x save to the clipboard like normal but also save to the clipboard history at the same time
if you want to add something like a password to the clipboard but not the history, then use win+c and win+x
show history
use win+v to show the clipboard history
. . . .
Β will be show in the middle[# lines]
will be shown at the end of the lineremove from history
Β