Copy / paste macro not working in Share Screen

I created a macro to copy a selected text into a variable, to be used further down the workflow.
The workflow is I Share Screen into another machine, select some text, press a button on Stream Deck and the macro issues a Copy command and stores the content of the clipboard to the variable.
When I tried to use it, pressing the Stream Deck key wipes out the selected text and replaced it with a "c"...obviously from the command-C.
I tried both "Copy" and "Type a keystroke" method - same result.

Then I decided to connect into the other machine using TeamViewer and Splashtop.
Tried the macro and the macro correctly copied the selected text.

So the issue is obviously with Share Screen - but manually issuing "command-c" works.

Anyone else encountered this issue before?

Different screen sharing apps treat KM's simulated meta keys in different ways. Even different versions of Screen Sharing can behave differently... What are your client machine (your local computer) and server (the remote one) OSs?

1 Like

Both running MacOS. Remote machine running MacOS Ventura, client machines (I tried from two) running MacOS Ventura and Big Sur.

If you want to do something solely on the remote machine, I found it best to install KM on that and run the macros there. You can still trigger them with local keystrokes -- if you have the same macros on both devices, put them in a Group that is disabled when Screen Sharing is the active app and then your local machine will ignore the keystroke, which is passed to Screen Sharing, which sends it to the remote machine, which triggers the remote macro. I assume similar can be done with a Stream Deck keypress.

For simpler stuff, and/or for a macro that acts on both local and remote machines, you should be able to use AppleScript and the "System Events" OSAX to send the keystrokes -- Screen Sharing is more respectful of meta keys sent in that way. So this macro, run locally when your remote machine window is frontmost, will copy the remote selection to the remote clipboard:

RD Copy Test.kmmacros (1.9 KB)

Image

I can't get Stream Deck to trigger the macro on the remote machine (I don't think).

I basically just want to get to two files on the remote machine, copy the text from there and continue my workflow on my local machine. I could copy the two files on Screen Sharing over to my local machine and the macro would work, but it's still a couple of steps extra (which I don't have to do when using TeamViewer and Splashtop).

It's ok, I'll just connect remotely using TeamViewer or Splashtop instead of Screen Sharing...the rest of the workflow steps are the same.

Was just wondering why Keyboard Maestro doesn't work with Screen Sharing, that's all.

Thanks for the AppleScript macro...I'm sure it'll come in handy one day!

What are the files? Any particular reason why don't just turn on file sharing on the remote machine(s) and open those files locally instead?

There will be ways, even if indirectly -- eg turn on the KM Web Server on the remote machine and use Open URL type actions on the SD buttons. Whether that's worth doing is another matter, especially in this case where you seem to be running the macro locally but dipping into the remote machine to get data.

SSL certificate files - they are in a newly created system folder every time and I have to go and change the file permissions before I can open them (hence the share screen) and I used to open the two files I need, and copy and paste, copy and paste for each site's SSL I have to update and then repeat.
This way, I copy twice and then have it's just paste , paste, paste all the way.

certbot renew, by any chance? IIRC you can use --post-hook to automate a permissions change, which might help.

Say if you are using certbot and I'll see if I can remember...

Or perhaps you could turn on remote login, send an ssh command to change the permissions then scp the certs back to your machine, ready to load your clipboard?

Or I can just remote connect using TeamViewer or Splashtop and the macros just work? :joy:

I'm using Let's Encrypt but for technical reason I can't use the auto renew function (which I haven't investigated further - I think it's because it's not available on my hosting platform) so I have to do it manually.

That doesn't stop you from using a --post-hook. You could, for example, use it to copy the validated keys to your (remote) user directory and change the permissions there (so as not to mess with the original permissions), then pull those to your local machine ready for use. Fully-worked example of similar here.

While TeamViewer/Splashtop are working for you, that's certainly the easiest route. But maybe keep post-hook etc in your back pocket, ready for when they also stop accepting meta keys for some reason :wink:

I think it’s the post hook that I got stuck on.

I run the command on my server but I don’t know how to get it to connect remotely to the relevant remote user directory, so to be safe, I follow the instructions to let it manually create those entries in the user directory and then copy the ssl certs.

Thanks for the example, I’ll have a look!

Thanks so much!

1 Like