Skip to content

Instantly share code, notes, and snippets.

@4rc0s
Created November 7, 2011 16:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save 4rc0s/1345461 to your computer and use it in GitHub Desktop.
Save 4rc0s/1345461 to your computer and use it in GitHub Desktop.
AutoHotKey clipboard history script that is easily navigated and relatively short
; Retrieves saved clipboard information since when this script last ran
Loop C:\tmp\clipvar*.txt
{
clipindex += 1
FileRead clipvar%A_Index%, %A_LoopFileFullPath%
FileDelete %A_LoopFileFullPath%
}
maxindex := clipindex
OnExit ExitSub
; Clears the history by resetting the indices
^+NumpadClear::
^+Numpad5::
tooltip clipboard history cleared
SetTimer, ReSetToolTip, 1000
maxindex = 0
clipindex = 0
Return
; Scroll up and down through clipboard history
^+WheelUp::
if clipindex > 1
{
clipindex -= 1
}
thisclip := clipvar%clipindex%
clipboard := thisclip
tooltip %clipindex% - %clipboard%
SetTimer, ReSetToolTip, 1000
Return
^+WheelDown::
if clipindex < %maxindex%
{
clipindex += 1
}
thisclip := clipvar%clipindex%
clipboard := thisclip
tooltip %clipindex% - %clipboard%
SetTimer, ReSetToolTip, 1000
Return
; Add clipboard contents to the stack when you copy or paste using the keyboard
~^x::
~^c::
Sleep 500
clipindex += 1
clipvar%clipindex% := clipboard
thisclip := clipvar%clipindex%
tooltip %clipindex% - %thisclip%
SetTimer, ReSetToolTip, 1000
if clipindex > %maxindex%
{
maxindex := clipindex
}
Return
; Clear the ToolTip
ReSetToolTip:
ToolTip
SetTimer, ReSetToolTip, Off
return
; Saves the current clipboard history to hard disk
ExitSub:
SetFormat, float, 06.0
Loop %maxindex%
{
zindex := SubStr("0000000000" . A_Index, -9)
thisclip := clipvar%A_Index%
FileAppend %thisclip%, C:\tmp\clipvar%zindex%.txt
}
ExitApp
@4rc0s
Copy link
Author

4rc0s commented Nov 7, 2011

Features:

  • automatically captures clipboard (text) when you press ctrl c or ctrl x and adds it to a stack.
  • quickly scroll and see the contents of the stack through ctrl shift mousewheel (you can of course modify this to your own preference).
  • history is saved in script variables (RAM, which should be fine unless you're planning on extreme clipboard usage)
  • history is persistent, will be saved on script reload, system restart, etc
  • clear history with a hotkey
  • simple script (~70 lines) easy read and understand for your own modifications

Original source:
http://www.autohotkey.com/forum/topic77408.html

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