• 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: Traversing windows with Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Traversing windows with Cocoa


  • Subject: Re: Traversing windows with Cocoa
  • From: aldo kurnia <email@hidden>
  • Date: Mon, 3 Mar 2008 14:45:24 -0800 (PST)

Hi,
I'm not trying to manipulate anything in the protected memory space. All I want to do is determine the name of the application / process from the window, and then bring it to the front-most index.

UI scripting is exactly what I've tried to do and failed. For example, you'd expect the following script to work, but not all application supports the functions I used here and it will fail on some application (including the ones that I need to support):

-- the window title we're looking for
set winName to "someWinTitle"

tell application "System Events"
    set procs to processes whose visible is true
end tell

-- go through all visible processes
repeat with i from 1 to (count of procs)
   set appName to name of item i of procs

   tell application appName
      set winCount to count of windows
      -- go through all the app's windows
      repeat with x from 1 to winCount
         -- match the window's title
         if ((name of (item x of windows)) as string) is winName then
            set index of item x of windows to 1
            display dialog "success!! " & winName & " is a " & appName & " window"
            return
         end if
      end repeat
   end tell
end repeat

display dialog "window " & winName & " not found"


It seems to me that Applescript provides a very limited solution for my problem, which is why I started looking into Accessibility API (and still got stuck).

Aldo

Jens Alfke <email@hidden> wrote:
On 3 Mar '08, at 1:10 PM, aldo kurnia wrote:

> Given a window's TITLE, how do you create a reference to it,
> determine what kind of application the window is (the name of the
> application/executable)? and how do you move that window to the front?

Applications run in protected memory spaces. There's no way to get
direct access to windows of other processes. (This is a Good Thing for
system security.)



> Applescript is also not very useful since the application I'm trying
> to support doesn't support some of the basic window scripts.

The UI scripting support might help; its AppleScript commands end up
generating fake UI events in the target app, so you can manipulate
even apps that aren't scriptable. I don't know how to use that stuff,
though. Check the docs.

—Jens


---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Traversing windows with Cocoa
      • From: Bill Cheeseman <email@hidden>
References: 
 >Re: Traversing windows with Cocoa (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Better Anti-Aliasing for drawing?
  • Next by Date: Re: NSURLConnection SSL connection with expired cert.
  • Previous by thread: Re: Traversing windows with Cocoa
  • Next by thread: Re: Traversing windows with Cocoa
  • Index(es):
    • Date
    • Thread