Using Keyboard Maestro with Remote Desktop

Hi all, very new to keyboard maestro and automation in general. I connect to work through a remote desktop app on Mac, and want to automate a few processes that I do for work on a day to day basis. Unfortunately I am having issues with certain keypresses working through Keyboard Maestro, such as Alt and cmd. Has anyone has a similar issue to this in the past and has anyone found a workaround? Cheers

Some of what you can do will depend on the remote desktop software you are using, and some will depend on the remote OS and app you are targeting -- as always, the more relevant information you can give the better the answers you'll receive.

Targetting MacOS 12.4 using Remote Desktop from the app store for Mac. I use the paste macro for example it will only type v and the cmd press doesn't get seen by the remote desktop software. All my tests work fine locally but just seems to be the alt + cmd key I'm having issues with.

There's "Remote Desktop" by TheITSpecialistsLLC -- going by the reviews, I hope you aren't using that! There's a bunch of others, so you'll need to be a little more precise.

Meta keys can sometimes be a problem, but I know that a "Type Cmd-V" KM action works in both Apple Remote Desktop and built-in Screen Sharing.

I'm using the Apple Remote Desktop app, I was using the paste function so tried it as a cmd + v keystroke instead but still same issue, only writes the "v". So frustrating as if I can get this working it'll unlock a whole host of opportunities with automation. helpppp!

Post an example macro that doesn't work -- there's instructions on how post and upload your macro here -- so people can try and figure out the problem.

I'm not going to say it definitely works in ARD because I'm running an old version and YMMV...

Here you go, when I use this is in ARD it just writes a V instead of pasting. Can still use all the keyboard shortcuts manually on ARD, just not using Keyboard Maestro. Please help!!

Paste Macro (v10.1.1)

Paste.kmmacros (1.6 KB)

I have had the same issue working with Remote Desktop and what works for me is to save the text you want to paste into a KM variable. Then use the "Execute AppleScript" action to transfer the text. In the attached screenshot, "dolphin_comments" is the KM variable I use which would be different for you. Other than that you wouldn't have to change the attached AppleScript.


Might be version thing -- ⌘V works fine for me with ARD 3.9.3. What version are you folks using? The modifier could be "dropped" by the client (your machine), the server, or the app you are trying to paste into -- does it fail with eg TextEdit?

One thing that sometimes works is splitting keypress and modifier into different actions:

You could also send a Unix command:

...either using KM to manipulate ARD's menus and dialogs or via an Execute AppleScript action (haven't tried that, I don't know how easy it would be to use AppleScript to "Send Unix Command" to the frontmost ARD window -- I'll have a play with that later).

If it's just pasting plain text then @maxnnina's solution is easiest. If pasting rich text, images, etc then one of the above might work. If you want to do other keystrokes involving the modifier keys you should be able to change the "Send Unix Command" to suit.

I am also on 3.9.3. How strange! Gonna give splitting the command modifier and keystroke a go and see how that goes.

Tried splitting the modifier and keystroke, same issue... It's an issue I'm having on two of my laptops running ARD, and I really don't know where I'm going wrong. I would write a Unix command but really not sure how to implement that as I'm still a beginner!

Hello mate, this might be able to work for me actually. Are you able to dumb it down a tad? When you say "save the text you want to paste into a KM variable" what do you mean by that?

In ARD, open your target machine. From ARD's "Manage" menu, select "Send Unix Command...".Type in osascript -e 'tell application "System Events" to keystroke "v" using command down", set "Run command as:" to "Current console user..." and uncheck "Display all output". Hit the "Send" button.

All you're doing is using a Unix command to tell AppleScript on the target machine to do a ⌘V -- bypassing all the "who gets to interpret the modifier key" malarkey. If that's working we might be able to generalise it and/or make it easier to do.

What are you actually trying to do using ARD? There may be better ways. Also remember that you can install KM on up to 5 machines with your licence -- if the thing you are trying to do is wholly on the remote machine then you could put KM on that and run everything "locally"...

36:68: execution error: System Events got an error: osascript is not allowed to send keystrokes. (1002)

And the remote machine should have flashed an "Enable Accessibility" dialog. Open System Preferences on the remote machine, go to "Security & Privacy", unlock, go to "Accessibility", put a tick next to "ARD Agent".

Just wanted to chime in here, I know it's an old thread but I was encountering the same issue and it's frustrating to no end.

Happily I can report that, while sending the UNIX command for AppleScript to run MIGHT have worked with accessibility being enabled, it works perfectly by executing the same AppleScript on the controlling computer. It's almost like a security thing with ARD, but darned if I could figure out why some people don't have a problem. I am using Logitech G Hub keyboard software, maybe that has something to do with it. Anyway, add an action into your KM script as I'll show in an attached image... --Josh
Screenshot 2023-06-30 at 8.14.54 PM