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 — https://forum.keyboardmaestro.com/latest gets changed to https;//forum.keyboardmaestro.com/latest, 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.
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
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.
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!)
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.
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…
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...
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
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?