 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
skrommel
Joined: 30 Jul 2004 Posts: 190
|
Posted: Sat Aug 06, 2005 10:34 pm Post subject: ClipStep - Step through multiple clipboards using Ctrl-X-C-V |
|
|
ClipStep - Control multiple clipboards using only the keyboard's Ctrl-X-C-V
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.
To delete a clipboard, hold down Ctrl, press V followed by X twice to delete, three times to delete all, or once to cancel. Release Ctrl to accept.
The clipboards are saved to separate files, so place the script in it's own folder.
Thank's to skywalka who posted this idea in another forum.
Updated to v1.2: Removed a few bugs, tweaked some functions.
Skrommel
| Code: | ;ClipStep.ahk v1.2
;
;Control multiple clipboards using only the keyboard's Ctrl-X-C-V
;
;Select some text, press Ctrl-C a couple of times 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.
; To delete a clipboard, hold down Ctrl, press V followed by X twice to delete, three times to
; delete all, or once to cancel. Release Ctrl to accept.
;
; The clipboards are saved to separate files, so place the sctipt in it's own folder.
;
;Skrommel @2005
SetBatchLines,-1
numofclips=0
activeclip=1
paste=no
delete=no
Gosub,INDEX
LOOP:
Sleep,100
GetKeyState,state,CTRL
If state=u
{
If delete=delete
{
readclip=filearray%activeclip%
readclip:=%readclip%
Filedelete,%readclip%.clip
tooltip=Deleting Clip %activeclip% of %numofclips%
Gosub,TOOLTIP
Gosub,INDEX
Gosub,FINDPREV
}
Else
If delete=all
{
tooltip=Deleting all clips
Gosub,TOOLTIP
Filedelete,*.clip
numofclips=0
activeclip=0
filearray1=0
Gosub,INDEX
activeclip=%numofclips%
}
Else
If paste=paste
{
readclip=filearray%activeclip%
readclip:=%readclip%
tooltip=Pasting clip %activeclip%
Gosub,TOOLTIP
Gosub,PASTECLIP
}
delete=no
paste=no
}
Goto,LOOP
$^x::
If paste<>no
{
If delete=delete
{
ToolTip,Delete all clips
SetTimer,TOOLTIPOFF,Off
delete=all
paste=yes
Return
}
Else
If delete=cancel
{
If numofclips<1
{
tooltip=No clip exists
Gosub,TOOLTIP
Return
}
readclip=filearray%activeclip%
readclip:=%readclip%
FileRead,Clipboard,*c %readclip%.clip
StringLeft,clip,Clipboard,100
ToolTip,Delete Clip %activeclip% of %numofclips%`n%clip%
SetTimer,TOOLTIPOFF,Off
delete=delete
paste=yes
Return
}
Else
{
tooltip=Cancel
Gosub,TOOLTIP
delete=cancel
paste=yes
Return
}
}
clip1:=ClipboardAll
Clipboard=
Send,^x
ClipWait,1
clip2:=ClipboardAll
If clip2=
{
tooltip=Empty selection
Gosub,TOOLTIP
}
Else
If clip1<>%clip2%
{
tooltip=Copying to clip 1
Gosub,TOOLTIP
Gosub,ADDCLIP
Gosub,INDEX
}
Else
{
tooltip=Same selection
Gosub,TOOLTIP
}
clip1=
clip2=
Return
$^c::
If paste<>no
{
If numofclips<1
{
tooltip=No clip exists
Gosub,TOOLTIP
delete=no
paste=yes
Return
}
Gosub,FINDPREV
Gosub,SHOWCLIP
delete=no
paste=paste
Return
}
clip1:=ClipboardAll
Clipboard=
Send,^c
clip2:=ClipboardAll
If clip2=
{
tooltip=Empty selection
Gosub,TOOLTIP
}
Else
If clip1<>%clip2%
{
tooltip=Copying to clip 1
Gosub,TOOLTIP
Gosub,ADDCLIP
Gosub,INDEX
}
Else
{
tooltip=Same selection
Gosub,TOOLTIP
}
clip1=
clip2=
Return
$^v::
If numofclips<1
{
tooltip=No clip exists
Gosub,TOOLTIP
delete=no
paste=yes
Return
}
If paste<>no
Gosub,FINDNEXT
Gosub,SHOWCLIP
delete=no
paste=paste
Return
ADDCLIP:
readclip=filearray1
readclip:=%readclip%
lastclip=%readclip%
lastclip+=1
numofclips+=1
activeclip=1
IfExist,%lastclip%.clip
FileDelete,%lastclip%.clip
FileAppend,%ClipboardAll%,%lastclip%.clip
Return
SHOWCLIP:
readclip=filearray%activeclip%
readclip:=%readclip%
clip1:=ClipboardAll
IfExist,%readclip%.clip
FileRead,Clipboard,*c %readclip%.clip
StringLeft,clip2,Clipboard,100
If clip2=
clip2=... Image
ToolTip,Clip %activeclip% of %numofclips%`n%clip2% ...
SetTimer,TOOLTIPOFF,Off
Clipboard:=clip1
clip1=
clip2=
Return
PASTECLIP:
readclip=filearray%activeclip%
readclip:=%readclip%
IfExist,%readclip%.clip
FileRead,Clipboard,*c %readclip%.clip
Send,^v
delete=no
paste=no
Return
DELETECLIP:
delete=no
paste=no
Return
TOOLTIP:
ToolTip,%tooltip%
SetTimer,TOOLTIPOFF,900
Return
TOOLTIPOFF:
ToolTip,
SetTimer,TOOLTIP,Off
Return
INDEX:
filelist=
Loop,*.clip
{
StringTrimRight,filename,A_LoopFileName,5
filelist=%filelist%%filename%`n
}
StringTrimRight,filelist,filelist,1
Sort,filelist,N R
StringSplit,filearray,filelist,`n
numofclips=%filearray0%
Return
FINDNEXT:
If numofclips<1
{
tooltip=No clip exists
Gosub,TOOLTIP
delete=no
paste=yes
Return
}
activeclip+=1
If activeclip>%numofclips%
activeclip=1
Return
FINDPREV:
If numofclips<1
{
tooltip=No clip exists
Gosub,TOOLTIP
delete=no
paste=yes
Return
}
activeclip-=1
If activeclip<1
activeclip=%numofclips%
Return |
Last edited by skrommel on Sun Aug 07, 2005 2:57 pm; edited 3 times in total |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4517 Location: Boulder, CO
|
Posted: Sun Aug 07, 2005 3:00 am Post subject: |
|
|
| Cool! For unformatted text and few clipboards this script is faster to use and more convenient than the other clipboard scripts posted here. Thanks for sharing it! |
|
| Back to top |
|
 |
skrommel
Joined: 30 Jul 2004 Posts: 190
|
Posted: Sun Aug 07, 2005 10:01 am Post subject: RTF |
|
|
It works with all kinds of formats, the problem is displaying them when stepping through them.
What we need is a ClipToImage function, or for Gui,Add,Image to read the clip-format.
Skrommel |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4517 Location: Boulder, CO
|
Posted: Sun Aug 07, 2005 5:06 pm Post subject: |
|
|
Wonderful! It really works with images and formatted text, too. Unfortunately, I see the bookmark and picture problem in MS Word still pops up its ugly head. We just have to wait until MS or Chris finds a way around.
One feature worth mentioning in the description: if a selection is copied to the clipboard through the Windows context menu (right-click/copy), it still can be pasted the original way (independent to clip-step) through the context menu (right-click/paste). It sometimes helps to let MS Word show pasted pictures, instead of just the placeholders. |
|
| Back to top |
|
 |
skrommel
Joined: 30 Jul 2004 Posts: 190
|
Posted: Sun Aug 07, 2005 10:56 pm Post subject: Clipboard Error? |
|
|
I originally wanted to add PrintScreen and other clips to the chain, but there seems to be all kinds of things going on with the clipboard.
Even running the script from the help file
| Code: | #Persistent
return
OnClipboardChange:
ToolTip Type: %A_EventInfo%
Sleep 1000
ToolTip ; Turn off the tip.
return |
alters the clipboard and shows a message. Is it just my computer, or is there a bug here somewhere?
Skrommel |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4517 Location: Boulder, CO
|
Posted: Mon Aug 08, 2005 5:23 am Post subject: |
|
|
| At least this problem I don't seem to have (XP SP2, Dell Inspiron 9300 laptop). I don't get the tooltip popping up. What is in your system? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10667
|
Posted: Sat Sep 24, 2005 3:34 pm Post subject: |
|
|
While reading another topic, I'd forgotten about the script above so wrote the below. Here it is in case it's of use to anyone or if there's anything of merit that can be combined with the one above:
| Code: | ; This script keeps a record of the clipboard contents so that in effect, you have
; more than one clipboard. To restore the old clipboards (one by one), press the
; Win+Space or Shift+Win+Space hotkeys (or other hotkeys as configured below).
; The script give you feedback about what's on the clipboard via Tooltips.
; CONFIGURATION SECTION. SET YOUR PREFERENCES HERE:
MaxClipboards = 5 ; How many clipboards to maintain in the list.
HotkeyBack = #space ; Hotkey to move backward through the list of clipboards.
HotkeyFwd = #+space ; Hotkey to move forward through the list of clipboards.
; END OF CONFIGURATION SECTION
Hotkey, %HotkeyBack%, HotkeyBack
Hotkey, %HotkeyFwd%, HotkeyFwd
#Persistent
ClipIndex = 0
ClipIndexToRestore = 0
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
}
ClipIndex += 1 ; Move to the next slot.
if (ClipIndex > MaxClipboards) ; Wrap back around to the beginning.
ClipIndex = 1
ClipIndexToRestore := ClipIndex ; Reset the hotkey's bookmark each time a save occurs.
ClipSaved%ClipIndex% := ClipboardAll ; Save the current contents of the clipboard.
ToolTip, %ClipIndex%, A_CaretX, A_CaretY ; Briefly notify the user of the item number.
SetTimer, ToolTipOff, 1000
return
HotkeyBack:
HotkeyFwd:
if ClipIndexToRestore = 0 ; No saved clipboards yet.
return
if (A_ThisHotkey = HotkeyBack)
{
ClipIndexToRestore -= 1 ; Move backward through the list.
if ClipIndexToRestore <= 0 ; Wrap around to the tail end of list.
ClipIndexToRestore := MaxClipboards
}
else ; (A_ThisHotkey = HotkeyFwd)
{
ClipIndexToRestore += 1 ; Move forward through the list.
if ClipIndexToRestore > %MaxClipboards% ; Wrap around to beginning or list.
ClipIndexToRestore := 1
}
if StrLen(ClipSaved%ClipIndexToRestore%) = 0 ; Nothing saved, so don't do it.
{
ToolTip Restored Clipboard #%ClipIndexToRestore% is empty., A_CaretX, A_CaretY
SetTimer, ToolTipOff, 2000
return
}
NoSaveClipboard := true ; Tell OnClipboardChange not to save our clipboard change.
Clipboard := ClipSaved%ClipIndexToRestore%
ToolTip Restored Clipboard #%ClipIndexToRestore%:`n%Clipboard%, A_CaretX, A_CaretY
SetTimer, ToolTipOff, 2000
Sleep 30 ; This gives the OnClipboardChange subroutine an opportunity to run.
NoSaveClipboard := false
return
ToolTipOff:
ToolTip
SetTimer, ToolTipOff, Off
return |
|
|
| Back to top |
|
 |
EXtes Guest
|
Posted: Fri Sep 30, 2005 3:02 pm Post subject: |
|
|
Hi skrommel
Nice work, Thanks.
I would suggest: | Code: | | tooltip:="Copying to clip " . numofclips + 1 |
EXtes |
|
| Back to top |
|
 |
EXtes
Joined: 01 Oct 2005 Posts: 7
|
Posted: Sat Oct 01, 2005 1:04 pm Post subject: |
|
|
Argh
Clipboard is copied to clip 1 always, so forget about my reply |
|
| Back to top |
|
 |
Peepsalot
Joined: 06 Oct 2005 Posts: 24
|
Posted: Thu Oct 06, 2005 10:20 pm Post subject: |
|
|
Awesome script. It would be cool to have it also support Shift-Delete(Cut), Ctrl-Insert(Copy), and Shift-Insert(Paste).
Apparently I'm one of the very few people that regularly uses these shortcuts. I guess I'm weird.
I'm very new to AUtohotkey, and I'm impressed with everything it is capable of. Maybe I will tinker with the script a bit tonight. |
|
| Back to top |
|
 |
lowbatteries Guest
|
Posted: Mon Feb 06, 2006 11:59 pm Post subject: file copying |
|
|
If I hit ctrl+c on a file, I get the tooltip "empty selection", where as if I use ctrl+x, it saves it as a clip and I can then paste it (works as it does in windows).
Currently, copying files with ctrl+c is effectively broken while running the script, but I can use the ctrl+insert and shift+insert mentioned by peepsalot. I had no clue those shortcuts existed. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3906 Location: Bremen, Germany
|
Posted: Tue Feb 07, 2006 9:21 am Post subject: |
|
|
lowbatteries posted in a new topic:
| lowbatteries wrote: | permanent clipboards ...
I discovered that you can create permanent clipboards by renaming the clip files from 1.clip to x.clip, or some other non-numeric name, and setting the permissions to read-only. |
I guess it belongs here. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Tomas Guest
|
Posted: Tue Nov 07, 2006 1:40 am Post subject: |
|
|
I wish there was a way to always only have 2 clipboards to switch between. Personally in 99% of the time I would only need 2 clipboards. Perhaps there is an easy fix to implement this.
Thanks for a great little utility!
Tomas |
|
| Back to top |
|
 |
hughman
Joined: 11 Feb 2007 Posts: 92
|
Posted: Wed Feb 14, 2007 3:39 pm Post subject: |
|
|
| Chris wrote: | While reading another topic, I'd forgotten about the script above so wrote the below. Here it is in case it's of use to anyone or if there's anything of merit that can be combined with the one above:
|
This is the very clipboard script I want. Thx Chris.But I have a problem.
I want to integrate several script into one. So I change a little your script as follow:
| Code: |
#Space::
#!Space::
if ClipIndexToRestore = 0 ; No saved clipboards yet.
return
if (A_ThisHotkey = #Space)
{
ClipIndexToRestore -= 1 ; Move backward through the list.
if ClipIndexToRestore <= 0 ; Wrap around to the tail end of list.
ClipIndexToRestore := MaxClipboards
}
;If (A_ThisHotkey = #!Space)
else ; (A_ThisHotkey = HotkeyFwd)
{
ClipIndexToRestore += 1 ; Move forward through the list.
if ClipIndexToRestore > %MaxClipboards% ; Wrap around to beginning or list.
ClipIndexToRestore := 1
}
if StrLen(ClipSaved%ClipIndexToRestore%) = 0 ; Nothing saved, so don't do it.
{
ToolTip Restored Clipboard #%ClipIndexToRestore% is empty., A_CaretX, A_CaretY
SetTimer, ToolTipOff, 2000
return
}
NoSaveClipboard := true ; Tell OnClipboardChange not to save our clipboard change.
Clipboard := ClipSaved%ClipIndexToRestore%
ToolTip Restored Clipboard #%ClipIndexToRestore%:`n%Clipboard%, A_CaretX, A_CaretY
SetTimer, ToolTipOff, 2000
Sleep 30 ; This gives the OnClipboardChange subroutine an opportunity to run.
NoSaveClipboard := false
return
|
I have just used the hotkey #space and #+space directly in place of the "hotkey" command.
As a result ,when I press #!space, the list move backward too rather than forward. Why?
And why this line "MaxClipboards = 5" must be moved to precede all the other hotkey and hotstring? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10667
|
Posted: Fri Feb 16, 2007 1:36 am Post subject: |
|
|
| Quote: | | when I press #!space, the list move backward too rather than forward. Why? | if (A_ThisHotkey = #Space)
Should Be:
if A_ThisHotkey = #Space
See the Variables/Expressions page for details.
| Quote: | | And why this line "MaxClipboards = 5" must be moved to precede all the other hotkey and hotstring? | See the Scripts page (auto-execute section). It's also covered in the FAQ. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|