Hi. I wrote a small handler that I want to run from system preferences when a video disk is inserted. The handler is:
use AppleScript version “2.4” – Yosemite (10.10) or later
use scripting additions
on video DVD appeared theObject
log "video DVD appeared: " & theDisk
set UserInput to the button returned of (display dialog ¬
"choose DVD option" buttons {"Rip", "Play"} with icon stop)
if UserInput = "Rip" then
tell application "iSkysoft iMedia Converter Deluxe"
activate
end tell
else
tell application "DVD Player"
activate
end tell
end if
end video DVD appeared
I set the script to be run in system prefs when a video DVD is inserted. However when I insert a disk, the handler is not run. Any idea what I may have done wrong? Thanks in advance!
Tried your suggestion of using theObject in place of theDisk, the dialog does come up but then I get a beach ball of death in the dialog endlessly. Had to log out to stop it. What does the log command do anyway? I’m a novice and am not familiar with that command. Thanks!
I experienced the same problem here when I tested the on video DVD appeared handler. I’m not really sure what to suggest. This appears to be an Apple bug. I’ve not used this feature in years so I cannot tell you when the problem appeared.
A solution I found was to ask the Finder to display the dialog for you:
on video DVD appeared theObject
tell application "Finder"
display alert "Testing - " & theObject
end tell
end video DVD appeared
The log command is a way of logging values. When run from Script Debugger, or the Script Editor, the parameter to the log command is recorded in the Event Log display. When a script is run in other environments, the output of the log command may or may not be recorded. In the case of the on video DVD appeared handler, unfortunately the log is not recorded.
If you are using Script Debugger, you can simulate the on video DVD appeared and then step through your code within Script Debugger to see what is happening. When you are done, you can save your script (with debugging disabled) and have the system invoke it when you insert a DVD.
Thanks for your help Mark. Since nothing I’ve been able to do has worked, and it works in the simulated environment, I submitted an email to Light Night Software to see if they knew about any bugs in El Capitan that may be causing the problem. Thanks again.
In my experiments you need to wrap any statement that presents a dialog box in a tell application "Finder" block to avoid the hang you are experiencing.