Is possible to redefine application's shortcut?

In one application (SomeApp) I want redefine the CMD-N (build-in) shortcut (New Window) to run automator-script.

So, when I press CMD-N it should run my Automator apple-script instead of the New Window built-in command, but exactly in one application only.

Already done:

  1. I opened the Automator and created a simple service.
  2. no input in the SomeApp.
  3. It contains the run shell script action
  4. and the script is open -a SomeApp http://www.google.com (opening an URL)
  5. of course, the script itself is working flawlessly (i know how to using Automator)
  6. Tested, saved, named it as: SomeAppUrl
  7. In the SomeApp the CMD-N is currently used for the "New Window" (builtin) command.
  8. I want replace this already existing shortcut with the my Automator service described above.
  9. I know the system preferences -> keyboard -> shortcuts

BUT

  • in the services i could choose a shortcut - but it will be a global
  • or in the App shortcuts could choose for the given SomeApp the "New Window" and assigning a new shortcut

But no one REPLACING the current (built-in) Cmd-N with my SomeAppUrl Automator service ONLY in the SomeApp.

Is this possible? If yes, could please someone add some hints?

EDIT

For the fast-commenters:

  1. The current state: the CMD-N opening a "New window".
  2. The final state: the CMD-N should run my own Automator script...
  3. Is this possible?

Assuming the Automator Service/Quick Action settings are, e.g. in macOS Catalina,... Workflow receives [no input] in [SomeApp] and it's assigned the keyboard shortcut of ⌘N in System Preferences > Keyboard > Shortcuts > Services, it is not global in the sense that now ⌘N in every application is going to run that Service/Quick Action. Only the application defined as SomeApp is going to receive the ⌘N keyboard shortcut.

This of course means that SomeApp must have focus to receive the ⌘N keyboard shortcut assigned to the Automator Service/Quick Action.

Therefore, in order to have SomeApp respond to ⌘N as the Automator Service/Quick Action the New Window command of SomeApp must be reassigned to e.g. ⌥N in System Preferences > Keyboard > Shortcuts > App Shortcuts.

Go to System Preferences > Keyboard > Shortcuts > App Shortcuts1 and click the [+] button.

  • For Application: select the target application (SomeApp).
  • For Menu Title: use New Window (Or exactly what is on the menu for the command you want to change.)
  • For Keyboard Shortcut: use, e.g.,: ⌥N (Assuming no other command is using that one in that application. You must determine that, e.g., ⌥N, or whatever you change it to, is not already in use.)

Then click the Add button.

Now when SomeApp has focus and you press ⌘N the Automator Service/Quick Action will be triggered.


Notes:

When a keyboard shortcut is assigned to an Automator Service/Quick Action in System Preferences > Keyboard > Shortcuts > Services, it is only global if the Automator Service/Quick Action is set to ... in [any application], and when set to SomeApp it only appears in that applications Services menu.

I have found in some cases pressing the assigned keyboard shortcut may not trigger the first time and that manually triggering it once from the Services menu takes care of that.

Additionally keep in mind that all of this assumes necessary and appropriate settings in System Preferences > Security & Privacy > Privacy have been set/addressed as needed.

1 See Create keyboard shortcuts for apps on Mac for additional information.