Re: What is "system events" ?
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