• 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: Scripting Bridge, System Events, current application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Bridge, System Events, current application


  • Subject: Re: Scripting Bridge, System Events, current application
  • From: Pete Siemsen <email@hidden>
  • Date: Wed, 4 Aug 2010 11:11:28 -0600

On Aug 4, 2010, at 9:52 AM, Matt Neuburg wrote:

On Wed, 4 Aug 2010 09:15:59 -0600, Pete Siemsen <email@hidden> said:
I'm using Scripting Bridge to implement some behavior in an Objective-C program.  Much of it works, but I'm having trouble creating Scripting Bridge code that implements the following AppleScript behavior:

 set previousApp to the name of the current application
 -- some stuff happens here that includes "activating" an app
 tell application previousApp to activate

Why are you using Scripting Bridge for this? You are already in Objective-C, so just do it directly. NSWorkspace (and, on Snow Leopard, NSRunningApplication) gives you everything you need. m.

Because I didn't know about NSWorkspace or NSRunningApplication :-)  Thanks!  Wow, that's a lot of learning time wasted^h^h^h^h^h^h used unproductively on Scripting Bridge :-)  So with this new knowledge, the code might be, like,

NSRunningApplication *previousApp;

int getPreviousApp(void) {
//      previousApp = ???;
        return SUCCESS;
}

int restorePreviousApp() {
        if ([previousApp activateWithOptions:NSApplicationActivateIgnoringOtherApps] == NO)
            return FAILURE;
        return SUCCESS;
}

How would I set previousApp to the app to the "current application", the one that has focus when my program starts?  Perhaps using runningProcessWithProcessIdentifier, but I still don't know how to identify the process that has focus (is frontmost) when my application starts.

- Pete

 _______________________________________________
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: Scripting Bridge, System Events, current application
  • Next by Date: Re: Scripting Bridge, System Events, current application
  • Previous by thread: Re: Scripting Bridge, System Events, current application
  • Next by thread: Re: Scripting Bridge, System Events, current application
  • Index(es):
    • Date
    • Thread