• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scriptable multi-clipboard utility?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scriptable multi-clipboard utility?


  • Subject: Re: Scriptable multi-clipboard utility?
  • From: "koenig.yvan" <email@hidden>
  • Date: Sat, 08 Mar 2014 14:16:14 +0100

Enhanced version allowing to select/insert several lines


tell application "System Events"
set frontApp to (file of first process whose frontmost is true) as text
end tell
set fullClipText to (the clipboard as text)

try
# We may select several lines if needed.
set maybe to choose from list (paragraphs of fullClipText) with multiple selections allowed
# returns false if we click Cancel or type Escape
# returns the list of selected lines if we click OK
if maybe is not false then
# Concatenate the selected items with the lineBreak available in the source
if (count maybe) > 1 then
if fullClipText contains (return & linefeed) then
set lineBreak to return & linefeed
else if fullClipText contains linefeed then
set lineBreak to linefeed
else
set lineBreak to return
end if
set maybe to my recolle(maybe, lineBreak)
end if
set the clipboard to maybe
# loop reducing the delay to what is really needed, no less, no more
repeat
delay 0.1
if (the clipboard as text) is maybe then exit repeat
end repeat
tell application frontApp
activate
end tell
tell application "System Events" to keystroke "v" using {command down}
delay 0.2
set the clipboard to fullClipText
end if
end try

#=====

on recolle(l, d)
local oTIDs, t
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set t to "" & l
set AppleScript's text item delimiters to oTIDs
return t
end recolle

#=====

Yvan KOENIG (VALLAURIS, France) samedi 8 mars 2014 14:16:09



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Scriptable multi-clipboard utility?
      • From: Michael Grant <email@hidden>
References: 
 >Scriptable multi-clipboard utility? (From: Michael Grant <email@hidden>)
 >Re: Scriptable multi-clipboard utility? (From: Michael Grant <email@hidden>)
 >Re: Scriptable multi-clipboard utility? (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: Scriptable multi-clipboard utility?
  • Next by Date: Calendar running scripts?
  • Previous by thread: Re: Scriptable multi-clipboard utility?
  • Next by thread: Re: Scriptable multi-clipboard utility?
  • Index(es):
    • Date
    • Thread