• 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
Re: System Events: window id's instead of window names?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System Events: window id's instead of window names?


  • Subject: Re: System Events: window id's instead of window names?
  • From: Deivy Marck Petrescu <email@hidden>
  • Date: Tue, 22 Jun 2010 10:11:18 -0400

On Jun 22, 2010, at 9:21 AM, Thomas Fischer wrote:

> Hi Daniel,
>
> I'm not quite clear what you are trying to achieve.
> But from short testing, my impression is that "process" windows don't have ids, while application windows do.
> So for example
>
> tell application "System Events"
> 	get id of window 2 of application "TextEdit"
> end tell
>
> works for me (10.6.4), while
>
> tell application "System Events"
> 	get id of window 2 of process "TextEdit"
> end tell
>
> yields an error.
> Does this help in any way?
>
> Best
> Thomas
>
>
> Am 22.06.2010 um 01:40 schrieb Daniel Brown:
>
>> Using System Events, is there any way to get id's of windows instead
>> of just their names?
>>
>> I've written a little script to horizontally tile the windows of the
>> current application, but if multiple windows have the same name then
>> it only finds one of them and fails to tile properly. Here's the
>> script:
>>
>> tell application "Finder"
>>     set {screenWidth, screenHeight} to {item 3, item 4} of (get
>> bounds of window of desktop)
>> end tell
>>
>> tell application "System Events"
>>     set ws to windows of process (name of first process whose
>> frontmost = true and visible = true)
>>     set {width, height} to {screenWidth / (count ws), screenHeight}
>>     set i to 0
>>     repeat with w in ws
>>         set {position of w, size of w} to {{i * width, 0}, {width, height}}
>>         set i to i + 1
>>     end repeat
>> end tell
>>
>> The problem appears to be that the windows given to me by System
>> Events are identified only by name, not id—I get an error if I ask
>> `get id of w` in the loop. And the reason that I'm going through
>> System Events is that I want tiling to work even for non-scriptable
>> applications.
>>
>> Is there a way to identify the windows of a non-scriptable application
>> by id? Or maybe I'm just making a dumb mistake somewhere?
>>
>> Dan


Thomas,
You got the id of the window because TextEdit is scriptable and might (it does in this case) have "id" as its window's property.
If you try your script with a non-scriptable app, you will get an error.

Deivy Petrescu
email@hidden



 _______________________________________________
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

  • Follow-Ups:
    • Re: System Events: window id's instead of window names?
      • From: Thomas Fischer <email@hidden>
References: 
 >System Events: window id's instead of window names? (From: Daniel Brown <email@hidden>)
 >Re: System Events: window id's instead of window names? (From: Thomas Fischer <email@hidden>)

  • Prev by Date: Re: System Events: window id's instead of window names?
  • Next by Date: Re: System Events: window id's instead of window names?
  • Previous by thread: Re: System Events: window id's instead of window names?
  • Next by thread: Re: System Events: window id's instead of window names?
  • Index(es):
    • Date
    • Thread