Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active July 27, 2023 16:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebrny/1d1cf0b3041b031ce06bfe44a10cd289 to your computer and use it in GitHub Desktop.
Save davebrny/1d1cf0b3041b031ce06bfe44a10cd289 to your computer and use it in GitHub Desktop.
πŸ“‹ (autohotkey) - microscopic clipboard manager (text only)
#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
*/
@davebrny
Copy link
Author

davebrny commented Mar 10, 2017

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

    • lines that are longer than 65 characters are truncated and Β  . . . . Β  will be show in the middle
    • the default number of items in the history is 20
    • if an item has multiple lines then [# lines] will be shown at the end of the line

remove from history

  • ctrl+click on an item in the list to remove it from the history
  • to clear the history completely, reload the script from the tray menu

Β 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment