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.
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
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
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
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.
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.
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.
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