This question has come up before, but not in a recent thread, and none of the remedies are working for me. I’ve created a simple test Python script using trackpad inputs to send MIDI control change information to a mixing console.
I’m getting the following error:
This process is not trusted! Input event monitoring will not be possible until it is added to accessibility clients.
I don’t believe Accessibility is used anymore for this – I think it’s a holdover from earlier OS. Under “Privacy & Security” I can add applications to a list under “Input Monitoring,” and I’ve added the Python instance, the script itself, and the Terminal. I’ve even upgraded Python to 3.12 and added that instance. Nothing affects this error.
Does anyone have any advice? Thanks – code copied below.
Dave
import mido
from pynput import mouse, keyboard
from pynput.keyboard import Key, Listener as KeyboardListener
from pynput.mouse import Listener as MouseListener
# Constants
MAX_X_RESOLUTION = 127 # MIDI control change max value
# MIDI setup
outport = mido.open_output('USB Midi Cable', virtual=True)
def send_program_change():
"""Send a MIDI program change message."""
program_change = mido.Message('program_change', program=1, channel=0)
outport.send(program_change)
def send_control_change(value):
"""Send a MIDI control change message based on the x position of the trackpad."""
control_change = mido.Message('control_change', control=1, value=value, channel=0)
outport.send(control_change)
def on_move(x, y):
"""Handle mouse movement."""
# Scale the x position to MIDI values (0-127)
width = 1920
midi_value = int((x / width) * MAX_X_RESOLUTION)
send_control_change(midi_value)
def on_press(key):
"""Terminate the program if escape key is pressed."""
if key == Key.esc:
return False # Returning False stops the listener
if __name__ == "__main__":
send_program_change()
# Start listening to the keyboard and mouse
with MouseListener(on_move=on_move) as listener:
with KeyboardListener(on_press=on_press) as listener:
listener.join()
user25045976 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.