• 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: What is "system events" ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is "system events" ?


  • Subject: Re: What is "system events" ?
  • From: Jim Weisbin <email@hidden>
  • Date: Fri, 20 Oct 2017 14:48:20 -0400

Jean-Christophe Helary <email@hidden
<mailto:email@hidden>> wrote:

> What other practical use cases are there for System Events scripting? Would
> you have a simple example?

Here’s something I use a lot. Using System Events, I can get the duration of an
audio file without having to open, say, Quicktime, and it’s GUI:


tell application "System Events”

set f to audio file f

tell (get contents of f)
        set N to name of f
        set t to (its duration) / (its time scale)
        set hr to text 2 thru 3 of ((100 + t div hours) as string)
        set min to text 2 thru 3 of ((100 + t mod hours div minutes) as string)
        set sec to text 2 thru 3 of ((100 + t mod minutes div 1) as string)
        set frm to text 2 thru 3 of ((100 + t mod 1 * 30) as string)
        set D to ""
        if (hr is not equal to "00") then
                set D to hr & ":"
        end if
        --- use this one if you want frames displayed after a decimal point:
        --- set d to d & min & ":" & sec & "." & frm
        --- use this one if you want no frames displayed:
        set D to D & min & ":" & sec
        end tell
end tell





Jim Weisbin | C.T.O. | Human | Post Human | 27 West 20th Street | Suite 801 |
New York, NY | 10011 |  (212) 352-0211 |  (917) 375-2272 | 2046 Broadway |
Santa Monica, CA | 90404 |  (310) 264-0211 telephone | www.humanworldwide.com
<http://www.humanworldwide.com/>
Click here <http://www.humanworldwide.com/#commercials> to view our online reel


 _______________________________________________
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: What is "system events" ?
      • From: Shane Stanley <email@hidden>
    • Re: What is "system events" ?
      • From: "Stockly, Ed" <email@hidden>
  • Prev by Date: Re: What is "system events" ?
  • Next by Date: Re: What is "system events" ?
  • Previous by thread: Re: What is "system events" ?
  • Next by thread: Re: What is "system events" ?
  • Index(es):
    • Date
    • Thread