metronome

202 views
Skip to first unread message

Kalman Tarr

unread,
Jul 12, 2024, 8:21:28 AMJul 12
to QLab
Hi Pros,

I downloaded an app called "metronome" from app store.
Using UI Browse, I get the path to its start button.
This is the script I wrote. But it is not perform the start process I expected. Where did I made any mistake? PLS Help me.
It gives me next 

error "Application isn’t running." number -600 from application "System Events"


tell application "System Events" to tell application process "Metronome"

tell application "Metronome" to activate

tell group 1 of group 2 of group 1 of group 1 of window 1

tell button 3

click

end tell

end tell

end tell


Thanks in advance,

Kalman


micpool

unread,
Jul 12, 2024, 11:28:12 AMJul 12
to QLab
Reverse the first 2 lines of your script?

Kalman Tarr

unread,
Jul 12, 2024, 1:09:20 PMJul 12
to QLab
Hi Mic,

I'm not sure about your question. What do you mean by that?
Could you elaborate?
I get this error:

error "System Events got an error: Can’t get group 2 of group 1 of group 1 of window 1 of application process 1 whose bundle identifier = \"is.gtmetronome\". Invalid index." number -1719

The app couldn't be scriptable? Maybe... Or what else?

Kalman

Kalman Tarr

unread,
Jul 12, 2024, 2:05:28 PMJul 12
to QLab
Hi Mic,
I tried to explicate the whole path to reach the required button.
I'll show you the new script. 
This is the UI Browser advice.

-- Use this script as a wrapper for GUI Scripting statements when you are confident 

that GUI Scripting is available and enabled or that the user knows how to enable it if necessary


activate application "Metronome"

tell application "System Events"

tell process "Metronome"

-- insert GUI Scripting statements here:

tell window 1

tell group 1

tell group 1

tell group 2

tell group 1

tell button 3

click it

end tell

end tell

end tell

end tell

end tell

end tell

end tell

end tell


But it generats error again.

error "System Events got an error: Can’t get group 2 of group 1 of group 1 of window 1 of process \"Metronome\". Invalid index." number -1719 from group 2 of group 1 of group 1 of window 1 of process "Metronome"


What do you think about it?


Best,

Kalman


Message has been deleted

micpool

unread,
Jul 12, 2024, 3:37:50 PMJul 12
to QLab
This is the correct UI script

tell application "System Events" to tell application process "Metronome" to click button 3 of group 2 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1


Button 1 is decrement tempo


Button 2 is decrement tempo


Button 6 is TAP tempo


Button 7 opens size (time signature) pop up, but I can't work out how to go any further in this window with the sliders. Perhaps Rich might have an idea? The App is the first one that comes up in the UK app store by Ivan Chepranov


tell application "System Events" to tell application process "Metronome" to set value of text field 1 of group 2 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1 to "130".  --sets bpm directly


Mic


micpool

unread,
Jul 12, 2024, 3:48:31 PMJul 12
to QLab
This metronome has quite a nifty feature in that it can sync metronomes on iOS devices with the Metronome on the Mac (Obviously with a slight delay to the start to set up a buffer.)

Mic

Kalman Tarr

unread,
Jul 12, 2024, 5:00:44 PMJul 12
to QLab
Hi Mic,
I can't find words to express my gratitude.
It is a great solution!! Yeah
Thanks again.
Sincerely,
Kalman

Kalman Tarr

unread,
Jul 13, 2024, 3:47:00 AMJul 13
to QLab
Hi Mic,
I have to tell you, I don't really understand this extreme high level 'group' paths. I already said that I tried to solve the problem using UI Browser.
The group path more shorter like yours.
But my attempt was unsuccessful.
Can you explain why have to almost "duplicate" the group commands. Am I using the wrong version of UI Browser?
Thanks in advance.

Best,
Kalman

micpool

unread,
Jul 13, 2024, 5:17:42 AMJul 13
to QLab
Sometimes UI browser can’t drill down correctly through  deeply nested UI elements.

As it is no longer maintained, it is what it is.

The UI hierarchy of the Metronome app is particularly tortuous. Perhaps it’s because it was originally written for iOS.

I found the path in Script Debugger, by returning UI  elements of window 1,  flipping down the group disclosure triangles in the result, and looking at all the buttons. With all the groups that had  2 groups inside them, it wasn’t straightforward.

There was a similar problem with Ventura’s Clock.app when we looked at that. UI browser reported a much shorter path, but Rich used a similar brute force method in Applescript Editor to get the correct solution.

Kalman Tarr

unread,
Jul 13, 2024, 7:09:35 AMJul 13
to QLab
Thank you Mic this great detailed reply.

I'm trying to follow the line you draw to understand the nested groups.
I will spend time understanding it.

Thank you Mic this great detailed reply.
I'm trying to follow the line you draw to understand the nested groups.
I think I found the root of the problem. Maybe or maybe not!
If you watching the surface of Metronome app, you can recognize some elements in the bottom of the surface that provide different view mode of the app. (Excuse me, because of my incorrect use of terms, you know my English is not sophisticated. It might be weak, maybe.) Well, I suppose the hidden nested groups are for this situation. UI Browser does not recognize them. OK!  Sorry for being smart.
The main thing is the next, Mic found the good solution to the question.

Thanks again, have a good weekend!
Sincerely,
Kalman

Rich Walsh

unread,
Jul 13, 2024, 10:20:15 AMJul 13
to ql...@googlegroups.com
This is a very strange app… Clicking button 3 didn’t work for me: it was button 4 until I closed and reopened the app, at which point the layout rendered differently and it became button 3 – but no longer responded to a click, even from the Accessibility Inspector…? It now doesn’t work!

Assuming you have the picker window open (after clicking button 7) then this will increase the number of beats in a bar:

tell application "System Events" to tell application process "Metronome" to increment static text 1 of group 2 of group 1 of group 3 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1

This will change the image picker wheel on the right (not sure what to call it):

tell application "System Events" to tell application process "Metronome" to increment image 1 of group 2 of group 1 of group 3 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1

Decrement will go the other way, and you can get the value of the static text to, say, repeat until it’s “7”.

This should close the picker window:

tell application "System Events" to tell application process "Metronome" to click button 1 of group 1 of group 3 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1

I wasted the morning trying to understand picker wheels before just opening the System Events dictionary to see what commands a static text element will respond to.

I used this to find all the UI elements nested in the app – the searchable replies in Script Editor are useful for identifying things, and you can change “value” for “name” or “description” or “class", etc:

tell application "System Events" to tell application process "Metronome"
set allElements to UI elements of window 1
set allInfo to {}
set i to 0
repeat until i = (count allElements)
set eachElement to item (i + 1) of allElements
set end of allInfo to value of eachElement
try
set allElements to allElements & UI elements of eachElement
end try
set i to i + 1
end repeat
end tell
allInfo

You can test for class before adding to allInfo if you only want to get, say, the description of buttons.

All a bit pointless if clicking button 3 doesn’t start the app though…

Rich

Kalman Tarr

unread,
Jul 14, 2024, 9:31:57 AMJul 14
to QLab
Hi Rich,

I am running the scripts you advised.
The last part give back the next answer in ScriptEditor.
You know I am not a Pro, that's why I am contacting to you and Mic.
I absolutely not understand the answer what is means.
I'l show you the reasult:

Result:

{missing value, missing value, missing value, missing value, " ", missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, "70", missing value, missing value, missing value, "", missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value, missing value}


I would like to express my thanks for dealing with me and for wasting your morning.
I hope I learn a lot from this, as always.
The point is that I really like this Metronome and that it manages to start/stop it.
That's enough for me at this moment.

Thanks again all your help both of you.

Sincerely,
Kalman

Rich Walsh

unread,
Jul 14, 2024, 2:50:16 PMJul 14
to ql...@googlegroups.com
That’s the result. It tells you there’s a UI element with value “70”, which is a safe bet to be the tempo text field. If you search the replies – as I said – for “70” you’ll then get:

get value of text field 1 of group 2 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window " " of application process "Metronome"


So now you know where the tempo text field is. Next:

class of UI elements of group 2 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1 

That tells you this text field is next to 7 buttons in the hierarchy:

--> {group, button, text field, button, group, button, button, button, button, button}


So now you can do:

description of every button of group 2 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1

--> {"–", "+", "button", "button", "button", "Tap", "4/4"}


You’ve found 4 of the labelled buttons in the interface. You can click the other 3 to see which one starts the app.

If you have the picker window open the initial script returns a UI element with value “/“ so now you know where all the parts of that popup window are.

Quicker than unfolding triangles in Script Debugger and more accurate than Accessibility Inspector. Since UI Browser is EOL I wouldn’t even bother installing it.

You have to ask though, why don’t you just render a metronome out as an audio file and play it with the highly developed tools QLab has for playing audio files, instead of mucking around with UI scripting?

Rich

Kalman Tarr

unread,
Jul 15, 2024, 6:01:14 AMJul 15
to QLab
Thank you Rich for your reply. 

What you write it is too high for me. But I am happy to see new things and try to understand them.

You're right! The simple solution, create audio file record, using Metronome app and using it to play to the ear of conductor using QLAB. But there is a small thing, the conductor wants to keep on eyes the metronome signal.
And one more thing, using Metronome app is a simple way to control continously the tempo of the metronome. I mean in runtime.
 
Thanks again for your halp!
Sincerely,
Kalman

Andy Leviss

unread,
Jul 18, 2024, 2:27:41 PMJul 18
to ql...@googlegroups.com
On Fri, Jul 12, 2024 at 8:21 AM Kalman Tarr <tarr....@gmail.com> wrote:
I downloaded an app called "metronome" from app store.

For what it's worth, if the goal you're trying to achieve is simply to be able to set a tempo for a click track/metronome from within QLab, there's a simple way to do it all in QLab. All you need to do is generate a one bar click track at 100 BPM. Drop that into QLab, and then use the Rate control in the Time & Loops tab (with "preserve pitch" enabled) to adjust it's tempo. Setting it to .6 would get you 60 BPM, 1.2 would get you 120 BPM, etc. 

I don't know if that's helpful to you, but figure it might be to somebody out there!

-Andy 
Reply all
Reply to author
Forward
0 new messages