I’ve written a application with a script that saves a .prefs file.
When I read it it’s ok, but trying to set 3 checkboxes to its values is coming up with an error -1719 that the window 1 is ‘an invalid index’.
I’ve checked the process name, and it’s correct.
Can anyone tell me what I’m doing wrong, please.
Regards
Santa
on ReadPreferences()
tell application "Finder"
set thePListPath to POSIX path of (thePListFolderPath & "com.MeSelf.rtfLoader.plist")
tell application "System Events"
tell property list file thePListPath
tell contents
set theZip to value of property list item "TheZip"
set theSound to value of property list item "TheSound"
set theSound to value of property list item "ExpandZip"
end tell
end tell
end tell
tell application "System Events" to tell process "rtfd Loader"
try
if value of checkbox 1 of window 1 ≠theZip then click checkbox 1 of window 1
if value of checkbox 2 of window 1 ≠theSound then click checkbox 2 of window 1
if value of checkbox 3 of window 1 ≠expandZip then click checkbox 3 of window 1
on error errmsg
display dialog errmsg
end try
end tell
end tell
end ReadPreferences
OK, I found the way to click the buttons (last three lines of code), but now I’m stuck on trying to set the selection of a pop-up button.
these lines have me stuck.
set the current menu item of button "Year Selector" of window 1 to menu item theYear of button "Year Selector" of window 1
set the current menu item of button "Search" of window 1 to menu item thePlace of button "Search" of window 1
Any help on this one please?
Regard
Santa
on ReadPreferences()
tell application "Finder"
set thePListPath to POSIX path of (thePListFolderPath & "com.MeSelf.rtfLoader.plist")
tell application "System Events"
tell property list file thePListPath
tell contents
set theZip to value of property list item "TheZip"
set theSound to value of property list item "TheSound"
set expandZip to value of property list item "ExpandZip"
set theYear to value of property list item "TheYear"
set thePlace to value of property list item "ThePlace"
end tell
end tell
end tell
end tell
set the current menu item of button "Year Selector" of window 1 to menu item theYear of button "Year Selector" of window 1
set the current menu item of button "Search" of window 1 to menu item thePlace of button "Search" of window 1
if (integer value of button "copyziptodesk" of window 1) ≠theZip then call method "performClick:" of object (button "copyziptodesk" of window 1)
if (integer value of button "soundon" of window 1) ≠theSound then call method "performClick:" of object (button "soundon" of window 1)
if (integer value of button "expandzip" of window 1) ≠expandZip then call method "performClick:" of object (button "expandzip" of window 1)
end ReadPreferences
on ReadPreferences()
tell application "Finder"
set thePListPath to POSIX path of (thePListFolderPath & "com.MeSelf.rtfLoader.plist")
tell application "System Events"
tell property list file thePListPath
tell contents
set theZip to value of property list item "TheZip"
set theSound to value of property list item "TheSound"
set expandZip to value of property list item "ExpandZip"
set theYear to value of property list item "TheYear"
set thePlace to value of property list item "ThePlace"
end tell
end tell
end tell
end tell
try
tell popup button "Year Selector" of window 1
set current menu item to (first menu item whose title is theYear)
end tell
end try
try
tell popup button "Search" of window 1
set current menu item to (first menu item whose title is thePlace)
end tell
end try
if (integer value of button "copyziptodesk" of window 1) ≠theZip then call method "performClick:" of object (button "copyziptodesk" of window 1)
if (integer value of button "soundon" of window 1) ≠theSound then call method "performClick:" of object (button "soundon" of window 1)
if (integer value of button "expandzip" of window 1) ≠expandZip then call method "performClick:" of object (button "expandzip" of window 1)
end ReadPreferences