Applescript error NSReceiverEvaluationScriptError: 4

Adonsa

Registered
Hi,
This applescript script worked fine until I performed security update SecUpd2005-009Ti to System 10.4.3

tell application "Safari" to activate
tell application "System Events"
tell application process "Safari"
click menu item "Reset Safari…" of menu "Safari" of menu bar 1
try
click button "Reset" of window 1
end try
end tell
end tell


Now it fails to perform, and returns this error:

System Events got an error:
NSReceiverEvaluationScriptError: 4

Safari ver. 2.0.2
System Tiger 10.4.3
G-4 667 upgraded to 1.8 Ghz
1.5 Gigs RAM.


Any idea what the cause and remedy might be?
Much appreciate your comments and insights.

Thanks much,

Adonsa
 
Sounds like GUI scripting somehow got turned off. Open AppleScript Utility ("/Applications/AppleScript/AppleScript Utility.app") and turn it back on. It should work fine after that.

Hope this helps.
 
Hi Mikuro,
Thanks much for replying.
Mikuro said:
Open AppleScript Utility ("/Applications/AppleScript/AppleScript Utility.app") and turn it back on.

I checked, and it's still on... hmmm, so
I made sure that the script has the ellipsis, not 3 dots, then I made sure that universal access assistive devices is enabled.

The only thing monumental I had done between the last time the script worked, and when it ceased was that I installed the latest Apple security update (yes I did the permissions thing before and after the install). It's really tough to imagine that a security upgrader would diddle with Applescript.I have no right to fingerpoint to the Apple upgrader, the problem could be coincidental.

I ran the script thru Script Debugger Demo and here's what happened: Initially I thought that Applescript couldn't find Safari, but looking at where the pointer stopped, it looks like Applescript can't find Safari's reset button anymore, even though it is, in fact, real.

While attempting to step thru the script, the pointer stopped here and wouldn't let me go further, then the error was returned.

tell application "Safari" to activate
tell application "System Events"
tell application process "Safari"

---->click menu item "Reset Safari…" of menu "Safari" of menu bar 1
try
click button "Reset" of window 1
end try
end tell

end tell

Script Debugger's Script Error window returned these errors at each of its 3 tabs:
The Message Tab displayed this error:
-System Events got an error: NSReceiverEvaluationScriptError: 4
The partial Result tab returned this:
{}
The Application Tab returned this:
application "System Events"

After I did all that, I checked to see if the problem would replicate with a similar script written against the Opera Web Browser. I applied my applescript script to the Opera web browser and the same error was returned. If I may speculate, it appears that Applescript is not getting along with System Events.

tell application "Opera" to activate
tell application "System Events"
tell application process "Opera"
----->click menu item "Delete Private Data…" of menu "Tools" of menu bar 1
try
click button "Delete" of window 1
end try
end tell
end tell

There must be something else I'm overlooking, any assist sure will be appreciated.
Happy New Year, and thanks much!

Adonsa
 
I can't think of any other reason for that error off the top of my head. All I can say is that the script works fine for me, and I also have all the latest security updates installed for 10.4.3. Hmm.

Can you try the script with a different user account? That might offer some clues as to where the problem lies.

And out of curiosity, does this script work for you:
Code:
tell application "System Events"
	tell application process "Safari"
		return the name of every menu item of menu "Safari" of menu bar 1
	end tell
end tell
That ought to return a list of the dozen-or-so items in the Safari menu.
 
Hi Mikuro,

RE:
Mikuro said:
...Can you try the script with a different user account? That might offer some clues as to where the problem lies.

And out of curiosity, does this script work for you:
Code:
tell application "System Events"
	tell application process "Safari"
		return the name of every menu item of menu "Safari" of menu bar 1
	end tell
end tell

Bummer, the infamous NSReceiverEvaluationScriptError: 4
error happened. I took your advice and booted up on an entirely separate drive,(also with System 10.4.3 and the latest security upgrade) an external firewire drive; then I dismounted all other mounted volumes. Confident that everything was isolated, I ran your above script, and, to my horror, the infamous NSReceiverEvaluationScriptError: 4 error occurred again.

Noting that you are not experiencing that error, I wonder if I should write a letter to Apple, to whoever programs Applescript?

I thank you for your advice thru this elusive ordeal.

Thanks and Happy New Year,
Adonsa
 
Hi Mikuro,

This is embarrasing. Another macker helped me to see the light.

Here's a brief rundown.

Prior to performing the Apple security upgrade, no problem.
Afterwards, the elusive and infamous error.
I run the patch, Fruit Menu by Unsanity, and Fruit Menu patches out the word Safari to the left of the File menu and replaces it with an application icon.
And I had been using Fruit Menu for a long time and forgot about it
Shame on me.

I should have turned off fruit menu and any other patcher stuff prior to running the Apple upgrader. So the fruit menu application icon causes Applescript to mis-interpret the Safari menu title into "missing item."

The fix is to turn off Fruit Menu's "Use application icon" option.

So what I must to is write up a proper narrative and send it to both Unsanity and to the MacFixit web site. Of course, having it posted here to MacOsx.com is just as important.

I thank you for enduring all this and for advising me along.

Happy New Year
Adonsa
 
Ohhhh! Glad you found the solution. What a strange compatibility change.

Out of curiosity, what happens when you run this script to return the name of every menu?
Code:
tell application "System Events" to return the name of every menu of menu bar 1 of application process "Safari"

And can you still say "menu 2 of menu bar 1" to get the menu?
 
Back
Top