22/05/07
Mise à jour de VLC DVD.scpt

Voir le billet précédent : ouverture automatique des DVD avec VLC.
Télécharger le script : scptVLC4DVD.zip (±27 Ko).
Le script est maintenant doté d'une icône (resource fork), ce qui explique le poids de l'archive. La mise à jour concerne diverses optimisations du code : essentiellement l'abandon de fullscreen remplacé par un keystroke, et une meilleure gestion de la fenêtre…
VLC DVD.scpt
(* VLC DVD.scpt HP <http://blogosx.jupiterii.com> updated May. 23, 2007 *) property lastDVD : "" property VLC : "VLC" on run set isDVD to false quitVLC() set testDisks to do shell script "ls /dev/rdisk?" set diskNumberMax to (count words of findAndReplace("/dev/", "", testDisks)) set itemsDisks to (count words of testDisks) + 1 set diskList to {} set itemNum to 0 repeat try copy word itemNum of testDisks to the end of diskList end try set itemNum to itemNum + 1 if itemNum = itemsDisks then exit repeat end if end repeat try set lastDVD to (lastDVD / 1) try set diskString to "/dev/disk" & lastDVD detectDVD(diskString) if isDVD is true then launchDVD() set diskNumber to lastDVD end if end try end try if isDVD is false then repeat with i from 1 to the count of diskList set this_item to "/dev/" & findAndReplace("rdisk", "disk", (item i of diskList)) set diskNumber to findAndReplace("/dev/disk", "", this_item) try if diskNumber is not equal to lastDVD then detectDVD(this_item) if isDVD is true then launchDVD() exit repeat end if end if end try if (isDVD is true) then exit repeat end if end repeat end if set lastDVD to lastDVD end run on detectDVD(pathDisk) global isDVD, diskNumber set testDisk to ¬ do shell script "diskutil info " & pathDisk ¬ & "|grep -i \" Media Type:\" | awk '{print $3}' | tail -1" if testDisk contains "DVD" then set isDVD to true set lastDVD to diskNumber end if end detectDVD on launchDVD() global diskNumber, isDVD if exists application VLC then tell application VLC to open ":dev:rdisk" & diskNumber tell application "System Events" set frontmost of application process VLC to true tell process VLC keystroke "f" using command down end tell end tell end if end launchDVD on findAndReplace(tofind, toreplace, TheString) set ditd to text item delimiters set res to missing value set text item delimiters to tofind repeat with tis in text items of TheString if res is missing value then set res to tis else set res to res & toreplace & tis end if end repeat set text item delimiters to ditd return res end findAndReplace on quitVLC() tell application "System Events" if exists process VLC then try quit application "VLC" end try end if end tell end quitVLC