More clipboard tools - smart cut, smart copy.
Posted: 2011-09-05 15:53:06
These macros take the selected text and cut or copy to the next available clipboard that's not the number 1 clipboard. If the clipboard doesn't exist, it creates a new one.
This code has been updated from its original based on Philip's suggestions below.
Smart Copy
Smart Cut
This code has been updated from its original based on Philip's suggestions below.
Smart Copy
Code: Select all
# Copy and save to next empty clipboard
# Thanks to Philip (phspaelti) from the forum who helped make this macro awesome.
#####
Define Command AddClipboard
$n = 0
While Clipboard Exists “Clipboard $n”
$n +=1
End
New Clipboard “Clipboard $n”
$newClipboard = Clipboard Index “Clipboard $n”
Return $newClipboard
End
#####
$doc = Document.active
$doctext = $doc.text
$count = Clipboard Count
If $count < 2
$newClipboard = AddClipboard
$count = Clipboard Count
End
$n = 2
$range = TextSelection.activeRange
$text = $doctext.subtextInRange($range)
If !$text
Prompt ‘Nothing selected.’,’‘,’OK’
exit
End
# Go through clipboards to find an empty one.
While $n <= $count
$clipboardName = $n
$clipboardData = Read Clipboard $clipboardName
If !$clipboardData
Write Clipboard $text, $clipboardName
exit
End
$n += 1
End
# If there are no empty clipboards, create a new one.
$newClipboard = AddClipboard
Write Clipboard $text, $newClipboard
Code: Select all
# Copy and save to next empty clipboard
# Thanks to Philip (phspaelti) from the forum who helped make this macro awesome.
#####
Define Command AddClipboard
$n = 0
While Clipboard Exists “Clipboard $n”
$n +=1
End
New Clipboard “Clipboard $n”
$newClipboard = Clipboard Index “Clipboard $n”
Return $newClipboard
End
#####
$doc = Document.active
$doctext = $doc.text
$count = Clipboard Count
If $count < 2
$newClipboard = AddClipboard
$count = Clipboard Count
End
$n = 2
$range = TextSelection.activeRange
$text = $doctext.subtextInRange($range)
$doctext.deleteInRange($range)
If !$text
Prompt ‘Nothing selected.’,’‘,’OK’
exit
End
# Go through clipboards to find an empty one.
While $n <= $count
$clipboardName = $n
$clipboardData = Read Clipboard $clipboardName
If !$clipboardData
Write Clipboard $text, $clipboardName
exit
End
$n += 1
End
# If there are no empty clipboards, create a new one.
$newClipboard = AddClipboard
Write Clipboard $text, $newClipboard