小智 15
抱歉,John Schmitt,您未经测试的解决方案不起作用,但您走在正确的轨道上。这个已经过测试,它有效。
正确的命令是(如果您将 Applescripts 嵌入到 shell 脚本中,我更喜欢这样做):
osascript -e 'tell application "System Events" to key code 144 using command down'
Run Code Online (Sandbox Code Playgroud)
例如,在目标显示机器上将其保存为 ~/bin/tdm.sh。
然后,从主机,在终端发出这个:
ssh username@target-display-machine "~/bin/tdm.sh"
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以保存和调用 Applescript 命令。我发现将它们嵌入到 shell 脚本中更加方便和一致——这是我的特别偏好,因为无论如何我都做了很多 shell 脚本。
小智 3
未经测试,但我可能会考虑在 iMac 上的 ~/bin/command_f2 中创建一个包含以下内容的 applescript:
使用 {command down} 告诉应用程序“系统事件”按“F2”
然后从您的笔记本电脑类型:
ssh me@imac '~/bin/command_f2'
要获得有关此问题的更多帮助,请考虑将标题更改为“通过 ssh 发送击键”之类的内容,因为“键”可能意味着与 ssh 键混淆。
祝你好运。