0
假設我有一個新的腳本添加,那麼appscript是否可以識別它們,以及如何使用appscript調用它們?如何使用Python Appscript調用自定義腳本添加?
假設我有一個新的腳本添加,那麼appscript是否可以識別它們,以及如何使用appscript調用它們?如何使用Python Appscript調用自定義腳本添加?
使用osax模塊。例子:
import osax
print osax.scriptingadditions() # lists installed scripting additions
standardadditions = osax.OSAX() # uses built-in StandardAdditions.osax (the default)
print standardadditions.random_number(from_=1, to=10)
satimage = osax.OSAX('Satimage') # uses 3rd-party Satimage.osax from satimage-software.com
print satimage.hypot([3, 4])
使用ASDictionary導出腳本除了術語在appscript格式。
OS X 10.6注意:osax模塊只能在32位進程中動態檢索腳本添加術語。如果將術語導出爲靜態膠水模塊並導入該模塊,但可以在64位進程中使用它,但這很麻煩。順便說一句,大多數第三方osaxen還不支持64位,所以你需要注意這一點。
就個人而言,我會嘗試找到一個本地的Python解決方案,然後再使用腳本添加,因爲osaxen是非常討厭的。因人而異。