Checking Menu Item - Acrobat

Hi

I have the following script:

tell application "System Events"
	tell process "AdobeAcrobat"
		set pagestatus to selected of menu item "Two-Up" of menu 1 of menu item "Page Display" of menu 1 of menu bar item "View" of menu bar 1 -- check if "Two Up" enabled
	end tell
end tell

The script is intended to return whether the Two-Up menu item is ticked. However it always returns “false”, whatever the state of the menu item (ticked or not ticked). I have looked at properties of the menu item concerned and nothing seems to indicate when the menu item is ticked/selected.

Can anyone help? I am stumped.

Thanks

Hi,

the most reliable way is to check the mark character


tell application "System Events"
	tell process "AdobeAcrobat"
		set twoUpEnabled to (value of attribute "AXMenuItemMarkChar" of menu item "Two-Up" of menu 1 of menu item "Page Display" of menu 1 of menu bar item "View" of menu bar 1) is "✓" -- check if "Two Up" enabled
	end tell
end tell

Saved my life (again)

Thanks, Stefan

Stefan

Have tried to replicate your solution for Skim:

tell application "System Events"
	tell process "Skim"
		set pagestatus to (value of attribute "AXMenuItemMarkChar" of menu item "Facing Pages" of menu 1 of menu item "PDF Display" of menu 1 of menu bar item "PDF" of menu bar 1) is "✓"
	end tell
end tell


But am not getting reliable results.

Any suggestions as to what I am doing wrong?

Thanks

And same problem with Preview:

tell application "System Events"
	tell process "Preview"
		set pagestatus to (value of attribute "AXMenuItemMarkChar" of menu item "Two Pages" of menu 1 of menu item "PDF Display" of menu 1 of menu bar item "View" of menu bar 1) is "✓"
		set pagestatus to properties of menu item "Two Pages" of menu 1 of menu item "PDF Display" of menu 1 of menu bar item "View" of menu bar 1
	end tell
end tell

Not getting expected results

sorry, there is no universal GUI script for all applications.

You have to check the UI elements for each one if certain attributes are available

Understood Stefan

But where did you find that you could address something called “AXMenuItemMarkChar” in the case of Acrobat?

When I ask for properties of the menu item concerned, the closest I see is AXMenuItem?

In short, how does one discover if it is possible to GUI script a particular app in a particular way?

Any clues gratefully received…

OK. Think I have the answer to me question. But looking at Preview, it has the same attribute “AXMenuItemMarkChar”, so I am puzzled why your script does not work for this app.

I use ScriptDebugger for developing scripts, which provides an explorer for elements and properties

GUI scripting is horrible, because it’s more guessing than writing code

OK. Will look at doing this another way, I think

Many thanks

Hello

Is it in 10.6 that you can’t get values out of Preview by gui scipting?
Curious about wether it helps guiscripting that you write into the application bundle that the application supports scripting or not.

Best Regards

McUsr

Hi

I am using 10.5 so cannot answer your question. Can get values out of Preview with GUI scripting on 10.5 but, as Stefan points out, can be a bit hit and miss.

Cheers

Hello kiwilegal

As you are in France, are you running Preview in French or in English ?

If you run it in Frech, you must replace the English menu items names by the French ones in the script.

My own choice is to never use items name but items index.


tell application "Preview" to activate
tell application "System Events"
	tell process "Preview"
		
		set pagestatus to attributes of menu item 2 of menu 1 of menu item 3 of menu 1 of menu bar item 5 of menu bar 1
		
		set pagestatus to (value of attribute "AXMenuItemMarkChar" of menu item 2 of menu 1 of menu item 3 of menu 1 of menu bar item 5 of menu bar 1) is "3"
		
		set pagestatus to (value of attribute "AXMenuItemMarkChar" of menu item 2 of menu 1 of menu item 3 of menu 1 of menu bar item 5 of menu bar 1)
	end tell
end tell

Yvan KOENIG (VALLAURIS, France) dimanche 23 mai 2010 12:46:05