问题描述
我需要实现的是,使用 AppleScript:
- 唤醒远程 iMac
- 输入密码
- 接受密码登录
到目前为止,我成功做的是启用远程事件并连接到 iMac,但现在我卡住了。这是我到目前为止尝试过的:
set remotemachine to "eppc://192.168.0.26"
tell application "System Events" of machine remotemachine
keystroke 123
end tell
然而,这让我无处可去。它对我说“错误:应用程序未启动。编号 -600”。抱歉,这不是确切的英文字符串。
有谁知道我做错了什么? ?
提前致谢。
解决方法
两个主要问题:
-
System Events
不会在远程机器上永久运行,您无法从本地机器启动应用程序。您必须使用System Events
启动Finder
,这是唯一永久运行的应用程序。 -
您必须明确解决远程机器的
Finder
和System Events
,但还要添加一个using terms from
块,因为必须在本地解析术语。
此示例在远程计算机上启动 System Events
并重新调整桌面文件夹的路径
set RemoteMachine to "eppc://192.168.0.26"
tell application "Finder" of machine RemoteMachine
using terms from application "Finder"
if "System Events" is not in (get name of processes) then
open application file id "com.apple.systemevents"
repeat until "System Events" is in (get name of every process)
delay 1
end repeat
end if
end using terms from
end tell
tell application "System Events" of machine RemoteMachine
using terms from application "System Events"
set x to path of desktop folder
end using terms from
end tell