Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

ClipStep - Step through multiple clipboards using Ctrl-X-C-V


  • Please log in to reply
40 replies to this topic
rrhuffy
  • Members
  • 17 posts
  • Last active: Dec 11 2013 10:21 PM
  • Joined: 16 Apr 2012
I used ClipStep, but it was very annoying when I tried to copy something at example from forum (in [code ] block) and often get "Empty selection" or "No clips" (even after putting WaitClip in $^c section) so I tried Chris code for clipboard.
And it works great, even with third party software like Dropbox "Copy public gallery link" / KeePass "Copy password" / PrintSc / Copy file, but interface was much worser than ClipStep.
DeWild1 said (2 years ago, i know :P But archaeologist sticker is worth putting code here ;) ) that he would like to see combined scripts together.
I wanted the same, but I'm so stubborn and I combined that together (i hope that it's bug-free).
So below is combo from skrommel interface and Chris reliability with my modification.

That script got almost 100% Clipstep interface:
"Select some text, press Ctrl-C to copy it to multiple new clipboards.
Now hold down Ctrl and press V repeatedly to step through the clipboards. C steps backwards.
When you've got the clipboard you want, release Ctrl to paste."
When GUI appear (after ^v) while still holding CTRL click ^x and release CTRL to abort paste operation.
It doesn't save clipboards on hdd (unlike ClipStep) and it cycle through [1, MaxClipboards] clips, and then wrap around to the beginning erasing latest one. Thats why there isn't delete clip/all clips feature.
[code]
#Persistent
MaxClipboards = 5
usedClipboards = 0
ClipIndex = 0
guiActive = false

$^x:: ;CUT/EXIT
if guiActive = true ; if GUI is activated then deactivate it, and send EXIT tooltip
{
guiActive = false
ToolTip, Exit
gosub, HOLD
}
else ; if GUI isn't activated then just CUT
{
Send ^x
}
return

$^c:: ;COPY/PREV
if guiActive = true ; if GUI is activated then move to previous clipboard and show it
{
if ClipIndex = 0 ; No saved clipboards yet.
return
ClipIndex -= 1 ; Move backward through the list.
if ClipIndex <= 0 ; Wrap around to the tail end of list.
ClipIndex := usedClipboards
gosub, SHOWCLIPBOARD
}
else ; if GUI isn't activated then just COPY
{
Send ^c
}
return

$^v:: ;PASTE/NEXT
if guiActive = true ; if GUI is activated then move to next clipboard and show it
{
if ClipIndex = 0 ; No saved clipboards yet.
return
ClipIndex += 1 ; Move forward through the list.
if ClipIndex > %usedClipboards% ; Wrap around to beginning or list.
ClipIndex := 1
gosub, SHOWCLIPBOARD
}
else ; if GUI isn't activated then activate GUI and show first element in clipboard
{
guiActive = true
gosub, SHOWCLIPBOARD
}
return

OnClipboardChange:
if (A_EventInfo = 0 OR NoSaveClipboard)
return ; Empty or the hotkey told us not to save its own change to the clipboard.
; Check if what's on the clipboard now exactly matches the previously saved item. If it
; does, don't save it. This solves the fact that some apps save each clipboard twice.
if ClipIndex > 0
{
ClipSavedTemp := ClipboardAll ; ...because can't compare directly to ClipboardAll.
if ClipSaved%ClipIndex% = %ClipSavedTemp% ; Must be old-style if-statement.
return
}
usedClipboards := (usedClipboards + 1 > MaxClipboards) ? MaxClipboards : usedClipboards+1
ClipIndex += 1 ; Move to the next slot.
if (ClipIndex > MaxClipboards) ; Wrap back around to the beginning.
ClipIndex = 1
ClipIndex := ClipIndex ; Reset the hotkey's bookmark each time a save occurs.
ClipSaved%ClipIndex% := ClipboardAll ; Save the current contents of the clipboard.
ToolTip, Added %ClipIndex%/%usedClipboards% `n%Clipboard%
gosub, HOLD
return

SHOWCLIPBOARD:
{
if StrLen(ClipSaved%ClipIndex%) = 0 ; Nothing saved, so don't do it.
{
ToolTip, Restored Clipboard #%ClipIndex% is empty.
gosub, HOLD
return
}
NoSaveClipboard := true ; Tell OnClipboardChange not to save our clipboard change.
Clipboard := ClipSaved%ClipIndex%
ToolTip, Restored Clipboard #%ClipIndex%:`n%Clipboard%
gosub, HOLD
Sleep 30 ; This gives the OnClipboardChange subroutine an opportunity to run.
NoSaveClipboard := false
}

HOLD:
{
GetKeyState,state,CTRL
if state = d ; While holding CTRL gui won't dissapear
SetTimer,HOLD,100
else
{
ToolTip,
if guiActive = true ; Only way to activate GUI is put ^v, so after release CTRL we want to deactivate GUI and PASTE
{
guiActive = false
Send ^v
}
SetTimer,HOLD,off
}
return
}
[/code]

sacmal
  • Guests
  • Last active:
  • Joined: --
Hi rrhuffy,
The script works great for me!!!
is there any way that i can delete all the clips so start afresh?

kangaroo
  • Guests
  • Last active:
  • Joined: --
and would there be a way to (temporarily) disable the working of this script?
why? sometimes I am coping one multiple times just by holding the CTRL key down and then tapping V-V-V-V-V-V-V etc.
this feature is not possible with this script
Thanks!!

rrhuffy
  • Members
  • 17 posts
  • Last active: Dec 11 2013 10:21 PM
  • Joined: 16 Apr 2012
sacmal:
Try this:
#x::
NoSaveClipboard := true
Loop, %usedClipboards%
{
   ClipSaved%A_Index% = 
}
NoSaveClipboard := false
usedClipboards = 1
ClipIndex = 1
return

kangaroo:
Simplest way is something like that:
#v::Send ^v
Then use WIN+V to paste.
Or:
#z::Suspend
After WIN+Z You can click down CTRL and tap VVVVVVVV, but when You click CTRL+C then script is working, and saving new items to clipboard...so CTRL+C is still working, but CTRL+V isn't...dont know if that's bug, or feature :p

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

So below is combo from skrommel interface and Chris reliability with my modification.


works good, thanks rrhuffy

i've simply changed one line in the ctrl+v hotkey:

;ClipIndex += 1  ; Move forward through the list
ClipIndex -= 1    ;// move backwards instead of forward

i find it more natural

CloudSurfer777
  • Members
  • 42 posts
  • Last active: Sep 04 2013 01:55 AM
  • Joined: 02 Oct 2012
Fantastic rrhuffy, nice tight code, it works well, definitely better than ClipStep and Chris' although theirs are great learning tools.
Thanks! Posted Image

Harry Binswanger
  • Members
  • 85 posts
  • Last active: Oct 27 2016 09:33 PM
  • Joined: 26 Aug 2010

Must be something in my set up, but for me the index doesn't increment: it's always ClipIndex = 1. I have tried the script as a separate .AHK file, without any other scripts running, and get same results.



CloudSurfer777
  • Members
  • 42 posts
  • Last active: Sep 04 2013 01:55 AM
  • Joined: 02 Oct 2012

Everyone,

 

I've been using Clipjump by Avi and it works like ClipStep should but even better, search for Clipjump

 

--

Luke



chaz
  • Members
  • 192 posts
  • Last active: Oct 01 2015 02:42 AM
  • Joined: 26 Mar 2013

Better yet, here's the link to A v I 's ClipJump: The Ultimate Clipboard Manager.


Find me at the other forum as timeFlies.


tentator
  • Members
  • 6 posts
  • Last active: Dec 19 2013 09:42 PM
  • Joined: 09 Aug 2013

works good, thanks rrhuffy

i've simply changed one line in the ctrl+v hotkey:
 

;ClipIndex += 1  ; Move forward through the list
ClipIndex -= 1    ;// move backwards instead of forward
i find it more natural

 

 

yes I find it too more natural.. ;)

but you have to correct obviously also the if to wrap around and do the same also for "v" I suppose..

 

for others to copy here the whole fixed script:

#Persistent
MaxClipboards = 7
usedClipboards = 0
ClipIndex = 0
guiActive = false

$^x:: ;CUT/EXIT
 if guiActive = true ; if GUI is activated then deactivate it, and send EXIT tooltip
 {
  guiActive = false
  ToolTip, Exit
  gosub, HOLD
  }
  else ; if GUI isn't activated then just CUT
  {
   Send ^x
  }
return

$^c:: ;COPY/PREV
 if guiActive = true ; if GUI is activated then move to previous clipboard and show it
 {
  if ClipIndex = 0 ; No saved clipboards yet.
   return
  ClipIndex += 1 ; Move backward through the list.
  if ClipIndex > %usedClipboards% ; Wrap around to the beginning of list.
   ClipIndex := 1
  gosub, SHOWCLIPBOARD
  }
  else ; if GUI isn't activated then just COPY
  {
   Send ^c
  }
return

$^v:: ;PASTE/NEXT
 if guiActive = true ; if GUI is activated then move to next clipboard and show it
 {
  if ClipIndex = 0 ; No saved clipboards yet.
   return
  ClipIndex -= 1    ; move backwards through the list.
  if ClipIndex < 1 ; Wrap around to end of list.
   ClipIndex := usedClipboards
  gosub, SHOWCLIPBOARD
  }
  else ; if GUI isn't activated then activate GUI and show first element in clipboard
  {
   guiActive = true
   gosub, SHOWCLIPBOARD
  }
return

OnClipboardChange:
 if (A_EventInfo = 0 OR NoSaveClipboard)
  return ; Empty or the hotkey told us not to save its own change to the clipboard.
 ; Check if what's on the clipboard now exactly matches the previously saved item. If it
 ; does, don't save it. This solves the fact that some apps save each clipboard twice.
 if ClipIndex > 0
 {
  ClipSavedTemp := ClipboardAll ; ...because can't compare directly to ClipboardAll.
  if ClipSaved%ClipIndex% = %ClipSavedTemp% ; Must be old-style if-statement.
   return
 }
 usedClipboards := (usedClipboards + 1 > MaxClipboards) ? MaxClipboards : usedClipboards+1
 ClipIndex += 1 ; Move to the next slot.
 if (ClipIndex > MaxClipboards) ; Wrap back around to the beginning.
  ClipIndex = 1
 ClipIndex := ClipIndex ; Reset the hotkey's bookmark each time a save occurs.
 ClipSaved%ClipIndex% := ClipboardAll ; Save the current contents of the clipboard.
 ToolTip, Added %ClipIndex%/%usedClipboards% `n%Clipboard%
 gosub, HOLD
return

SHOWCLIPBOARD:
{
 if StrLen(ClipSaved%ClipIndex%) = 0 ; Nothing saved, so don't do it.
 {
  ToolTip, Restored Clipboard #%ClipIndex% is empty.
  gosub, HOLD
  return
 }
 NoSaveClipboard := true ; Tell OnClipboardChange not to save our clipboard change.
 Clipboard := ClipSaved%ClipIndex%
 ToolTip, Restored Clipboard #%ClipIndex%:`n%Clipboard%
 gosub, HOLD
 Sleep 30 ; This gives the OnClipboardChange subroutine an opportunity to run.
 NoSaveClipboard := false
}

HOLD:
{
 GetKeyState,state,CTRL
 if state = d ; While holding CTRL gui won't dissapear
  SetTimer,HOLD,100
 else
 {
  ToolTip,
  if guiActive = true ; Only way to activate GUI is put ^v, so after release CTRL we want to deactivate GUI and PASTE
  {
   guiActive = false
   Send ^v
  }
  SetTimer,HOLD,off
 }
 return
}


kcaandersen
  • Members
  • 4 posts
  • Last active: Jun 03 2015 02:43 AM
  • Joined: 02 Jun 2015

Just in case anybody catches this, as it's been a while on this thread:

 

I'm trying to copy multiple items using this script, then with a hotkey, automatically paste multiple items from my clipboard history, but I can't get the code to trigger the clipboard history.  It seemingly completely ignores that it exists.

 

^vvvv or {Ctrl down}vvvv{Ctrl up} is what I'm trying to achieve via hotkey. All I get is the latest item pasted, as if the clipboard history didn't exist.

 

Any help would be greatly appreciated, for a relatively new AHK user.

 

Thanks,