• 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: Why are 2 Terminal windows opening with NSAppleScript?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why are 2 Terminal windows opening with NSAppleScript?


  • Subject: Re: Why are 2 Terminal windows opening with NSAppleScript?
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 08 Mar 2012 10:17:40 -0600

On Mar 7, 2012, at 9:32 PM, Prime Coderama wrote:

> If no Terminal app is open, the following code opens TWO Terminal windows. Why is it doing this? I only want one window to open.
>
> If only one Terminal window is open, then the following code opens only ONE additional window.
>
> NSAppleScript* terminal = [[NSAppleScript alloc] initWithSource:
>                           [NSString stringWithFormat:
>                                @"tell application \"Terminal\"\n"
>                                @"    activate\n"
>                                @"    do script \"echo %@\"\n"
>                                @"    tell the front window\n"
>                                @"    set title displays shell path to false\n"
>                                @"    set title displays custom title to true\n"
>                                @"    set custom title to \"My session! %@\"\n"
>                                @"    end tell\n"
>                                @"end tell", name, name]];
>
> [terminal executeAndReturnError:nil];

Hint: what happens if you just launch Terminal?

Terminal opens a window (or, depending on settings, a window group) at launch.  Then, as you note, your script opens an additional window.

Regards,
Ken


_______________________________________________

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


References: 
 >Why are 2 Terminal windows opening with NSAppleScript? (From: Prime Coderama <email@hidden>)

  • Prev by Date: Re: Accessing array in thread safe way
  • Next by Date: Re: ivar access during -finalize
  • Previous by thread: Why are 2 Terminal windows opening with NSAppleScript?
  • Next by thread: Re: Why are 2 Terminal windows opening with NSAppleScript?
  • Index(es):
    • Date
    • Thread