Keyboard maestro not reliable with Scrivener's Dynamic Menus: is scripting an alternative?

Keyboard Maestro is not reliable in dealing with Scrivener’s dynamic menus. By dynamic, I mean that menu items change depending on where you are (in a document, in the binder, etc).

Take for example the View → Text Editing → Show/Hide Page View menu item.

If I am in Page View, the menu item will change to hide page view. If I am not in Page View, the menu item will change to show Page View

With either System Pref. Shortcuts or keyboard maestro, it is easy to toggle Show/Hide Page View.

What I am trying to do is find a way to trigger only Hide Page View:

  • if the document is in Show Page View format, then it would trigger Hide Page View

  • if the document is already in Hide Page View format, then nothing happens.

Why do I want this ?

  • sometimes I want to change the interface setup and change a multitude of menu items in sequence.

  • it is not only a question of show/hide page view. If it was, I would simply toggle. This applies to many many more similar menu items. I would like to create a model script I could apply to many other dynamic menu items.

I am not asking about keyboard maestro. I have been working with the moderators of the site for months on this and have not found a reliable answer. Some macros work, but only part of the time. I was wondering if a script could work.

thanks in advance very much for your time and help !