Send clipboard contents, or current browser URL to another application?

I'm wanting a script that will send the URL of the current page in Google Chrome to another application (called Droplr). I don't really know any AppleScript but got so far by using keyboard shortcuts:

tell application "Google Chrome" to activate
tell application "System Events" to key code 37 using {command down}
tell application "System Events" to key code 8 using {command down}
(Command-L to select the address bar, and then Command-C to copy the URL to the clipboard.)

What I then want to do it open the URL copied to the clipboard with the application called Droplr.

Is this possible in any way?
Also, I'm wondering if it's possible with AppleScript to maybe send the URL of the current page in Chrome directly to the application without replicating the keyboard shortcuts to select the address bar and copy to the clipboard?

iMac i7 8GB RAM | MacBook Pro 15" 2.0 GHz 2GB RAM | Mac mini 2.0 GHz 2GB RAM, Mac OS X (10.6.5)

Posted on Nov 26, 2010 2:37 AM

Reply
2 replies

Nov 26, 2010 8:31 AM in response to JonoH

(Command-L to select the address bar, and then Command-C to copy the URL to the clipboard.)


ick, yuck, yuck.

While I see where you're going, it really is the least desirable path, and this isn't really AppleScript's strength.

To get the URL of the current page in Chrome, use:

tell application "Google Chrome"
set theURL to URL of active tab of window 1
end tell


Now you have the URL in your AppleScript variable theURL.

This approach is far preferable to your copy paste technique because:

a) it doesn't require Chrome to be the active app
b) it doesn't rely on UI scripting (e.g. pressing key combinations)
c) it doesn't touch the clipboard (which may have preexisting data on it that the user wanted)

So that's the good news.
The bad news is that Droplr isn't AppleScriptable, meaning you can't use AppleScript commands to drive it directly. Instead you have to revert to UI Scripting to emulate the user actions (select the menu, type theURL, click OK, etc.

I don't have a Droplr account so I can't easily test that part for you.

Nov 26, 2010 8:47 AM in response to Camelot

Haha. Yea, I didn't think that was a very elegant way of doing it.

There's nowhere to paste or type a url in the Droplr app. You can drag the favicon of the page from Chrome's address bar to the dock icon or the menu bar icon. Or it's also possible to send a URL from LaunchBar to the app (don't know if this helps at all?)




Camelot wrote:
The bad news is that Droplr isn't AppleScriptable, meaning you can't use AppleScript commands to drive it directly. Instead you have to revert to UI Scripting to emulate the user actions (select the menu, type theURL, click OK, etc.


I wouldn't know where to start to do this. Is there a tutorial site you can recommend with info on this?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Send clipboard contents, or current browser URL to another application?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.