Bhishan Posted September 18, 2018 Share Posted September 18, 2018 (edited) Link to workflow: workflow_link. Using the information from this apple stackexchange link, I tried to create an apple script to click the menu "Get LaTeX" from the app called "Mathpix Snipping Tool". NOTE: The Mathpix Snipping Tool is a great app, it can get the OCR of any image and converts it into LaTeX item. Since it is difficult to remember so many keyboard shortcuts, I decided to write alfred keyword to simulate "ctrl-cmd-m" of this app, but got problem and posted the question. Here is the code: tell application "Mathpix Snipping Tool" activate end tell tell application "System Events" click menu item "Get LaTeX" of menu 1 end tell When I run the first part in terminal using `osascript myscript.scpt` it runs fine. However, when I run the whole code it gives error. mymathpix.scpt:94:138: execution error: System Events got an error: Can’t get menu 1. (-1728) The application is not a regular application like Safari with menu items, its just hanging in top of the menubar and we can use some keyboard shortcuts to run the commands. How to fix the problem? Thanks. Edited September 18, 2018 by Bhishan fixed typo Link to comment
deanishe Posted September 18, 2018 Share Posted September 18, 2018 I've changed the title of your topic. [HOWTO] is for explanations of how to do something, not for questions. Bhishan 1 Link to comment
CJK Posted September 21, 2018 Share Posted September 21, 2018 (edited) @Bhishan, this is the general form the AppleScript code will take when trying to access a menu bar icon and its menu: use application "System Events" property P : a reference to the process named "Mathpix Snipping Tool" property M : a reference to menu bar item 1 of menu bar 2 of P property I : a reference to the menu item named "Get LaTeX" of menu 1 of M click M click I It doesn't work for every single menu bar application, and there's an annoying 5-second delay between the first click command and the second. This is a known, persistent feature that has various documented so-called solutions, none of which are reliable, but you can have a Google and see what works for you. Don't forget to make sure Terminal (or whichever program is executing the above script) has accessibility privileges granted to it. Edited September 21, 2018 by CJK Bhishan 1 Link to comment
nicpaesk Posted December 3, 2020 Share Posted December 3, 2020 Hi, could you share the final workflow please ? It would be very useful !! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now