【问题标题】:Go to the Running Safari And Press Enter Using AppleScript转到正在运行的 Safari,然后使用 AppleScript 按 Enter
【发布时间】:2013-12-21 03:51:48
【问题描述】:

我对 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 safRunning then
    run script "tell application \"Safari\" 
         key code 36
    end tell"
    return "Running"
else
    return "Not running"
end if

run script 里面key code 36(用于刺激输入)给我错误:

error "Expected end of line but found identifier." number -2741

你猜我哪里出错了?

【问题讨论】:

    标签: macos applescript


    【解决方案1】:

    试试:

    if application "Safari" is running then
        activate application "Safari"
        tell application "System Events" to keystroke return
    else
        return "Not running"
    end if
    

    【讨论】:

      猜你喜欢
      • 2012-04-19
      • 2015-06-28
      • 1970-01-01
      • 1970-01-01
      • 2014-09-15
      • 2015-01-13
      • 1970-01-01
      • 2011-11-12
      • 1970-01-01
      相关资源
      最近更新 更多