Security & Privacy and self-modifying applications

64 Views Asked by At

A friend and I are developing an application with electron. This application has settings which are currently being stored in the application LaunchMenu.app. Within this application we are using the following JXA script to execute keyboard events:

//JXA send keys
function sendKeys(sequence){
  const events = Application("System Events");
  sequence.forEach(data => {
    console.log(data.keys);
    if ("keys" in data) events.keystroke(data.keys, data.modifiers ? {using: data.modifiers} : {});
    if ("codes" in data) events.keyCode(data.codes, data.modifiers ? {using: data.modifiers} : {});
  });
}

The problem is whenever we change a setting, LaunchMenu.app is changing, which is causing the following message to appear whenever a key event message is sent.

“LaunchMenu“ wants access to control “System Events“. Allowing control will provide access to documents and data in “System Events“, and to perform actions within that app.

The app is still ticked in the Security & Privacy > Accessibility menu but we need to untick and retick it in order to start using keyboard events again...

One work around would be trying to not modify the application, however we quite like how the app is self-contained and we wouldn't be able to ensure the app doesn't change in the future (by one of the 3rd party applets installed on it).

Is there anything else we can do to ensure the script we run always has permissions to system events?

0

There are 0 best solutions below