The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   Get URL and Title in OmniWeb (http://forums.omnigroup.com/showthread.php?t=10023)

MoofTheStoof 2008-09-26 01:15 PM

Get URL and Title in OmniWeb
 
I'm trying to reproduce this:
[code]tell application "Safari"
set thisPage to do JavaScript "document.URL" in document 1
set thisTitle to do JavaScript "document.title" in document 1
end tell[/code]

In OmniWeb. I've opened OmniWeb in AppleScript, but I'm too much of a novice to puzzle it out. I found "GetWindowInfo," but haven't figured out how to assign the proper values to the "thisPage" and "thisTitle" variables.

This is the first half of an AppleScript by Scott Haneda at osxhelp.com for quickly sending off an email with URL and Title, but I want a version for OmniWeb since I'm moving back to OmniWeb full time.

whpalmer4 2008-09-26 01:59 PM

This should accomplish the same thing:

[code]
tell application "OmniWeb"
set windowID to id of front window
set windowInfo to GetWindowInfo windowID
set thisURL to first item of windowInfo
set thisPage to second item of windowInfo
end tell
[/code]

whpalmer4 2008-09-26 02:01 PM

By the way, not that learning how to do this with a script is a bad thing, but what's wrong with File->Mail Link to This Page?

MoofTheStoof 2008-09-26 03:09 PM

That solution works perfectly. Thanks.

[QUOTE=whpalmer4;47863]By the way, not that learning how to do this with a script is a bad thing, but what's wrong with File->Mail Link to This Page?[/QUOTE]

The way I have it set up, now, the second half of the script inserts those variables into an email template in Mail.app and sends it to a pre-set address. The script resides in my Scripts folder, and is accessible from the AppleScript menu bar item. So the current procedure is to browse to a page I want to send (I have multiple copies of the script for a couple different receiver addresses), select the appropriate script from the menu, and go back to browsing. Pull-down a menu, click a menu item. Done. The "Mail Link to This Page could do the same thing, but adds a couple of steps because I still have to start typing the recipient's name, then click "send." It's a nice functionality, and I'm sure I'll use it if I'm sending a page to somebody I don't already have a script for, but I'm used to my way and my way still saves a few seconds.

The final script:
[code]-- Based on script made by Scott Haneda
-- http://osxhelp.com
-- 02/13/2008

-- Get the current URL
tell application "OmniWeb"
set windowID to id of front window
set windowInfo to GetWindowInfo windowID
set thisPage to first item of windowInfo
set thisTitle to second item of windowInfo
end tell

-- Create a new email message in mail.app
tell application "Mail"
set this_message to make new outgoing message at beginning of every outgoing message
tell this_message
make new to recipient at beginning of to recipients ¬
with properties {address:"example@example.com", «class rdsn»:"FirstName LastName"}
set the subject to "URL from Moof"
set the content to "This is an URL sent from an AppleScript for speed's sake:

" & thisTitle & "
" & thisPage & "

--
Moof"
end tell
send this_message -- Send the email message
end tell[/code]


All times are GMT -8. The time now is 02:00 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.