• 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: Respond to DVD/CD insertion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Respond to DVD/CD insertion


  • Subject: Re: Respond to DVD/CD insertion
  • From: Mark Hunte <email@hidden>
  • Date: Fri, 21 Nov 2014 22:12:01 +0000

If you can find a ( maybe https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html  )trigger then you can get the dvd volume and do stuff like in this example.

set get_name to "/Volumes/" & (do shell script "dru_get=`drutil status -drive internal|  grep -ie Name| awk -FName:\\  ' {print $2}'`;df -h |grep  $dru_get |awk -F\"/Volumes/\" ' {print $2}'  ")

do shell script "open  " & quoted form of get_name



We use drutil status -drive internal  and grep to find the /dev/disk number of the dvd  drive, awk, df -h  and grep to get the volume path.





On 21 Nov 2014, at 19:51, Bill Cheeseman <email@hidden> wrote:


On Nov 21, 2014, at 2:01 PM, Stockly, Ed <email@hidden> wrote:

He inserts a
CD, and when that's ejected, he removes it and inserts the next, with no
more interaction.

Here's a thought, which I have tested only up to a point. 

The accessibility API, which underlies GUI Scripting, has a notification called, in plain English, 'row count changed'. So, open a Finder window, set it to show the Desktop, put it in list view, and tell your person to leave it alone. Then set up my UI Actions product <http://pfiddlesoft.com/uiactions> to launch a script whenever the Finder issues the 'row count changed' notification. That will happen every time a disk is inserted or ejected, because the Finder window will add or remove the inserted or ejected disk from the list in the window.

I used my UI Browser product just now to confirm that the notification is issued under these circumstances. In fact, several notifications are issued for each insertion. You can use certain filters in UI Actions to control the circumstances under which an action is triggered. However, you will likely have to do some filtering in the triggered script itself -- such as distinguishing between a disk inserted and disk ejected event (the count goes up or down). One way to get around the multiple notifications per insertion event is to prevent the script from executing if it already executed in the last x seconds, and work out the threshold interval so it is shorter than the time it takes to perform the operation you're performing on each disk.

-- 

Bill Cheeseman - email@hidden
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: Respond to DVD/CD insertion
      • From: Shane Stanley <email@hidden>
References: 
 >Respond to DVD/CD insertion (From: "Stockly, Ed" <email@hidden>)
 >Re: Respond to DVD/CD insertion (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: Scripting alerts
  • Next by Date: Re: Respond to DVD/CD insertion
  • Previous by thread: Re: Respond to DVD/CD insertion
  • Next by thread: Re: Respond to DVD/CD insertion
  • Index(es):
    • Date
    • Thread