; Deluxe Clipboard ; AutoHotkey Version: 1.0.30+ ; Language: English ; Platform: Win2000/XP ; Author: Laszlo Hars ; ; Script Function: ; Provides unlimited number of private, named clipboards to ; Copy: ^!c, Cut: ^!x, Paste: ^!v, Append: ^!a or CutAppend: ^!y any selections ; In applications using ^c for copy, and ^v for paste to/from the Windows clipboard ; Private clipboard names consist of numbers, letters, #, _, @, ?, [, and ] ; OK: 01, Greetings[2], gut_und_schlecht, #5, finished?, @home ; BAD: 1.1, You&Me, Mon Amis, $1000, <1>, a-z, 100% ; The already used names are shown in a sorted drop down list with ; incremental search (beginning of a name and Up or Down arrow) ; The last-used name is pre-selected, Enter accepts ; Repeated hotkeys provide their original functions (auto exit) ; Esc, Click on Cancel or on [x]: escapes out ; Enter, Alt-underlined, Click: performs action with typed/selected name ; ; Limitations: ; ClipBoardAll interferes with MS Word (adds bookmarks) ; ; Version 1.0: 2005.03.05 Initial creation ; 1.1: 2005.03.07 Error check added for clipboard names ; Legible version of A_ThisHotKey in GUI text ; 2nd hotkey while 1st is active replaces function ; Repeated hotkey is detected from saved current hotkey ; 1.2: 2005.03.12 Append: by arrays of private clipboards, $ separated ; Paste: each entry of the array one-by-one ; ClipBoardAll is used names = ; | after each name, || after last used (default) AKey = ; Active hotkey (none), in case EnvVar AKey exists $^!c:: ; COPY to private clipboard Actn = &Copy GoSub WINDOW return $^!v:: ; PASTE from private clipboard Actn = &Paste GoSub WINDOW return $^!x:: ; CUT to private clipboard Actn = &Cut GoSub WINDOW return $^!a:: ; APPEND to private clipboard Actn = &Append GoSub WINDOW return $^!y:: ; CUT+APPEND to private clipboard Actn = Cut&Append GoSub WINDOW return WINDOW: if AKey = %A_ThisHotKey% ; Activating hotkey pressed the second time { Gui Destroy WinActivate ahk_id %CallerID% Send %BKey% ; Send Bare hotkey AKey = ; no Active hotkey return } if AKey <> ; 2nd hotkey while 1st is active Gui Destroy AKey = %A_ThisHotKey% ; Save Activating HotKey StringReplace BKey, Akey, UP StringReplace BKey, Bkey, ~, ; Bare hotkey = Removed modifiers StringReplace BKey, Bkey, $, StringReplace BKey, Bkey, %A_Space%`&%A_Space%, ; HKey = Legible form of AKey StringReplace HKey, BKey, `^, Ctrl- StringReplace HKey, HKey, `!, Alt- StringReplace HKey, Hkey, `+, Shift- StringReplace HKey, Hkey, `#, Win- StringReplace HKey, Hkey, `<, Left- StringReplace HKey, Hkey, `>, Right- StringReplace HKey, Hkey, `*, Any- WinGet CallerID, ID, A ; save caller's ID as the window to return to Gui Font, s10, MS Sans Serif ; ADJUST BELOW FOR YOUR SCREEN RESOLUTION Gui Add, ComboBox,x026 y064 w220 h20 r5 Sort vName, %names% ; 1st Gui Add = active Gui Add, Button, x146 y104 w100 h30, Cancel Gui Add, Button, x026 y104 w100 h30 Default, %Actn% Gui Add, Text, x028 y014 w220 h40, For %HKey% repeat, or`nName your private clipboard Gui Show, h163 w271 Center, Deluxe Clipboard return GuiClose: GuiEscape: ButtonCancel: Gui Destroy return ButtonCopy: Gosub GoBack IfEqual NameError,1,GoSub,WINDOW ;setup new GUI after wrong name else { cnt := CB_%Name%$0 Loop %cnt% CB_%Name%$%A_Index% = ; clear memory used by the array, if any CB_%Name%$0 = 1 ; chain length = 1 ClipBoard0 = %ClipBoardAll% ; save original clipboard (ClipBoardAll) Send ^c ; copy data to clipboard CB_%Name%$1 = %ClipBoardAll% ; transfer new clipboard to array (ClipBoardAll) ClipBoard = %ClipBoard0% ; restore original clipboard } return ButtonPaste: Gosub GoBack IfEqual NameError,1,GoSub,WINDOW ;setup new GUI after wrong name else { ClipBoard0 = %ClipBoardAll% ; save original clipboard (ClipBoardAll) cnt := CB_%Name%$0 Loop %cnt% { ; load clipboard from array C := CB_%Name%$%A_Index% Clipboard = %C% Send ^v ; paste data to window } ClipBoard = %ClipBoard0% ; restore original clipboard } return ButtonCut: Gosub GoBack IfEqual NameError,1,GoSub,WINDOW ;setup new GUI after wrong name else { cnt := CB_%Name%$0 Loop %cnt% CB_%Name%$%A_Index% = ; clear memory used by the array, if any CB_%Name%$0 = 1 ; chain length = 1 ClipBoard0 = %ClipBoardAll% ; save original clipboard (ClipBoardAll) Send ^x ; cut data to clipboard CB_%Name%$1 = %ClipBoardAll% ; transfer new clipboard to array (ClipBoardAll) ClipBoard = %ClipBoard0% ; restore original clipboard } return ButtonAppend: ; only works with *text* clipboards Gosub GoBack IfEqual NameError,1,GoSub,WINDOW ;setup new GUI after wrong name else { ClipBoard0 = %ClipBoardAll% ; save original clipboard (ClipBoardAll) Send ^c ; copy new data to clipboard CB_%Name%$0++ ; increment number of clipboards in the chain idx := CB_%Name%$0 CB_%Name%$%idx%= %ClipBoard% ; store new clipboard at the next array location ClipBoard = %ClipBoard0% ; restore original clipboard } return ButtonCutAppend: ; only works with *text* clipboards Gosub GoBack IfEqual NameError,1,GoSub,WINDOW ;setup new GUI after wrong name else { ClipBoard0= %ClipBoardAll% ; save original clipboard (ClipBoardAll) Send ^x ; cut data to clipboard CB_%Name%$0++ ; increment number of clipboards in the chain, init = 1 idx := CB_%Name%$0 CB_%Name%$%idx%= %ClipBoard% ; store new clipboard at the next array location ClipBoard = %ClipBoard0% ; restore original clipboard } return GoBack: Gui Submit ; assign gui variables Gui Destroy ; GUI's done its task AKey = ; no active hotkey if Name = { ; check if Name is empty MsgBox Please provide a`nClipboard Name! NameError = 1 return } StringReplace var,Name, #, a, All StringReplace var, var, _, a, All StringReplace var, var, @, a, All StringReplace var, var, ?, a, All StringReplace var, var, [, a, All StringReplace var, var, ], a, All if var is not alnum ; check if Name can be a variable, $ used internally { MsgBox Wrong name (%Name%)`nTry again! NameError = 1 return } NameError = 0 WinActivate ahk_id %CallerID% ; get back to caller window StringReplace names,names,||,| ; remove last-used marker StringGetPos Pos, names,%Name%| ; was this clipboard name used? if Pos < 0 ; new name appended names = %names%%Name%|| else ; old name marked as last used StringReplace names,names,%Name%|,%Name%|| return