My (pseudo-)pimp Automatic MacTheRipper AppleScript

Discussion in 'Mac Programming' started by kalisphoenix, Feb 2, 2007.

  1. macrumors 65816

    kalisphoenix

    Joined:
    Jul 26, 2005
    Messages:
    1,234
    #1
    Yeah, so, I want to put all of my DVDs on my Mac mini. Not all at once, just one or two here or there. The problem is that it's a media center, so I removed the keyboard and mouse. In other words, I needed to put a DVD in and have the Mac mini rip it... automatically. But sometimes, I want to put in a DVD and just watch it. Thankfully, I learned that Front Row ignores your System Preferences-set direction for what to do when you insert a DVD. So if I want to rip a movie, I exit Front Row and insert the DVD. If I want to watch it, I just stay in Front Row -- no problem.

    Anyway, I wanted to post my script on here. It's worked fine thusfar, but I'm sure there are a couple of instances where it would not work quite right (or at all). What I'd like to know is if anyone has any suggestions for making this script more foolproof, more elegant, and more efficient.

    I'm a beginner at AppleScript, so please be gentle with me.

    Code:
    tell application "MacTheRipper"
            activate
            delay 10
    end tell
    
    tell application "System Events"
            tell process "MacTheRipper"
                    tell window 1
                            click button "Go!"
                            delay 5
                    end tell
            end tell
    end tell
    
    tell application "System Events"
            tell process "MacTheRipper"
                    tell window 1
                            tell sheet 1
                                    try
                                            click button "Continue"
                                    end try
                                    try
                                            click button "Ok"
                                    end try
                                    try
                                            click button "Open"
                                    end try
                            end tell
                    end tell
            end tell
    end tell
    
    set MagicNumber to 0
    repeat until MagicNumber is 1
            delay 10
            tell application "System Events"
                    tell process "MacTheRipper"
                            tell window 1
                                    tell sheet 1
                                            try
                                                    click button "Close"
                                                    set MagicNumber to 1
                                            end try
                                    end tell
                            end tell
                    end tell
            end tell
    end repeat
    
    tell application "Finder"
            do shell script ("drutil eject")
    end tell
    Any ideas?
     
  2. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Messages:
    5,478
    Location:
    Fox Lake, IL
    #2
    I'm not at my mac, but have you checked if MTR has an Applescript dictionary so you don't have to do everything with System Events?

    You should be able to open MTR.app in Applescript and it should expose the dictionary, look for a Suite that has MacTheRipper in the name.

    Good Luck and PS. When you are done, you should share the app!
     
  3. macrumors 68000

    bearbo

    Joined:
    Jul 20, 2006
    Messages:
    1,863
    #3
    does using system events require enabling the GUI scripting? if so you probably want to mention it...

    i never really got GUI scripting to work very well tho :( i'll try to learn something from this script.
     
  4. macrumors 65816

    kalisphoenix

    Joined:
    Jul 26, 2005
    Messages:
    1,234
    #4
    Sorry, folks, I was posting this in a hurry today and didn't think to mention the crap that should have been mentioned first.

    1. No AS dictionary for MtR, much to my continuing frustration. I'm not sure if the next version will have an AS dictionary, because I'm not a beta tester :( Are any BTs out there that can confirm or deny this?

    2. Yeah, it requires GUI scripting to work. Which is a tremendous pain in the ass.

    I'm thinking about trying to cheese a few bucks so I can become a paid beta tester for MtR. At least then I'd know :-|
     

Share This Page