Trying to write a macro that runs in a specific App window. (Finale 26)
There are multiple identical buttons and checkboxes in this window. Three buttons named "Select Font...", three buttons named "Position..." and several checkboxes named "Enclosure:"
How do I specify which of the buttons I need to press? Right now if I use "Press a button named 'Set Font...' " it opens all three sub-windows simultaneously.
In this case, I suppose I can use a 'click mouse' at a specific coordinate relative to the window, but with the checkboxes, I need to test their state with an If/Then to see if the button is off before I have the macro press it. In this case, the mouse coordinates will not work because I cannot test the button status first.
If you need help in identifying the button you want in this results list and/or using that in an AppleScript, then please save the BBEdit file (as a .py), zip it, and upload to forum, along with a screenshot of your app windows identifying the button you want to press.
tell application "System Events"
tell application process "Keyboard Maestro"
set oWin to front window
--- AFTER the window elements are displayed, drag the element of interest to the SD code panel
-- then usually replace the window title with "window 1"
-- This is the script you need in KM to press the "Recently Used" button.
tell application "System Events"
tell its application process "Keyboard Maestro"
-- tell its window "Keyboard Maestro Editor — @MOU Move Mouse to FrontMost Window When Window Changes"
tell window 1 -- "Keyboard Maestro Editor — @MOU Move Mouse to FrontMost Window When Window Changes"
tell its group 3
tell its button "⌘" -- you could also use button 1
I am just a user of this program, not the designer.
I can use a Click Mouse action at the coordinates for the buttons. Primarily, I am stuck on how to test the state of the checkboxes.
That macro worked, and confirmed that the buttons are named the same. (Thank you for that - it has already come in handy when a checkbox Name from another window was not identical to the text beside it.)
I will try the Script Debugger suggestion and see what I get. I was ironically also unable to get the app's native scripting language to work with this window either.
Yes, I've got all those covered in my macro. I was so focused on the two checkboxes that are identical "Enclosure..." that I didn't acknowledge that they are the ONLY two identical checkboxes. I can always make sure to manually check those in my workflow since all I need to do is remove the enclosures. At this point this morning I am mostly trying to figure it out just so I know how to do it for any future issues.
I tried a UI Element analyzer from another thread, and unfortunately, it looks like it's pulling the data from the first identical element, regardless of where my mouse pointer is. (I can tell because it pulls the position on the screen into the result and it only ever gives me the coordinates of the topmost identical element.)
Installing Script Debugger is my next shot. I was trying to avoid bringing another app into the mix if I could so I haven't started with that.
Using Script Debugger I can at least find out what the index of the two checkboxes are, and once I get more familiar with AppleScript I am sure I can find a way to check the value of it.
However, as I am a recent Mac user (switched from Windows in March because I figured, hey, I have the time to learn this now) my skills aren't quite there yet to write the AppleScript code needed.
I have successfully used the Click Mouse Action to get all of the buttons using their coordinates, and I've used an Until clause to Click at Found Image to find the Enclosure Checkboxes that are True. (Fortunately, I want them all set to false) This has been successful over 20 test attempts so I think it will work. Later on, once my AppleScript skills are better, I think I can write a script that checks the value of the checkboxes now that I know their index.