Insert Text by Typing mangles URLs taken from the system clipboard

I'm running a macOS VM in UTM, which doesn't currently support clipboard sharing. To work around this, I added this macro to Keyboard Maestro:


The pause is necessary as otherwise the first character gets lost for some reason.

However, when a URL is on the clipboard, the colon gets changed to a semicolon — gets changed to https;//, meaning I have to edit every URL. Inserting an Alert before Insert Text by Typing shows that KM is reading the clipboard correctly, it's just the insertion where it is changing it.

Is this intentional behaviour? I can see it possibly being a security feature, but I'd still like an option to disable it on a per-macro basis, as it's making my life very difficult in this case where I'm pasting with the full knowledge of what I'm pasting and where…

There doesn't seem to be any documentation of this behaviour on the Insert Text by Typing Wiki page. Assuming it's intentional, it would be helpful if it could be mentioned there.

No, it's not.

It might be a timing issue so that KM is typing faster than the target app can accept reliably (that's probably what you need your pause).

You might want to try to slow KM's typing speed by inserting a Set Action Delay for normal keystrokes prior to your 'Insert Text` action. See this page in the KM wiki: action:Set Action Delay [Keyboard Maestro Wiki]

Thanks — I didn't know about Set Action Delay. That's fixed some typing errors it was making.

Unfortunately, even when setting it to something ludicrous like 1 second, the colon is still changed to a semicolon.

OK - I'm out of ideas then. Sorry.

If you're able to paste from the System Clipboard, then it seems like the clipboard is being shared... or am I missing something?

I've occasionally had annoyances with Insert Text by Typing, so I use Insert Text By Pasting when they crop up. I usually follow it with a quick clipboard cleanup at the end of the macro like this:

Well, the clipboard is being shared — but Insert Text by Typing seems to be not typing what's actually on the thing, as alerts before and after the insert show the clipboard contents start "https:" but what's typed is "https;".

As the target is a VM that doesn't support pasting from the host OS, Insert Text by Pasting just inserts a "v" regardless of what's on the clipboard. If it supported pasting, I could just press ⌘V and save a lot of hassle :grin:

Have you established whether the clipboard contents are correct to confirm that it's a pasting rather than copying issue?

Have you tried pasting via the Edit > Paste menu item, just to cover all bases?

The clipboard contents are correct, because I inserted an Alert action with the contents %SystemClipboard% and it displayed the correct URL.

I cannot paste using Edit > Paste, because the VM does not support pasting from the host system, and the option is greyed out.

However, I have just tested with a non-URL string, and discovered that the real problem is that Insert Text by Typing is not passing modifiers like Shift correctly (which I should have realised when Insert Text by Pasting typed a "v"!)

This seems to be affecting all typing in UTM — using Type a Keystroke and setting it to type ⇧1 results in a 1, not an exclamation mark.

Targeting TextMate results in the correct behaviour, so it seems to be UTM to blame rather than KM — unless the issue is in KM typing into VMs running under Apple's Virtualization framework.

If anyone's running VMs using the Virtualization framework with Parallels or VMWare, it would be useful to know if you're seeing this there as well — I don't currently know whether this is an Apple bug or a UTM bug.

Presumably, you can type all these characters in the VM manually. If not, is there a keyboard settings preference pane in the VM you could have a poke around in?

Yes, typing works as expected in the VM. I'm not sure what the difference is between the way KM simulates keystrokes sent to the app and how the actual keyboard sends them, though. It's very bizarre (and annoying!)

Or not a bug at all...

Software events (KM typing for you) are not hardware events (you mashing the keyboard), and it's up to the "receiving" software how (or even if!) it deals with them. This seems a particular issue with apps used to interact with remote or virtual machines (see recent threads about Apple Remote Desktop, Parallels and Windows VMs, etc) where you often have a "translation" layer as well. It's often the meta keys that are the problem -- in your case, that includes "Shift".

Using "System Events" and keystrokes can sometimes get round this -- they seem to work at a level somewhere between hardware and software events -- but not always. Often you just have to try and see what happens...

Otherwise, what does UTM support? And don't forget that you could install KM on your VM, turn on the web server, and use triggers sent from your host Mac! Depending on what you are trying to do you could also ssh in, run a remote AppleScript via osascript, etc.

1 Like

Ah, now that's a nice hack! I think I might try and do it that way. Thanks for the idea!

It would have been much easier if I could just get the VM to log in to iCloud, as then I could transfer stuff via Notes. Not sure if this is some Apple restriction on VMs using the Virtualization framework…

1 Like

I’ve just tried with Parallels and it works without any problems.

1 Like

Thanks — it looks like this is a UTM issue, so I've opened an issue there.

Don't forget the old ways! Make folder on the host, share it, connect to the share from the VM. Just remember to close files if you want the other device to write to them. Poor man's local cloud solution...

Ah, there you've found another feature that doesn't seem to be supported by UTM when you're using the Virtualization framework…

All these work when you're emulating rather than virtualising the CPU — but the VM then crawls to the point that it's unusable.

What, you can't connect to a network resource? Seems pretty pointless to try and type in a URL then...

Ah, sorry, I thought you meant configuring the VM software to share a folder. Yes, network sharing would work for files, though it probably won't help very much with the clipboard sharing.

Well, you'd be able to eg put some text in a file on the host Mac then open the file in the VM and move the text to wherever. Not particularly convenient -- but that convenience is what you pay to get in Parallels/Fusion.

You might even be able use watched files/folders and KM on both sides to make a pretty smooth workround. What sort of things are you wanting to copy'n'paste between host and VM?

Passwords from 1Password, mainly. Leaving them lying around in files isn't a particularly good idea :grin:

If iCloud login worked in the VM, I'd just be able to install 1Password on that and sync the password database, of course…

The author of URM has replied to my bug report saying they use VZVirtualMachineView as-is without custom input handling, so it could be a bug in the Virtualization framework or in SwiftUI, unless he's missed something. I assume this works in Parallels/Fusion

Could somebody please tell me how KM sends the key events for Insert Text by Typing so I can add it to the UTM issue?