Re: Missing something obvious
Re: Missing something obvious
- Subject: Re: Missing something obvious
- From: Mark Ratledge <email@hidden>
- Date: Mon, 14 Dec 2009 19:39:09 -0700
Thanks for everyone's help on this. It works now! They key was
Yvan's suggestion to use:
set myApp to (info for (path to frontmost application))'s short name
instead of: set myApp to name of first application process whose
frontmost is true
and not use the tell application "System Events" end tell structure.
as in:
set the_title to the clipboard
set myApp to (info for (path to frontmost application))'s short name
if myApp is "Pages" then
tell application "Pages"
set the_URL to the selection
end tell
else if myApp is "BBEdit" then
tell application "Preview"
set the_URL to the selection
end tell
else
return
end if
set the_text to " <a href=\"" & the_URL & "\" title=\"" & the_title &
"\" class=\"external\" " & the_title & "</a>"
set the clipboard to the_text
By the way, using Axel's trapping below, the dialog says: myApp
>>>System Events<<< class of myApp: Unicode text, which Unicode
text is what we want to see, I assume.
On Dec 13, 2009, at 5:07 AM, Axel Luttgens wrote:
set the_title to the clipboard
tell application "System Events"
set myApp to name of first application process whose frontmost is
true
if myApp is "Pages" then
tell application "Pages"
set the_url to the selection as text
end tell
else if myApp is "BBEdit" then
tell application "BBEdit"
-- Not really for debugging purposes: it is anyway a good
-- idea to avoid to send a subsequent event to BBEdit.
set the url to the selection as text
--set the_url to the selection
end tell
else
-- Obviously, if we come here, nothing will happen wrt the
clipboard.
-- Let's thus try to understand why we're here.
tell application "Finder" to display dialog "myApp: >>>" & myApp
& "<<<" &return & "class of myApp: " & class of myApp
return
end if
end tell
set the_text to " <a href=\"" & the_url & "\" title=\"" &
the_title & "\" class=\"external\">" & the_title & "</a>"
set the clipboard to the_text
_______________________________________________
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