Jump to content
  • Announcements

    • Allan

      Forum Rules   04/13/2018

      Hello folks! As some things are being fixed, we'll keep you updated. Per hour the Forum Rules don't have a dedicated "Tab", so here is the place that we have our Rules back. New Users Lounge > [READ] - InsanelyMac Forum Rules - The InsanelyMac Staff Team. 
Sign in to follow this  
djrbx

Anyone know how to clean up this code?

2 posts in this topic

Recommended Posts

I written a small applescript droplet which would allow a user to drop quicktime movie files with mutiple audio channels assignments and the script would then change all those assignments into their given field. Left, Right, Center, Etc.

 

Does anyone know a way to compress the code so it would not be so redundant in calling the same function over and over?

 

Thanks

 

-------------------------------------------------------------------------------------------------
--																	--
-- v0.7.5-1															--
-- Changes the value of audio channel settings (L,R,C, etc.) within movie files	--
--																	--
-------------------------------------------------------------------------------------------------
display dialog "Please drop QuickTime Movies onto script to run. Thanks! :-P"

on open myFileList

 -- Allows script to be used in either Leopard or Snow Leopard
 -- Sets the name of appID "com.apple.quicktime" --> qtPlayer
 tell application "Finder"
	 set qtPlayer to name of application id "com.apple.quicktimeplayer"
 end tell

 -- Makes the target application the active window
 tell application id "com.apple.quicktimeplayer"
	 activate
	 repeat with myFile in myFileList
		 set myMovie to (open myFile)

		 -- Call on "System Events" for QuickTime Player 7
		 tell application id "com.apple.systemevents"
			 tell process qtPlayer

				 -- Shows Movie Properties
				 tell menu bar 1
					 tell menu bar item "Window"
						 tell menu "Window"
							 click menu item "Show Movie Properties"
							 activate
						 end tell
					 end tell
				 end tell

				 --
				 select row 3 of table 1 of scroll area 1 of window 1
				 click radio button 3 of tab group 1 of window 1

				 tell pop up button 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1
					 click
					 click menu item "Left" of menu 1
				 end tell
				 --
				 select row 4 of table 1 of scroll area 1 of window 1
				 click radio button 3 of tab group 1 of window 1

				 tell pop up button 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1
					 click
					 click menu item "Right" of menu 1
				 end tell
				 --
				 select row 5 of table 1 of scroll area 1 of window 1
				 click radio button 3 of tab group 1 of window 1

				 tell pop up button 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1
					 click
					 click menu item "Center" of menu 1
				 end tell
				 --
				 select row 6 of table 1 of scroll area 1 of window 1
				 click radio button 3 of tab group 1 of window 1

				 tell pop up button 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1
					 click
					 click menu item "LFE Screen" of menu 1
				 end tell
				 --
				 select row 7 of table 1 of scroll area 1 of window 1
				 click radio button 3 of tab group 1 of window 1

				 tell pop up button 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1
					 click
					 click menu item "Left Surround" of menu 1
				 end tell
				 --
				 select row 8 of table 1 of scroll area 1 of window 1
				 click radio button 3 of tab group 1 of window 1

				 tell pop up button 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1
					 click
					 click menu item "Right Surround" of menu 1
				 end tell
				 --
				 select row 9 of table 1 of scroll area 1 of window 1
				 click radio button 3 of tab group 1 of window 1

				 tell pop up button 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1
					 click
					 click menu item "Left Total" of menu 1
				 end tell
				 --
				 select row 10 of table 1 of scroll area 1 of window 1
				 click radio button 3 of tab group 1 of window 1

				 tell pop up button 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 1
					 click
					 click menu item "Right Total" of menu 1
				 end tell
				 --

				 -- Check to make QuickTime Player active window before saving
				 tell application id "com.apple.quicktimeplayer"
					 activate
				 end tell

				 -- Saves any and all changes then closes all windows
				 tell menu bar 1
					 tell menu bar item "File"
						 tell menu "File"
							 click menu item "Close"
							 click menu item "Save"
							 click menu item "Close"
						 end tell
					 end tell
				 end tell

			 end tell
		 end tell
		 close myMovie
	 end repeat
	 quit
 end tell
end open

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×