Toggling ⌘ ⇄ Ctrl in the Context of macOS ⇄ Windows Inter-operation

I have a windows keyboard connected to my Mac.

I usually go into the macOS Keyboard Preferences ⇢ modifier keys and change Control to Command so that I can press CTRL+C to copy instead instead of Command+C (it's much more comfortable as I'm constantly switching between Mac and PC systems with the same keyboard).

Now on my Mac, I need to constantly switch between working on my system, and using a remote desktop software that is installed on a PC.

I now have to go into the keyboard modifier keys and toggle the CONTROL dropdown between "Control" and "Command" every time I switch from the remote software back to my system.

Is there a simple way to set up something with keyboard maestro that will toggle this option so I don't have to get into system preferences each time I switch.

Not sure how up to date (with current macOS builds) this is, but there is some discussion here of how it might be done from the command line (in Keyboard Maestro terms, from a KM Execute a Shell Script action):

I appreicate the response, unfortunately I have no experience with coding/scripting and almost everything in that thread goes way above my head when it comes to this stuff.

I thought it would be a simple thing to do considering it's just modifying a dropdown menu, but I'm realizing that was a silly assumption.

I'm still trying to read and understand the thread you sent, but I think it's a bit too advanced for me.

Thanks again.

Have you already tried something like this?

Ctrl as Cmd.kmmacros (4.0 KB)


Usually this sort of thing fails rather than works, and of course it's far from a general Cmd/Ctrl key swap. But if it is limited to a few modifier/key combinations and only for certain programs, it might be worth a try.

Or with Device Key triggers instead of Hotkey triggers:

Screen Shot 2022-12-07 at 00.13.41-pty-fs8

In any case, put it in a macro group that makes the macro available only in programs where you actually want to use it.

1 Like

Not so silly -- there are things that are "simple" to do in the UI that are an absolute pain to macro/script because Apple or an app developer haven't provided the appropriate hooks for us to use. But you never know they're a pain until you try!

Most scripted solutions for your problem suffer from the same, big, drawback -- you'll have to log out and back in for them to take effect. Not really a viable solution.

What Remote Desktop software are you using? Does that, perhaps, have the option to remap modifiers when active?

If not you're probably reduced to UI-scripting what you are currently doing manually. There's been "quite a change" to System Settings in Ventura versus previous OS's System Preferences, so any specific help will need your OS version.

Thanks everyone for the answers.

I'll try to provide more info:

I'm on a Mac running High Sierra (10.13.6) and I am using a remote desktop app called RGS. I have not been able to find an options to remap key in RGS.

Remapping individual keystroke combo like CTRL-C to COMMAND-C and CTRL-V to COMMAND-V is not really an option is the software I use uses CTRL for much more than just copy and paste and I would need to set up too many key combos to make that a worthwhile solution as i'd be remapping half the keyboard.

It seems like I'm doomed to have to just keep opening up system pref and navigating to the modifier keys and toggling via the dropdown or going back to having two keyboards on my desk.

Don't despair quite yet!

While it's best to do things "programmatically" with scripts or direct KM actions if you can, when all else fails you can resort to manipulating the UI using KM's "Click Found Image" action or AppleScript's tell "System Events" (amongst others).

You should be able to write your own KM macro using "Image" actions, but try the following AppleScript in Script Editor -- if it works you could use it in an "Execute AppleScript" action. Set your modifier keys back to "normal" first, then this should change the standard mapping to your "switched" version:

tell application "System Preferences"
	reveal pane "Keyboard"
end tell
tell application "System Events"
	tell application process "System Preferences"
		delay 1
		click button "Modifier Keys…" of tab group 1 of window "Keyboard"
		tell pop up button "Control (⌃) Key:" of sheet 1 of window "Keyboard"
			delay 0.2
			pick menu item "⌘ Command" of menu 1
		end tell
		tell pop up button "Command (⌘) Key:" of sheet 1 of window "Keyboard"
			delay 0.2
			pick menu item "⌃ Control" of menu 1
		end tell
		delay 0.2
		click button "OK" of sheet 1 of window "Keyboard"
	end tell
end tell
tell application "System Preferences" to quit

You may have to increase the delays, depending on the speed of your Mac. Going back from "switched" to "normal" would be the same script but swapping over the two pick menu item... lines.



I think this may do the trick for now.

I was able to set a hotkey to run an AppleScript and pasted what you provided above. That worked toggling one way, and then I set a second hotkey with it toggling back.

You saved me having to navigate through to the keyboard pref roughly 15-20 times a day.