Created
April 17, 2012 15:13
-
-
Save moluapple/2406668 to your computer and use it in GitHub Desktop.
[Indesign]自动延时保存vbs脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rem ID_DelaySave.vbs | |
Rem An InDesign CS5 VBScript | |
Rem 测试环境: Win7, CS5 | |
Rem 自动延时保存 | |
Rem 请直接双面文件运行, 不要通过 ID 脚本面板运行 | |
main | |
Function main() | |
Set myInDesign = CreateObject("InDesign.Application") | |
myInDesign.InsertLabel "StopIt", "" | |
delaySave(myInDesign) | |
End Function | |
' 不会耗用 CPU 的 Sleep | |
Function ccSleep(seconds) | |
set oShell = CreateObject("Wscript.Shell") | |
cmd = "%COMSPEC% /c ping -n " & 1 + seconds & " 127.0.0.1>nul" | |
oShell.Run cmd,0,1 | |
End Function | |
' 现在可以通过执行 app.insertLabel("StopIt", "stop"); 来中断 | |
' 默认是程序退出时中断 | |
Function delaySave(myInDesign) | |
ccSleep(60) ' 时间设定, 单位: 秒 | |
mySnippet(myInDesign) | |
If myInDesign.ExtractLabel("StopIt") = "" Then | |
delaySave(myInDesign) | |
End IF | |
End Function | |
Function mySnippet(myInDesign) | |
If TypeName(myInDesign) = "Application" Then | |
If myInDesign.Documents.Count > 0 Then | |
myInDesign.Documents.Item(1).Save | |
End If | |
End If | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment