如何获取applescript以将应用程序版本与变量进行比较

时间:2019-05-29 15:06:40

标签: applescript

我的applescript中有一行内容,该行不会读取为应用程序名称设置的变量

set ReadAppVersion to value of version of application TheApp

但是如果我在下面使用它,它将起作用。

set ReadAppVersion to value of version of application "OsiriX"

由于某种原因,如果我将其用作变量名,则无法读取该应用程序的版本。

但是如果我在下面使用它,它会起作用。

set ReadAppVersion to value of version of application "OsiriX"
on AppOsirixChecks(TheApp)
  delay 1
  tell application "Finder"
    close every window
  end tell
  do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE"
  tell application "Dock"
    tell application "System Events"
      tell process "Dock"
        click UI element "Finder" of list 1
      end tell
    end tell
  end tell
  menu_click({"Finder", "Go", "Applications"})
  delay 1
  set ReadAppName to 0
  set ReadAppVersion to 0
  set TheRow to 2
  tell application "System Events"
    tell process "Finder"
      repeat until ReadAppName is equal to TheApp
        set ReadAppVersion to value of version of application "osirix"
        set ReadAppName to value of text field 1 of UI element 1 of row TheRow of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Applications"
        set TheRow to TheRow + 1
        if ReadAppVersion doesn't equal AppVersionOsiriX then
          log "TEST FAILURE !: The current version is: " & ReadAppVersion
        end if
      end repeat
    end tell
  end tell
  log ">>>                 Current Application Name is: " & ReadAppName
  log ">>>              Current Application version is: " & ReadAppVersion
  --return TheRow  -- this line does not seem necessary
  tell application "Finder"
    activate
    delay 2
    close every window
    do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE"
  end tell
end AppOsirixChecks
  

<filepath>/upgrade_test_validation_checklist.scpt:10612:10617: execution error: OsiriX got an error: Can’t make «class valL» of version into type specifier. (-1700)

2 个答案:

答案 0 :(得分:0)

没有value of version

要获取应用程序的version,请省略value of

set ReadAppVersion to version of application "OsiriX"

将行移动到System Events告诉块之前,因为您只需要获取一次该值即可。

老实说,我不知道脚本应该做什么。为什么GUI编写Finder窗口的脚本?

答案 1 :(得分:0)

尝试通过名称而不是引用来询问。这对我有效(甚至不在“告诉”查找程序块中)。

set theApplication to "EasyFind"
set theVersion to version of application named theApplication