check if menu paste is active

Hi, I am trying to use applescript to check if a menu is active or not, I have this script but I can’t make it work.

The idea is to see if the paste command is active


delay 2
tell application "FileMaker Pro"
	activate
	tell application "System Events"
		tell menu 1 of menu bar item 4 of menu bar 1
			set W to value of attribute "AXMenuItemCmdChar" of menu item 4
		end tell
	end tell
end tell

Any idea will help :slight_smile:

Hi,

the reference must contain the process


activate application "FileMaker Pro"
tell application "System Events"
	tell process "FileMaker Pro"
		tell menu 1 of menu bar item 4 of menu bar 1
			set W to value of attribute "AXMenuItemCmdChar" of menu item 4
		end tell
	end tell
end tell

Thank you for replaying, you are right. But I have the same problem. it returns an “X” as a result in both cases when the command is available and when its not. :frowning:

I have clean the code to make it more secure and I got this.



activate application "FileMaker Pro"
tell application "System Events"
	tell process "FileMaker Pro"
		set X to properties of attribute "AXMenuItemCmdChar" of menu item "Paste" of menu "Edit" of menu bar item "Edit" of menu bar 1
	end tell
end tell

This works just fine, but I get the same properties when the command is active or not. I am using FileMaker and the idea is to know if theres a dialog active or not. any ideas will help :slight_smile:

git it. this is the answer!


activate application "FileMaker Pro"
tell application "System Events"
	tell process "FileMaker Pro"
		set X to properties of attribute "AXEnabled" of menu item "Paste" of menu "Edit" of menu bar item "Edit" of menu bar 1
	end tell
end tell

you can test if a menu item is enabled with the attribute AXEnabled and if it’s checked with the attribute AXMenuItemMarkChar for example


activate application "Whatever"
tell application "System Events"
	tell process "Whatever"
		set AXMenuItemMarkCharValue to value of attribute "AXMenuItemMarkChar" of menu item . 
		set isChecked to AXMenuItemMarkCharValue is character id 10003
		set isEnabled to value of attribute "AXEnabled" of menu item . 
	end tell
end tell