Capture CMD-W only when a specific app is active

Is there a way to do the following:
I am running Microsoft Remote Desktop to connect to a Win 10 system. I have used PowerToys on the PC to map CMD-C, and CMD-V to the PC equiv CTRL-C and CTRL-V. However I would also like to map CMD -W to CTRL-W. The problem is that the Mac grabs the CMD-W before the Remote Desktop app can map it and it closes the connection in the Remote Desktop app. Is there a way to capture CMD-W only when Remote Desktop is active and pass it to the app so that Power Toys Keyboard mapper can change it to CTRL-W?

Macro Groups control when their contained macros are active, and you can configure a macro group to be active only within a specific application. See:

Put your macro in a macro group that is configured to be active only when Remote Desktop is the front application and give it a Hot Key trigger of Command-W.

That said, Remote Desktop (and any remote desktops/virtual machine/emulators/etc) operate at a very low level so the behaviour of macros in general will vary depending on the implementation details of the application.

Thanks but unfortunately that doesn't work. I created a Macro group for Remote Desktop and one macro which triggers on CMD-W but I can't get it to map to CTRL-W in Windows (close tab). The Mac no longer saw the CMD-W which is good but WIndows is not doing the CTRL-W. Not a big deal but I was hoping to use CMD rather than CTRL as I go back and forth between OSes.

Try this: System Settings (or System Preferences) -> Keyboard -> Keyboard Shortcuts -> App Shortcuts then use the + sign to create a mapping for Microsoft Remote Desktop, changing Close Window from Cmd-W to something else. Then perhaps PowerToys will be able to do the mapping you want.

1 Like

Thanks. I just tried that without success. I mapped Close Connection for Remote Desktop to Shift-Cmd-X. In Remote Desktop the menu shows this as he new shortcut for Close Connection (in place of CMD-W). In Windows, I mapped CMD-W to Ctrl-W. However when (in RD) I type CMD-W, it is still closing the connection.

I mapped Close as well for the Remote Desktop App (just in case) since that shows up when a connection is not active but it still refuses to let the CMD-W thru to the app where it can be mapped to CTRL-W

I installed the latest version of RD and mapped Close (there is now no Close Connection) and it worked! Thanks for your help!