I am trying to get a Button ID from an application window that is not "live" text. I was wondering if I could use a Find Image of the "Button ID" and use the new OCR to set it to a variable that I can use.
Any help would me appreciated!
While this is possible using Found Image and OCR, it would be more reliable to use AppleScript UI scripting. What app is displaying this window?
This is within the Stream Deck App. I updated the screen above.
Yes, you can use the Find Image action to find the Button ID and then extract the area of the field, and then OCR it. Seems to work fine in my test (although the image was double size, so real world testing is needed). You may also want to explicitly capture the image are to verify you are getting the field, including all the text, and excluding any border edges which can confuse the OCR.
Keyboard Maestro Actions.kmactions (18 KB)
Ah, that's so simple. Thanks Peter! The OCR option is going to open up so many possibilities - what a great feature.
Instead of using a KM Variable named "Result" , I'd suggest using a Local variable, like
This will avoid any potential conflicts that other macros, or even concurrent executions of the same macro, might create. As a general rule, I always use Local or Instance Variables . unless I have a specific need for a global variable (which is rare).
Indeed, local variables are fine for 95% of my macros. (That being said, I still have to convert lots of global variables in old macros…)