Macos 转到正在运行的Safari,然后使用AppleScript按Enter键
我对AppleScript非常陌生,我正在尝试这样做。我的机器上运行着一个Safari进程。我希望我能去跑步旅行,刺激一个回车键事件 有可能吗 我正在尝试的代码是:Macos 转到正在运行的Safari,然后使用AppleScript按Enter键,macos,applescript,Macos,Applescript,我对AppleScript非常陌生,我正在尝试这样做。我的机器上运行着一个Safari进程。我希望我能去跑步旅行,刺激一个回车键事件 有可能吗 我正在尝试的代码是: on is_running(appName) tell application "System Events" to (name of processes) contains appName end is_running set safRunning to is_running("Safari") if safRunnin
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
set safRunning to is_running("Safari")
if safRunning then
run script "tell application \"Safari\"
key code 36
end tell"
return "Running"
else
return "Not running"
end if
在运行脚本
中,键code 36
(用于输入)显示错误:
error "Expected end of line but found identifier." number -2741
猜猜我哪里出错了吗?试试:
if application "Safari" is running then
activate application "Safari"
tell application "System Events" to keystroke return
else
return "Not running"
end if