Re: Is app running?
Re: Is app running?
- Subject: Re: Is app running?
- From: Bill Cheeseman <email@hidden>
- Date: Sun, 08 May 2005 18:35:16 -0400
on 2005-05-08 1:02 PM, deivy petrescu at email@hidden wrote:
> Experimenting with that I tried other AX attributes and seemed to
> have a problem with "AXURL".
> "AXURL" should give me the URL of the file or application in the
> system, something like:
>
> ³file://localhost/Applications/AppleScript/Script Editor.app/²
>
> for SE. However, running the script:
>
> tell application "System Events"
> tell process "Dock"
> get value of attribute "AXURL" of UI element "QuickTime
> Player" of list 1
> end tell
> end tell
> ---> «class » id 1 of application "System Events"
>
> Am I missing something?
No, your script is syntactically correct. Unfortunately, the AXURL attribute
of a Dock item is returned as a URL object (Cocoa's NSURL? Carbon's CFURL?
-- I'm not sure, as I sit here), and GUI Scripting doesn't seem to know how
to decompose or translate it into a string. I'm not sure if a consistent
convention has been established within Apple as to how to return AXURL
attributes (see below for Safari's approach, which differs from that of the
Dock). If you look at the AXURL attribute of a Dock item in PreFab UI
Browser or Apple's UI Element Inspector (Accessibility Inspector in Tiger),
you'll see that the value of the URL is in fact a file URL representing a
URL of the form <file://localhost/....>. But you don't seem to be able to
access it in GUI Scripting.
In other applications (Safari is the only one I've tried, but Mail and
TextEdit are likely the same), an AXURL object is an attribute of a
clickable Web link, and it is returned as a string that GUI Scripting can
access. For example, if you use UI Browser to navigate the UI elements in a
Safari page that has clickable links, you'll find that the links are
"AXLink" UI elements, and that one of an AXLink's attributes is an "AXURL"
attribute of type string (speaking loosely). For example,
"http://googleblog.blogspot.com/". A GUI Scripting reference to it looks
like this, and in Safari it DOES work (watch for line wrap in the middle):
tell application "System Events"
tell process "Safari"
get value of attribute "AXURL" of UI element "Google Blog" of group
4 of UI element 1 of scroll area 1 of group 4 of window "About Google"
end tell
end tell
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden