applescript - repeat if exists document x

Terry Judd tsj at unimelb.edu.au
Thu Mar 12 18:08:56 EDT 2009


On 12/03/09 10:10 PM, "Jim Sims" <sims at ezpzapps.com> wrote:

> Works slick for Keynote.
> 
> A current issue I'm up against has been getting all this to also work
> with Preview.app, for some reason Preview seems to not play well with
> applescript. Seems that System Events has a better shot at my goal.
> 
> So, I changed direction a bit and am now going with:
> 
> tell application "System Events"
> get name of every window of application process "Preview"
> end tell
> return the result
> 
> Doing the above seems to require enabling access for assistive
> devices, but that is not a problem.

Hi Jim,

I haven't ever tried capturing the name and path of every open window but I
have worked with the frontmost application and document quite a bit and many
of the methods should be applicable. As you've already worked out, if an
application is scriptable then you can usually do good things by working
with its doccuments, otherwise you need to resort to System Events and
windows. A couple of useful things to try are the window description...

tell application "System Events"
    get the description of every window of process <<processName>>
end tell

...'standard window' usually equates to a document so you can then iterate
through each window and get the name (AXtitle) and path (AXdocument)...

tell application "System Events"
    tell process <<processName>>
        get the value of attribute <<attributeName>> of window <<windowNum>>
    end tell
end tell

HTH,

Terry...




More information about the use-livecode mailing list