• 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: Option key down in Yosemite
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Option key down in Yosemite


  • Subject: Re: Option key down in Yosemite
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 02 Oct 2014 23:11:19 +1000

On 2 Oct 2014, at 10:54 pm, 2551 <email@hidden> wrote:

Can you get it any shorter 

No, but perhaps sweeter. You said:

tell application "System Events"
set frontapp to (name of processes whose frontmost is true) as string
end tell

tell application frontapp

Getting a list and coercing it to text is inefficient, and always risky because of text item delimiters. "name of process 1" would be better; no list involved.

But more to the point, you're assuming the application name is the same as the process name, and there are plenty of cases where that's not the case.

So you might be better off using something like:

tell application "System Events"
set frontapp to (file of process 1 whose frontmost is true) as text
end tell

tell application frontapp
set zoomed of window 1 to not zoomed of window 1
end tell

That might even deal with cases where you have multiple versions of an app running.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: Option key down in Yosemite
      • From: Robert Poland <email@hidden>
References: 
 >Option key down in Yosemite (From: 2551 <email@hidden>)
 >Re: Option key down in Yosemite (From: Shane Stanley <email@hidden>)
 >Re: Option key down in Yosemite (From: 2551 <email@hidden>)
 >Re: Option key down in Yosemite (From: Shane Stanley <email@hidden>)
 >Re: Option key down in Yosemite (From: 2551 <email@hidden>)

  • Prev by Date: Re: Option key down in Yosemite
  • Next by Date: Re: Option key down in Yosemite
  • Previous by thread: Re: Option key down in Yosemite
  • Next by thread: Re: Option key down in Yosemite
  • Index(es):
    • Date
    • Thread