What is wrong with this appleScript?

Hello,

I have a very basic appleScript to check a box in an app called Growly Notes which is run via a keyboard maestro appleScript macro.

activate application "Growly Notes"
tell application "System Events"
tell process "Growly Notes"
click checkbox "Show border"  of scroll area 1 of window "Current Ongoing JL Scratchpad"  of application process "Growly Notes"
end tell
end tell

1- is anything obviously wrong with the script ?

2- is there any way to make the script window name independent (works irrespective of the window name).


thank you very much

This is the error message in the keyboard maestro engine log:
2021-10-05 14:29:48 Execute an AppleScript failed with script error: text-script:99:226: execution error: System Events got an error: Can’t get application process "Growly Notes" of process "Growly Notes". (-1728)
2021-10-05 14:29:48 Execute an AppleScript failed with script error: text-script:99:226: execution error: System Events got an error: Can’t get application process "Growly Notes" of process "Growly Notes". (-1728). Macro “Border around notes” cancelled (while executing Execute AppleScript).

Is there a reason why you aren’t simply using Keyboard Maestro for this function? I’ve found AppleScript to be pretty fiddly when trying to manipulate the UI. I have many KM macros that use the “click mouse at found image” for this type of activity. Just a thought. — jay

1 Like

thanks very much for your comment.
I have been using keyboard maestro for years and read through their forum daily and post to their forum regularly, although keep in mind that I am not very intelligent according to my spouse.
Click on specific coordinate is an alternative but is not ideal because it depends on window size and what is displayed.
I am surprised that you bring up click on found image. If there is one KM action that drives me to the edge of sanity it’s that action. In my experience it does not work 70% of the time, and even more frustrating sometimes works, sometimes not, and playing around with the image slider does not help. I am sure that I am doing something wrong but can’t figure out what because the action does not have many options. I also tried many types of images (varying margins).
thanks again very much for your comment

When you’re in the tell process "Growly Notes" block, you shouldn’t include
of application process "Growly Notes" in the command. It’s not merely redundant, it’s wrong from the computer’s point of view because there is no Growly Notes app within the Growly Notes process.

As for referencing a generic window, try of window 1. That will refer to the top window (I’m assuming the window you’re interested in is on the top) regardless of its name.

3 Likes

After deleting , of application process, it works perfectly.
Now, with window 1 works will all windows.
Thanks VERY much !

Well, thankfully, you got a better and more reliable answer than mine! :grinning:

Personally, I’ve had good luck with the KM “found image” action. In any event, glad your problem is sorted. Cheers! — jay

1 Like

thank you and once again I am grateful that you took the time to post a reply to my question