So I have a simple AppleScript that I think should type a bunch of keys, but the period character doesn't print in VMware Fusion's virtual machines. This is odd because my period key (.) enters a period like normal in those VMs.
MCVE
Here is my latest version that I tried:
on run {input, parameters}
set file_text to "this another test: ... hello ..."
delay 0.3
repeat with ch in file_text
tell application "System Events" to keystroke ch
delay 0.1
end repeat
return input
end run
I built this as a service in Automator. I run this by going to my application, then in the Title bar I select Services -> quicktype.
Expected Behavior
It should just type the text this another test: ... hello ...
. In many application, it does exactly that.
True Behavior
In a FreeBSD VM, pressing . renders a period at the shell (like normal). When the above script runs, however, the periods look like backspaces. End result:
In a Windows VM, . renders a period in Notepad (like normal). When the above script runs, however, the periods seem to be ignored completely. End result:
Questions
Is there a way to truly emulate pressing the keys from a string of characters in AppleScript? Because clearly the above way isn't doing that.
Does anyone know why the behavior I described above is happening? Why does this work in TextMate and Terminal, and other mac apps, but not in Fusion VMs?
u = Address.first
. I usedvim
to write everything so it wasn't converting anything like some word processors do.