【问题标题】:Keystrokes In ApplescriptApplescript 中的击键
【发布时间】:2017-11-13 16:54:15
【问题描述】:

我正在尝试在 Mac OSX 上运行一个 applescript 应用程序,该应用程序会自动使用 photobooth 拍照。它不工作。拍照的按键是“命令”和“返回”。

到目前为止,这是我的脚本:

tell application "Photo Booth"
    activate
end tell
tell application "System Events"
    delay 3
    keystroke "return" using command down
end tell

【问题讨论】:

    标签: macos applescript


    【解决方案1】:

    告诉应用程序“Photo Booth”
    激活
    结束告诉
    告诉应用程序“系统事件”
    延迟 3
    按键返回--不需要命令
    结束告诉

    【讨论】:

      【解决方案2】:

      如果你想要一张即时照片,你可以改用这个:
      告诉应用程序“Photo Booth”
      激活
      结束告诉
      告诉应用程序“系统事件”
      延迟 3
      使用 {command down, option down} 的击键返回
      结束告诉

      【讨论】:

        【解决方案3】:

        当 Photo Booth 已经打开时,这会加快速度。

        on is_running(appName)
            tell application "System Events" to (name of processes) contains appName
        end is_running
        
        set safRunning to is_running("Photo Booth")
        if safRunning then
            tell application "Photo Booth" to activate
            delay 0.3
            tell application "System Events" to keystroke return using command down
        else
            tell application "Photo Booth" to activate
            delay 3
            tell application "System Events" to keystroke return using command down
        end if
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多