• 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: Michael Grant <email@hidden>
  • Date: Sat, 08 Mar 2014 13:12:35 -0600

A couple more tweaks:
☞ If the user cancels, 'choose from list' returns {«class fals»:false}, not the string "false" — need to coerce to text (I haven't been able to get consistent results working with the chevron class).
☞ Running my original version, the choose from list dialog didn't always have focus, so I couldn't use it without mousing. To rectify I put it inside the tell system events block with an activate command.
☞ I assume if the user cancels, they won't want to paste the full text; also no need to modify the clipboard.
☞ The try block doesn't seem necessary as far as I can tell.

So, here's my current version:

tell application "System Events"

set frontApp to (name of (processes where it is frontmost)) as text

set fullClipText to (the clipboard as text)

set clipPars to paragraphs of fullClipText

activate

set myChoice to ((choose from list clipPars) as text)

end tell


tell application frontApp

activate

if myChoice is not "false" then

set the clipboard to myChoice

tell application "System Events" to keystroke "v" using {command down}

delay 1

set the clipboard to fullClipText

end if

end tell






On Sat, Mar 8, 2014 at 4:52 AM, 2551 <email@hidden> wrote:
Thanks, I think that could be quite useful actually for some kinds of edting tasks I do. I made a minor change to avoid “false” being pasted if the user cancels the choose from list dialog box.

Here’s my slightly modified version:

tell application "System Events"
set frontApp to (name of (processes where it is frontmost)) as text
end tell

set fullClipText to (the clipboard as text)

set clipPars to paragraphs of fullClipText

try
set the clipboard to ((choose from list clipPars) as text)


--added to avoid "false" if user cancels choose dialogue
if (the clipboard) is equal to "false" then
set the clipboard to fullClipText
else


delay 1
tell application frontApp
activate
tell application "System Events" to keystroke "v" using {command down}
end tell


delay 1
end if
end try

set the clipboard to fullClipText

 _______________________________________________
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



--
There's really no such thing as translating. It's all a scam. We basically just make stuff up and try to make it sound plausible.
 _______________________________________________
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: Christopher Stone <email@hidden>
References: 
 >Scriptable multi-clipboard utility? (From: Michael Grant <email@hidden>)
 >Re: Scriptable multi-clipboard utility? (From: Michael Grant <email@hidden>)

  • Prev by Date: build a list of mailboxes
  • Next by Date: Re: Scriptable multi-clipboard utility?
  • Previous by thread: Re: Scriptable multi-clipboard utility?
  • Next by thread: Re: Scriptable multi-clipboard utility?
  • Index(es):
    • Date
    • Thread