Clipboard action not working

Looks like that’s helping for now! This has been so finicky that I’m hesitant to proclaim victory just yet, but in a few tests I just ran it looks good.

Thanks for all the help guys!

If anyone does have a way of using applescripts I would still be interested though…

(Applescripts will have just the same problem of timing, I’m afraid)

Hey Mendel,

I've adjusted the timing in this one, and it works reliably on my system. (You might have to tweak the pause lengths.)

In your first macro the primary problem was the failure to allow the original Cmd-C time to populate the clipboard. (See orange highlighted actions in the macro.)

I did NOT see anywhere in this thread an instruction to CMD-Click the highlighted text in Papers in order to allow Cmd-C to copy it. Did I miss it? (Yep - missed/misunderstood.)

If not then consider that sort of thing necessary information in a help request for next time.

-Chris


Copy as quote.kmmacros (6.4 KB)

Papers is very AppleScriptable, however its object model is a bit arcane and lacking some basic things like the selection.

This will work ONLY if the front document is open and NOT in a library-viewer-window-preview – AND if there is only 1 highlight.

tell application "Papers"
  set displayedPub to displayed publications of front library window
  
  if length of displayedPub = 1 then
    set displayedPub to item 1 of displayedPub
  else
    error "Number of documents!"
  end if
  
  tell displayedPub
    set displayedPubOriginalPath to original path of its primary file item
    set docCiteKey to its citekey
  end tell
  
  set theHighlightItem to first highlight item where its source file's original path is displayedPubOriginalPath
  tell theHighlightItem to set highlightText to its source text
    
end tell

highlightText & linefeed & linefeed & docCiteKey

As far as I can tell there is NO way to determine if a highlight is selected.

I’m reasonably impressed with their AppleScript Getting Started Page:

http://support.mekentosj.com/kb/tutorials/scripting-papers-3-for-mac-with-applescript-a-getting-started-guide

-Chris

[quote="ccstone, post:23, topic:2483"]
I did NOT see anywhere in this thread an instruction to CMD-Click the highlighted text in Papers in order to allow Cmd-C to copy it.[/quote]

In rereading things I found this:

When I read it the first and second times I did not understand that Mendel meant click the highlighted text.

I was sure I had tried simply clicking the highlight and that had failed to select it, but perhaps I missed the target area by a small fraction.

So to clarify – Cmd-Click is not necessary to select a highlight – just Click.

-Chris