@ronald, I am confused. I thought you were talking about how to automate the built-in Mac Mojave+ screen shot utility. When that utility is running it is NOT possible to issue any keyboard commands, like a hotkey to trigger a KM Macro.
So, I think you are taking about automating the third party tool Josh Parnham - ShotBox . Is that correct?
If so, obviously that is a completely different task.
Even so, I could not get your UI script to work properly. It did NOT click on the Shotbox (aka "Screen Shot") share button. How and when are you triggering the UI macro?
Also, it would be best to put all scripts in a Code Block, using "applescript" in this case as the language. I have updated your post to do this.
Once I can duplicate the clicking of the share button, I can move on to addressing the other requests you have.