How to do something because of the result of an AppleScript

When I set up a macro to executee a script, how do I then do something in Keyboard Maestro based on the result of that script?

For example, I am writing a script to test if the front-most application is in full screen mode, and if it is, to intercept the escape key. If it is not, then I’d like the escape key to be pressed.

I have the following script set to execute, but short of actually doing the keypress in the script, how do I tell KM “Do this is script returns false and do the other thing if it returns true”?

try
   tell application "System Events"
      tell (first application process whose frontmost is true)
         tell (first window whose subrole is "AXStandardWindow")
            set myFullscreen to value of attribute "AXFullScreen"
            if myFullscreen then
               -- return something
            else
               -- return something else
            end if
         end tell
      end tell
   end tell
end try

Does this help?

1 Like

Thank you, yes, that has it all sorted and spurious presses of escape no longer exit the Full Screen Mode.

1 Like

Great! If you can mark my reply as the one that answered your question, that would be great. Thanks!

1 Like

Would just like to say, this post was very helpful to me. Thanks! I was passing results through the clipboard before, which was very silly.

Sorry about the super long delay, I never saw that second followup from you. Better late than never?