help with apple script and firefox

can please someone tell me why this simple apple script wont work in firefox i really hate firefox!!!
tell application “System Events”
tell process “firefox”
click menu item “Recently Closed Tabs” of menu “History” of menu bar 1
end tell
end tell

Although I don’t have a current version of Firefox, it never used to be scriptable. Does it have a dictionary now?

Hello.

I don’t know if our versions of Firefox coincide. Howeer I have the same problem as you with that particularily menuitem, which I guess stems from the fact that the “Recently closed tabs” is a dynamic menu item, and that it isn’t implemented since it isn’t present at all times.

You can file a bug about this with fireFox since it bugs you. :confused:

Edit

It is isn’t a bug, but normal behaviour for a dynamic menu, as DJ Bazzie Wazzie points out in his post below.

It’s not a bug and not Firefox alone whose causing this problem. There are more applications that has the same “problem”. It’s caused, like McUsr also mentioned, by dynamic menu’s who aren’t defined at launch and remains static but are created every time it needs to be drawn on the screen. So when menu History is not shown, the menu item “Recently Closed Tabs” simply doesn’t exists.

So to solve this issue you simply need to show the parent menu first so the menu item within will be available.

tell application "Firefox" to activate
tell application "System Events"
	tell process "firefox"
		perform action "AXPress" of menu "History" of menu bar 1
		-- AXPress action won't wait for the menu "History" be visible
		-- so a small delay is needed to give it time to be available.
		delay 0.2  
		perform action "AXPress" of menu item "Recently Closed Tabs" of menu "History" of menu bar 1
	end tell
end tell

Mote specific, you hate dynamic menus :wink:

Hello.

I’m sorry for calling it a bug. It is of course because the menuitem is resolved after you press the history menu, as DJ Bazzie Wazzie pointed out. I saw the accessibility information as a static structure, and not something which parallelled the way dynamic menus normaly are resolved.

hey thank yopu very much works percetly!