if then語句在mac終端機使用applescript?

if then語句在mac終端機使用applescript?

代碼是什麼:

「如果 $foo 是 1,那麼 $foo 現在應該等於 18」?

謝謝

答案1

在 bash(命令列)中:

if [ "$foo" = "1" ] ; then
  foo=18
fi

在 AppleScript 中:

if foo equals 1 then
    set foo to 18
end if

回覆評論:

set foo to 5
tell application "System Events"
    tell application "Firefox" to activate
    keystroke (foo as text) using command down
end tell

您可以將其按原樣附加到我對上一個問題的回答中,減去該set foo行。

相關內容