Applescript and QuickTime

Posted:
in Genius Bar edited January 2014
Yesterday when I would execute an applescript with:



tell application "QuickTime Player"



it would open the OS X version of QuickTime.



For some reason today, (I don't remember changing any settings) this call tries to start classic and tries to launch the OS 9 version of QuickTime. It seems that they are named the same. How can you distinguish the two?



Thanks in advance.

Comments

  • Reply 1 of 10
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by macrules101

    Yesterday when I would execute an applescript with:



    tell application "QuickTime Player"



    it would open the OS X version of QuickTime.



    For some reason today, (I don't remember changing any settings) this call tries to start classic and tries to launch the OS 9 version of QuickTime. It seems that they are named the same. How can you distinguish the two?



    Thanks in advance.




    Quote:

    tell application "Finder"

    set QTP_path to application file id "com.apple.QuickTime Player" as Unicode text

    open QTP_path

    end tell



    -------------------------

    [This script was automatically tagged for color coded syntax by Convert Script to Markup Code]
  • Reply 2 of 10
    Thanks, that works.
  • Reply 3 of 10
    This code works to open up the program, but how would i send commands to QuickTime now?



    Thanks
  • Reply 4 of 10
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by macrules101

    This code works to open up the program, but how would i send commands to QuickTime now?



    Thanks




    Just use the variable QTP_path, which is now a reference to the OS X QuickTime Player.app, the same way you were originally going to use the string "QuickTime Player". Here is a sample that I just did to test it out; just put the same commands that you were going to put in the "Tell App "QuickTime Player"" in this Tell block instead of the trivial ones I used:



    Quote:

    Open this script in a new Script Editor window.



    tell application "Finder" to set QTP_path to application file id "com.apple.QuickTime Player" as Unicode text



    tell application QTP_path

    activate

    name of front window

    end tell





    -------------------------

    [This script was automatically tagged for color coded syntax by Convert Script to Markup Code]



    When I run this, I get the result

    Code:




    "Untitled 1"









    In the Results window. This is indeed the name of the front window, so it works.



    See that link that says "Open this script in a new Script Editor window."? Click that to automatically copy the script into Script Editor on your computer.
  • Reply 5 of 10
    slugheadslughead Posts: 1,169member
    where do you learn all this applescript stuff?



    the dictionary is sooooooooooooooooooooooooooooooooo useless
  • Reply 6 of 10
    This does launch the app, however, I don't think it allows you to call anything specific to QuickTime player. It seems that it does not realize that it should use the QTPlayer dictionary.



    For instance, this code does not work:



    tell application "Finder" to set QTP_path to application file id "com.apple.QuickTime Player" as Unicode text



    tell application QTP_path

    \tactivate

    \tset {the_height, the_width} to dimensions of movie 1

    end tell





    Is what is happening making sense?



    thanks
  • Reply 7 of 10
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by slughead

    where do you learn all this applescript stuff?



    the dictionary is sooooooooooooooooooooooooooooooooo useless




    Boy ain't THAT the truth! The whole chapter 19 of AppleScript in a Nutshell is about how the dictionary sucks.



    MacScripter.net is your savior. Actually, I'm going to post this problem over there - I thought the workaround for the script opening the Classic app would work, but he's right, it does not address the commands to QT Player.
  • Reply 8 of 10
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by macrules101

    This does launch the app, however, I don't think it allows you to call anything specific to QuickTime player. It seems that it does not realize that it should use the QTPlayer dictionary.



    For instance, this code does not work:



    tell application "Finder" to set QTP_path to application file id "com.apple.QuickTime Player" as Unicode text



    tell application QTP_path

    \tactivate

    \tset {the_height, the_width} to dimensions of movie 1

    end tell





    Is what is happening making sense?



    thanks




    You're right. I just tried both ways and you have to say "Tell app "QuickTime Player"" for the "movie" term to be recognized.



    As above, I'll post this on MacScripter.net. I don't have Classic installed, but I saw this as a workaround - obviously it is only a partial workaround.
  • Reply 9 of 10
    lundylundy Posts: 4,466member
    I started a thread at Macscripter.net.



    http://bbs.applescript.net/viewtopic.php?p=37774#37774
  • Reply 10 of 10
    lundylundy Posts: 4,466member
    Here is Kel's reply - at MacScripter.net



    Quote:

    Posted: Fri Mar 25, 2005 2:54 pm Post subject: using terms from\t

    Hi,



    Surround the tell block with 'using terms from' so that at compile time it knows what app to take the dictionary terms from. Here's an example:



    set the_movie to choose file

    tell application "Finder"

    set QT_path to (application file id "TVOD") as string

    end tell

    using terms from application "QuickTime Player"

    tell application QT_path

    launch -- opens QT without the initial blank movie

    activate

    open the_movie

    tell front movie

    stop

    rewind

    end tell

    end tell

    end using terms from



    gl,

    _________________

    Kel



Sign In or Register to comment.