How to Record the Error Result of a Command?

Hello, all, and thanks for this wonderful forum (and Keyboard Maestro).

So I've got a script that needs to try to select a menu then store the result of that action, then try it again and store that result. (Basically, I need to verify that a certain Twitter account is loaded before a script proceeds, and there's no good way to do it progmatically as there is no scripting dictionary). I could attempt it then set "failure aborts macro" as a way of trapping the error I need, but that seems very messy. Can anyone suggest anything else? If the menu select command works, I want to store some variable, but if it fails I want to trap that error and show a message that I need to fix my Twitter accounts before running the script.

(In Filemaker, you can turn error trapping on, do a command and if there's an error, get(last error message) to see what the result was, I am hoping there's something like this I can call on)

Hey Peter,

What software are you using?

-Chris

Hi, the Twitter client is Tweetbot. I mainly want to select this menu option, Main Window @jlist2, and record whether it failed or not, without cancelling the whole macro (as I could do with "failure aborts macro").

If it fails, it will try one more menu command (since I run it on different computers, which connect to different tiwtter accounts), and if both fail I will report this to the user and stop the execution.

23(edit

Hey Peter,

Look at the IF-THEN action with menu items:

image

You can also do something like this:

Download ⇢ Select Menu Item -- Result.kmmacros (5.5 KB)

Be sure to see how I've set the error options in the Gear-Menu of the Select a Menu Item action.

-Chris

1 Like

Wow, both are great, thank you! I will try both out ASAP!