QuickTime X Hidden Preferences Scripts

Been a lurker for a bit & finally decided to register. Ran into a problem and I couldn’t think of any other better place to ask :slight_smile:

So, a few days ago, I found a bunch of Terminal commands for hidden QuickTime X preferences

http://forums.macrumors.com/showthread.php?t=775514

I then made scripts for those commands:

http://web.me.com/celebi23/QuickTimeXScripts/Main.html

I’m now trying to make a script for the amount of “Recent Items” shown.

http://i23.photobucket.com/albums/b355/eisnerguy1/RecentItems_1.png

I did get this to work but, then I think I accidentally did something & now it won’t work. The terminal commands work fine on there own as does the “Restore Defaults” part of the code. For some reason, the script is not saving the preference change:

set recentItems to {"1", "5", "10", "15", "20", "30", "50"}

display dialog (choose from list recentItems with prompt "Select the amount of Recent Items to display.")

if recentItems is "1" then
	do shell script "defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit -integer 1"
else if recentItems is "5" then
	do shell script "defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit -integer 5"
else if recentItems is "10" then
	do shell script "defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit -integer 10"
else if recentItems is "15" then
	do shell script "defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit -integer 15"
else if recentItems is "20" then
	do shell script "defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit -integer 20"
else if recentItems is "30" then
	do shell script "defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit -integer 30"
else if recentItems is "50" then
	do shell script "defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit -integer 50"
end if


set buttonClicked to button returned of (display dialog "Please restart QuickTime Player for the preference changes to take effect." & return buttons {"Restore defaults", "Restart QuickTime Player"} default button 2 with icon alias ((path to me) & "Contents:Resources:QuickTimePlayerX_128.icns" as text))

if buttonClicked is "Restore defaults" then
	do shell script "defaults delete com.apple.QuickTimePlayerX NSRecentDocumentsLimit"
	tell application "QuickTime Player" to quit
	delay 3 -- give the app time to quit, otherwise the next command may fail
	tell application "QuickTime Player" to activate
else if buttonClicked is "Restart QuickTime Player" then
	tell application "QuickTime Player" to quit
	delay 3 -- give the app time to quit, otherwise the next command may fail
	tell application "QuickTime Player" to activate
end if

Any help would be greatly appreciated.

I see a couple problems:

  1. You have the statement… if recentItems is “1” then… recentItems is a list so how can it be compared to the string “1”? You really want to be checking the result of choose list instead of recentItems.
  2. display dialog (choose from list…)??? What is that? display dialog and choose from list are 2 separate things.

Here’s how I would rewrite your script:

set recentItems to {"1", "5", "10", "15", "20", "30", "50"}

choose from list recentItems with prompt "Select the amount of Recent Items to display." OK button name "Select" cancel button name "Quit"
tell result
	if it is false then error number -128 -- cancel/quit the program
	set choice to first item
end tell

do shell script "defaults write com.apple.QuickTimePlayerX NSRecentDocumentsLimit -integer " & choice

set buttonClicked to button returned of (display dialog "Please restart QuickTime Player for the preference changes to take effect." & return buttons {"Restore defaults", "Restart QuickTime Player"} default button 2 with icon alias ((path to me) & "Contents:Resources:QuickTimePlayerX_128.icns" as text))

if buttonClicked is "Restore defaults" then
	do shell script "defaults delete com.apple.QuickTimePlayerX NSRecentDocumentsLimit"
end if

tell application "QuickTime Player" to quit
delay 3 -- give the app time to quit, otherwise the next command may fail
tell application "QuickTime Player" to activate

Thank you for you help!! :smiley: :smiley: :smiley: :D. It works now :smiley: I’m putting you into the credits in the scripts’ ReadMe file :smiley: