Hi, I've been using Mailplane with the OmniFocus plugin for a bit now, but 
when using the preview pane for my main GMail window found that there was 
no way to get the plugin to copy useful links.  With preview pane enabled 
the link on the main page never changes.  That should be fine, just pop the 
message out and get the URL from the other window, but no such luck with 
that either. The applescript interface always copies the link from the main 
window regardless of what window is in front, which with the preview pane 
view is always a link to the inbox.  I've put together the following 
workaround in the plugin, which focuses on whatever window is in front, 
uses the copy link menu item to get the URL from that window into the 
clipboard, then populates a Mailplane link, browser link, and an iPhone 
formatted link (works properly in mobile safari unlike the browser link) 
from that, and repopulates the clipboard with the original value.

While this works, it requires assistive device support to work.  Is there 
any chance we could get an interface in the applescript dictionary to get 
the currentUrl for the front window rather than just the main application 
window?

*on* clipping(CurrentApplicationInfo, ClippingTasks)

-- Grab Safari specific stuff

*tell* *application* "Mailplane"

*set* MyPageTitle *to* currentTitle

*set* MyURL *to* currentURL

*set* MyBrowserURL *to* currentBrowserURL

*end* *tell*

*tell* *application* "System Events"

*tell* *process* "Mailplane" *to* *set* frontmost *to* true

*set* oldclip *to* (*the clipboard* as *text*)

*set the clipboard to* ""

 *tell* *process* "Mailplane" *to* *click* *menu item* "Copy as Mailplane 
URL" *of* *menu* "Edit" *of* *menu bar item* "Edit" *of* *menu bar* 1

 *set* MyURL *to* ""

*repeat* *while* MyURL = ""

*try*

*repeat* *while* "" = (*the clipboard* as *text*)

*end* *repeat*

*set* MyURL *to* (*the clipboard* as *text*)

*end* *try*

*end* *repeat*

 *set* MyBrowserURL *to* "https://mail.google.com/mail/u/0/#"; & (*word* -2 *
of* MyURL) & "/" & (*last* *word* *of* MyURL)

*set* MyIphoneURL *to* "https://mail.google.com/mail/mu/mp/896/#cv/Inbox/"; 
& (*word* -2 *of* MyURL) & "/" & (*last* *word* *of* MyURL)

 *set the clipboard to* ((oldclip) *as* *text*)

 *end* *tell*

 *if* MyPageTitle *is* "" *or* MyPageTitle *is* *missing value* *then*

*set* MyPageTitle *to* "Mailplane"

*end* *if*

 *using terms from* *application* "OmniFocus"

*repeat* *with* MyTask *in* ClippingTasks

*tell* MyTask

*set* MySummary *to* (*summarize* note *as* *rich text*)

*if* MySummary *is* "" *or* MySummary *is* *missing value* *then*

*set* MySummary *to* MyPageTitle

*end* *if*

 *set* name *to* MyPageTitle

*tell* note

-- Build up a prefix, inserting tail to head

*insert* return & return at *before* *first* *character*

 -- TODO: Bundles need to be able to pass in localized values as part of 
their settings or some such.

*set* MyHeader *to* MyPageTitle

*insert* "Browser Link" at *before* *first* *character*

*set* value *of* *attribute* "link" *of* *style* *of* *paragraph* 1 *to* 
MyBrowserURL

*insert* return at *before* *first* *character*

*insert* "Mailplane Link" at *before* *first* *character*

*set* value *of* *attribute* "link" *of* *style* *of* *paragraph* 1 *to* 
MyURL -- We know that there is a newline since we just inserted it!

*insert* return at *before* *first* *character*

*insert* "iPhone Link" at *before* *first* *character*

*set* value *of* *attribute* "link" *of* *style* *of* *paragraph* 1 *to* 
MyIphoneURL

*end* *tell*

 *end* *tell*

*end* *repeat*

*return* {CurrentApplicationInfo, {}} -- handled all the tasks

*end* *using terms from*

*end* clipping

-- 
You received this message because you are subscribed to the Google Groups 
"mailplaneapp" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/mailplaneapp/-/2gpRyAo8RpAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/mailplaneapp?hl=en.

Reply via email to