The code for running a menu item is
All you need to test it out is the language independent name of the select tool menu item.
Here is an article on the topic:
You'll find more info here, including a plug-in for finding hidden menu items, of which there are many. There are lots of hidden menu items because Acrobat used to be all menu driven. When they switched the UI to all the fancy panels they never got rid of the menus, just hid them.
I already have it activated. My question is how to DEACTIVATE.
You deactivate it by selecting another tool. There is always one active, you just have to decide which one you want, for example the Hand tool, which is the default.
You should really avoid using "execMenuItem". The existence of the menu items and their names are highly dependent on the Acrobat version. You won't be able to count on that menu item being available or in the same location in future releases.
Rethink your use case.
Well Actually, the menu items never really go away. Do you have my Hidden Menu Items plug-in? Download it from the link I provided above. There's stuff in there going way back, and it still works.
However I get you're point. It's like using undocumented code. But just about any code these days is a problem because of all the 3rd party viewers, especially on mobile.
That's all true but I'm still going to recommend the questioner rethink their solution. As the mobile viewers get more script enabled, you won't be able to rely on the menu items being there.
We are controlling the user environment because users are coming to our machine to fill out the forms.
The only events you can use in Acrobat are related to form fields, bookmarks or links, or when a file is opened, closed, saved or printed, and when the application is first opened.
Yes, there is a way, but there are no events that will provide any kind of direct detection. Instead you have to go about it indirectly. There are two possible solutions.
1. Start an interval timer at the same time you start the drawing tool. Use the timer script to test for a new annotation on the page. Give the timer some maximum time as a safety. Maybe popup a message box to ask the user if they want to continue. I've used this method before and it works well as long as the users are well behaved.
2. Recreate the drawing tool in JS so you control it. This works well for circle and rectangle annots. What you do is create a page size invisible button. Use the button to detect mouse up and mouse down events. On mouse down create a circle or square annot at the mouse point. Start a timer to pick up the inbetween movements for drawing out the circle or square, then use Mouse up to kill the timer.
The #2 method is more reliable, but requires more coding on your part.