0

I have created an automator workflow; then I have created a keyboard shortcut in the Keyboard Settings to run this as a Quick Action on a keypress.

All of this works. But the workflow seems to run in the security context of the application which was active when I pressed the hotkey.

The activity inside the service has nothing to do with the current application (it takes a screenshot and then does something with it); it doesn't access the "current" application in any way.

It needs to access the System Events, and thus security kicks in. I then have to enable access to those features for any application which happened to be in the foreground when I hit the hotkey.

Is it possible to avoid this - i.e. run my service in a context of its own?

EDIT for clarification: The workflow clicks menus of applications, and sends keystrokes.

... take a screenshot ...
... startup GIMP ...

tell application "System Events"
    tell process "GIMP-2.10"

...
        click menu item "From Clipboard" of menu 1 of menu item "Create" of menu 1 of menu bar item "File" of menu bar 1

...
        keystroke " "
...

As an example, say I press the hotkey while Emacs is in front. I then get a security prompt asking me to allow some security aspects for Emacs. I neither want do give Emacs any permissions, nor do I want to repeat this for any other application which might be in focus when I take a screenshot later.

  • A service exports features for other applications to use - that is what it does. System Events should have its own permission - how are you using it? – red_menace Feb 7 at 15:14
  • @red_menace: I am using it like here guidingtech.com/25775/custom-shortcut-apps-mac-automator (Automator => create service; keyboard settings => create shortcut in the "Services" section). The term "service" is a bit misleading here as far as I can tell (nothing is actually running in the background, like a daemon in Unix language), but that's what the english Catalina calls it... – AnoE Feb 7 at 15:31
  • I am aware of what it is, whatever it is called (these days it is "Quick Action"). There is a system application that deals with activating and running the workflow - the service is is made available in the contextual menu based on what it has been specified to receive. My question was about what is in the workflow, as System Events doesn't have a command for screenshots, and would have its own permissions. – red_menace Feb 7 at 17:22
  • @red_menace, that sounds right ("Schnellaktion" in German). I have edited the question to remove the word "service", and given a code extract. – AnoE Feb 11 at 8:11
1

I had the same issue. What worked for me:

1: Saving the automator workflow as an application (File > Convert To > Application. Save > File Format = Application).

2: Then creating a separate Automator Quick Action with the sole purpose of launching the application created in 1 (File > New > Quick Action. Save normally as a workflow.).

The application containing the target workflow (1) will then need to be given Accessibility permissions via the usual (Security and Privacy > Privacy > Accessibility) and the key shortcut should be bound to the workflow (2) as you described.

This successfully bypasses the security settings of the currently active application by running the workflow in a self-contained app (with its own Accessibility preferences) negating the need for multiple permissions.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .