MT Pro: problem executing Apple Script

Hi Steve, I have another question:
I am currently trying to trigger two simple applescripts, in this case the display brightness setting. Unfortunately, nothing happens when I enter the script in the Translator field. Not even with the test button, there is not even an error message.
These scripts work perfectly in the script editor.

I gave MT the permission to control the computer in the system settings, but that didn’t help either.
Nothing happens and I don’t know what the problem is. These really are extremely simple scripts. It seems as if there is no functionality at all, if at least there were error messages :slight_smile:
I have the impression that MT does not even try to execute the scripts. I also don’t see any other parameters that could influence the behavior.
I have probably overlooked something trivial - but what?
I’m on Ventura on a Mac Studio M1.
Otherwise everything works perfectly in MT.
I’ll attach a screenshot of the Translator settings etc.
Do you have any idea what the problem could be?

Many thanks and best regards

Interesting as I’m not able to run this even in the script editor and I’m on Ventura also.

tell application "System Events"
    key code 113
end tell

I see from this page that some function keys do not work with scripting.

Steve Caldwell
Bome Customer Care

Also available for paid consulting services:

Hello Helfried,

first of all, please enable ‘Outgoing’ in the Log Window so that you can see if the Apple Script action is executed at all.

I’ve tried a bit. For me, the script is definitely executed, but screen brightness is not changed. The Log Window reports Outgoing AppleScript without error. And I can see the key code in Terminal: executing your Apple Script (key code 113), I see 8~ being typed into the Terminal. There are some strange side effects, too (like the Terminal not being focused after key code 113).

This is on a Macbook with touch bar. It does not have real keys for changing the screen brightness.
Then I found this discussion:

Someone points out that depending on keyboard, you may need to use keystrokes 144 and 145 instead of 107 and 113. I tried that and still the MT Pro script did not change the screen brightness.

Last, but not least, I attached an external keyboard to the Mac, and then keys 144 and 145 finally changed the screen brightness when executed from within an MT Pro project.

Here is my test project:
AppleScript Screen Brightness.bmtp (1.7 KB)

Hi, thank you very much for your helpfulness and the effort to solve the problem. I have just tested it here with your example file (which works for you, Florian) - nothing works here either. The problem doesn’t seem to be the key code numbers here, but that my MT doesn’t execute any scripts - nothing happens at all. All these scripts work perfectly here in the Apple Script Editor.
So the problem is probably not in my MT project or the script itself, but something in my system, in the OS, in the configuration - prevents MT from executing scripts.

As I said, I have assigned the rights in Accessibility, that’s not it.

Here in the screen video you can see that nothing is happening - this is your test project, Florian, and the log window is open.

Thank you all, best regards

You still haven’t enabled Outgoing in the Log Window:

Also, enabling ‘Accessibility’ in System Settings is probably not enough for controlling System Events. I have these entries in Automation:

I also realize that I’ve done these tests on a Mac running an old macOS 12 Monterey. The OS asked for these permissions that first time I’ve used them from within MT Pro’s Apple Script.

Ah, that was a very valuable hint with the SystemLog-Outgoing (I stupidly didn’t pay attention to it at all), now I finally see the error message:

‘OUT 8.0 ERROR executing AppleScript: action_8_0(): error -1743: Not authorized to send Apple events to System Events.’

I don’t have the entries under ‘Automation’, and unfortunately I don’t see a + sign or something to enter anything there. My operating system doesn’t ask me for it :slight_smile:

But apparently it should do that - hmm, annoying:

Maybe I can find a trick or hack to make it work anyway, at least now I know where the error probably lies !!! Thanks very much, that was extremely helpful.

I give up for the moment.
Apparently there is no chance to force entries in
if the app doesn’t ask for it, very annoying.
I have already uninstalled MT - i.e. deleted the app - and reinstalled it, but that didn’t change anything either. Maybe I have to delete some preferences ? but what? Why does Apple make such an essential setting so inaccessible - completely stupid.

I assume that you have installed MT Pro in /Applications ? I know that sending variables to MT Pro via Apple Script only works if MT Pro is installed there.

Yes, it is in /Applications.

I suspect that I simply need this entry in ‘security->automation’.
The error message also indicates this.
However, simply deleting the app was not enough to force the app to request the entry.
Does it help if I delete everything on my system disk that has anything to do with MT, i.e. system files, preferences etc…?
I have to make the app think it’s being started for the first time ever :slight_smile:

…or rather: I have to make the operating system think that this app is starting for the very first time. This can be more complicated, as this information is perhaps somehow hidden deep in the system. Shit

Wow, that was a long research trip :slight_smile:
After everything failed (complete uninstall and reinstall of MT, reset of TCC database entries… and more experiments) I came across these sqlite commands and customized them.

Disclaimer: use these commands at your own risk. They directly modify internal MacOS settings.

Before editing the TCC database, it might be a good idea to back it up. Just in case:

cp ~/Library/Application\ Support/ ~/TCC-Backup.db

Then, add System Events Automation permissions for MIDI Translator Pro:

sudo sqlite3 ~/Library/Application\ Support/ "insert into access values ('kTCCServiceAppleEvents', '', 0, 2, 3, 1, '??', NULL, 0, '', '??', NULL,1571402310);"

You may need to restart MIDI Translator Pro.

And voila, now it works! I now have the necessary entries under ‘Security → Automation’ and Midi Translator executes the scripts perfectly!
Finally a success, I had almost given up.

Here is another command to read the status of the automation permissions:

sudo sqlite3 ~/Library/Application\ Support/ "select * from access where service='kTCCServiceAppleEvents';"

and to delete the generated entries:

sudo sqlite3 ~/Library/Application\ Support/ "delete from access where client like '';"

Thanks for your help! I am so glad that everything is working now.

Hi Helfried,
that’s fantastic! Thanks for sharing. Your sqlite command worked fine for me.

I had lost myself in research, too, but I only got as far as removing the TCC entries using the tccutil tool. But then I could not get the expected behavior that MacOS asks for the permissions when the respective AppleScript is invoked by MT Pro. That seems to be a common problem on MacOS. Once the permission is denied, or removed using tccutil, you are not asked again.

I have cleaned your post a little bit and added a disclaimer and backup. I hope you don’t mind.
Do you have a source where you found the info about the sqlite DB?

thanks for cleaning up, it looks better like this :slight_smile:
This was the link that finally brought the solution after a long search:

It’s about another app, similar problems.
After inserting the corresponding IDs for ‘’ and ‘’
it worked.
Like you, I had no success with the tccutil commands before.