• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Windows properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Windows properties


  • Subject: Windows properties
  • From: KOENIG Yvan <email@hidden>
  • Date: Sun, 12 Feb 2012 15:57:52 +0100

Hello

I'm a bit puzzled.

I ran this simple script :

tell application "Preview"
activate
end tell
tell application "System Events"
tell application process "Preview"
title of every window
--> {"soucoupe YK.png", "Sans titre"}
properties of window 1
--> {minimum value:missing value, orientation:missing value, position:{971, 173}, class:window, role description:"fenêtre standard", accessibility description:missing value, focused:false, title:"soucoupe YK.png", size:{408, 279}, value:missing value, help:missing value, enabled:missing value, maximum value:missing value, role:"AXWindow", entire contents:{}, subrole:"AXStandardWindow", selected:missing value, name:"soucoupe YK.png", description:"fenêtre standard"}
end tell
end tell


I'm puzzled because I don't get the properties listed in System Events dictionary :

window n [inh. item; see also Processes Suite] : A window.
elements
contained by application, processes, UI elements.
properties
bounds (rectangle) : The bounding rectangle of the window.
closeable (boolean, r/o) : Whether the window has a close box.
document (document, r/o) : The document whose contents are being displayed in the window.
floating (boolean, r/o) : Whether the window floats.
id (integer, r/o) : The unique identifier of the window.
index (integer) : The index of the window, ordered front to back.
miniaturizable (boolean, r/o) : Whether the window can be miniaturized.
miniaturized (boolean) : Whether the window is currently miniaturized.
modal (boolean, r/o) : Whether the window is the application's current modal window.
name (text) : The full title of the window.
resizable (boolean, r/o) : Whether the window can be resized.
titled (boolean, r/o) : Whether the window has a title bar.
visible (boolean) : Whether the window is currently visible.
zoomable (boolean, r/o) : Whether the window can be zoomed.
zoomed (boolean) : Whether the window is currently zoomed.

In fact I'm able to get these properties only when I 'speak' to the application itself.
Example :
tell application "Numbers"
properties of window 1
--> {zoomed:false, miniaturized:false, name:"Sans titre", floating:false, modal:false, document:document "Sans titre", miniaturizable:true, class:window, closeable:true, resizable:true, zoomable:true, visible:true, id:795, bounds:{1079, 632, 2279, 1479}, titled:true, index:1}
end tell

But this piece of code apply only when the app is scriptable.

In other words, how may I get the path of a document which is open in a non scriptable application like Preview ?

Searching in old threads I found one which allowed me to write :

activate application "Preview"
tell application "System Events" to tell application process "Preview"
title of every window
--> {"soucoupe YK.png", "Sans titre"}
set theURL to value of attribute "AXDocument" of window 1
(*
Leaves theURL undefined if the document was never saved before.
If the doc was saved once, returns something like
"file://localhost/Important/pour ebay/soucoupe YK.png"*)
end tell
try
theURL
(*
scheme 1 with Satimage *)
alias of (URL info for theURL)
--> alias "Macintosh HD:Important:pour ebay:soucoupe YK.png"
(*
scheme 2 with Satimage *)
unescapeURL theURL
--> "file://localhost/Important/pour ebay/soucoupe YK.png"
(POSIX file result) as alias
--> alias "Macintosh HD:Important:pour ebay:soucoupe YK.png"
on error
"never saved"
end try

Am'I really forced to trigger Satimage to unescape theURL ?

Yvan KOENIG (VALLAURIS, France) dimanche 12 février 2012 15:57:44






 _______________________________________________
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

  • Prev by Date: Re: More Geek Speak
  • Next by Date: Rép: Windows properties
  • Previous by thread: Re: More Geek Speak
  • Next by thread: Rép: Windows properties
  • Index(es):
    • Date
    • Thread