Applescript and Max Audio

Discussion in 'Mac Programming' started by downingp, Oct 25, 2013.

  1. downingp, Oct 25, 2013
    Last edited by a moderator: Oct 25, 2013

    downingp macrumors 6502a

    Joined:
    Jun 26, 2006
    #1
    A few years ago, I setup an applescript to help me convert a FLAC file into Apple Lossless automatically which worked very well. Ever since I upgraded to OSX Mavericks, my script is no longer working. The "Max" program opens and inputs the FLAC files appropriately, but it never starts converting. Any ideas what could be going on?
    Thanks.

    The script is listed below:

    Code:
    tell application "Max" to activate
    
    tell application "Max"
    	convert theFile
    end tell
    
    delay 1
    
    tell application "System Events"
    	tell process "Max"
    		click button "Convert" of toolbar of window "File Conversion"
    		
    		set encoderOpen to true
    		repeat while encoderOpen is true
    			try
    				window "Encoder"
    			on error
    				set encoderOpen to false
    			end try
    		end repeat
    		
    	end tell
    end tell
     
  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    Make sure AppleScript Editor is allowed to control your computer. Check System Preferences --> Security & Privacy --> Privacy tab.

    This example worked for me on Mavericks with Max version 0.9.1 :

    Code:
    set theFile to choose file
    
    tell application "Max" to activate
    
    tell application "Max"
    	convert theFile
    end tell
    
    delay 1
    
    tell application "System Events"
    	tell process "Max"
    		click button "Convert" of toolbar 1 of window "File Conversion"
    		
    		set encoderOpen to true
    		repeat while encoderOpen is true
    			try
    				window "Encoder"
    			on error
    				set encoderOpen to false
    			end try
    		end repeat
    		
    	end tell
    end tell
    Note : I've added the first line because your code uses variable theFile but it's not defined.
     

    Attached Files:

  3. downingp thread starter macrumors 6502a

    Joined:
    Jun 26, 2006
    #3
    I actually found the security feature just before you posted this. The problem now is the check mark doesn't stay checked for very long under "hazel" Any thoughts?
     
  4. downingp thread starter macrumors 6502a

    Joined:
    Jun 26, 2006
    #4
    I used hazel to automate my process as well. Do you use hazel by chance?
     
  5. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
  6. downingp thread starter macrumors 6502a

    Joined:
    Jun 26, 2006
    #6
    How do you use your AppleScript then?
     
  7. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
  8. downingp thread starter macrumors 6502a

    Joined:
    Jun 26, 2006
    #8
    When I run the script within Applescript I get the following error:

    System Events got an error: button "Convert" of toolbar of window "File Conversion" of process "Max" doesn’t understand the “click” message.

    Do you get this error?
     
  9. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #9
    No error when using this :

    Code:
    click button "Convert" of toolbar 1 of window "File Conversion"
    the error you're describing when using this :

    Code:
    click button "Convert" of toolbar of window "File Conversion"
    Notice the difference e.g. toolbar 1. See my post #2.

    Note : I've looked at Hazel and now I understand why you didn't declare theFile . Hazel uses theFile to refer to the file being processed.
     
  10. downingp thread starter macrumors 6502a

    Joined:
    Jun 26, 2006
    #10
    Despite that change, I still get the same error. The script does not understand "click"
     
  11. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #11
    Strange. It doesn't really help but here's a screenshot of the script after running it. As you can see in Events and Replies the button was clicked.
     

    Attached Files:

Share This Page