• 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 21:22:50 +0100

I'm not sure that it's really useful but it costs nothing.
Taking the problem by an other side, removing it will give an error message which maybe will be useful to understand what was failing.

In fact, treating this program was on my list of things-to-do but, as a lot of retired beings, I'm overbooked.
Maybe it's because I'm not working as quickly as years before.

I dropped the process name to use the application path because there are cases where the process is not named like the application.
As System Event was giving the application's alias I decided to use it and don't extract the appName which would require to be deprived of the name extension.

The ability to select several lines was written in my own project so I coded it here hoping that it would be useful for you too.

Yvan KOENIG (VALLAURIS, France) samedi 8 mars 2014 21:21:28



Le 08/03/2014 à 20:17, Michael Grant <email@hidden> a écrit :

Merci Yvan, I sent mine before I saw yours. Is the try block really necessary? 
Michael


On Sat, Mar 8, 2014 at 7:16 AM, koenig.yvan <email@hidden> wrote:
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>)
 >Re: Scriptable multi-clipboard utility? (From: "koenig.yvan" <email@hidden>)
 >Re: Scriptable multi-clipboard utility? (From: Michael Grant <email@hidden>)

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