updated with better support for 10.9+ scripting dialog and privacy behavior