2016-11-24 60 views
0

我有一個腳本,其中包含檢查文檔第一個故事的功能。當我運行這個時,會彈出一個對話框,詢問我是否要將文本更新爲最新版本。由於該函數每次運行腳本都會運行多次,因此我想通過每次回答yes來取消該對話框。有沒有辦法在他們出現時自動對這些對話說「是」,或者只是用自動響應來壓制它們?是否可以抑制Extendscript中的CheckOut/CheckIn對話框?

function doccheckout(doc) { 
    // get the main story 
    var stories = doc.stories 
    var story = stories.firstItem() 
    // check out the main story 
    story.checkOut() 
    } 

同樣的事情發生時,我關閉了文件與document.checkIn(),所以我想,以抑制一個爲好,但我認爲任何解決方案的第一部分將適用於第二。

相關的彈出窗口

enter image description here

回答

2

嘗試禁用用戶交互:

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT; 
// your code here 
// 
// at the end of your script reset it to the default 
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL; 
+0

看來最後一行應該是'UserInteractionLevels.INTERACT_WITH_ALL'。 – milligramme

+0

謝謝@milligramme – fabianmoronzirfas

+0

由於某種原因,我得到'UserInteractionLevels是未定義的。但是,對象模型查看器顯示它存在。 [This old thread](https://forums.adobe.com/thread/871757)建議使用'app.displayDialogs',它似乎不在最新的8.0對象模型中。 – Arcandio

相關問題