Cool clipboard macro for selecting text from a clipboard

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
loulesko
Posts: 89
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Cool clipboard macro for selecting text from a clipboard

Post by loulesko » 2011-09-05 14:54:17

I have been looking for a way to make the fabulous multiple clipboards more useful and I think I hit on something good. This macro lists the first 60 characters from each clipboard in a list and then allows you to click on multiple choices to paste them in your document. If you don't want to paste jus hit ESC key.

Code: Select all

# Clipboards
$n = 1
$count = Clipboard Count
$choicelist = “”
While $n <= $count
	$clipboardName = $n
	$clipboardData = Read Clipboard $clipboardName
	$len = $clipboardData.length
If $len > 60
$range = Range.new(0, 60)
else
$range = Range.new(0, $len)
End
If $clipboardData
$clipboardData = $clipboardData.subtextInRange($range)
# Strip out the line feeds so the text looks good in the prompt window.
$map = Hash.new
$map{0x00A} = ‘ ’
$range = Range.new(0, $clipboardData.length)
$clipboardData.transliterateInRange($range, $map)
End
If $len > 60
$clipboardData = “$n)  $clipboardData...($len)”
else
$clipboardData = “$n)  $clipboardData”
End
# If the choice list exists append to array else create new array
If !$choicelist
$choicelist = Array.new($clipboardData)
else
$choicelist.appendValue($clipboardData)
End
	$n += 1
End
$choice = Prompt Checkboxes ‘Clipboards’,‘’, 'Paste', $choicelist
# Find the location of the first close paren which indicates the end of the clipboard number.
ForEach $cbname in $choice
$range = $cbname.rangeOfString “)”
$range = $range.location
$range = Range.new(0, $range)
$cbname = $cbname.subtextInRange($range)
$clipboardData = Read Clipboard $cbname
If $clipboardData
Type Text “$clipboardData ”
End
End


User avatar
martin
Official Nisus Person
Posts: 4291
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Cool clipboard macro for selecting text from a clipboard

Post by martin » 2011-09-06 15:22:40

Thanks for sharing Lou, this seems pretty handy!

User avatar
loulesko
Posts: 89
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: Cool clipboard macro for selecting text from a clipboard

Post by loulesko » 2011-09-06 15:28:39

Thanks Martin - it is shockingly useful.

L

Post Reply