使用预览对PDF文件进行密码保护时的长延迟
下面是我创建受密码保护的文件的脚本,但我不知道为什么第一个复选框需要12秒钟才能被单击 不过,第二次单击效果很好 我尝试过几件事,包括:没有成功使用预览对PDF文件进行密码保护时的长延迟,pdf,passwords,applescript,delay,password-protection,Pdf,Passwords,Applescript,Delay,Password Protection,下面是我创建受密码保护的文件的脚本,但我不知道为什么第一个复选框需要12秒钟才能被单击 不过,第二次单击效果很好 我尝试过几件事,包括:没有成功 activate application "Preview" tell application "System Events" tell process "Preview" keystroke "p" using command down delay 0.5 tell front window repeat un
activate application "Preview"
tell application "System Events"
tell process "Preview"
keystroke "p" using command down
delay 0.5
tell front window
repeat until exists sheet 1
delay 0.5
end repeat
tell sheet 1
click menu button "PDF"
repeat until exists menu 1 of menu button "PDF"
delay 0.02
end repeat
click menu item "Save as PDF" of menu 1 of menu button "PDF"
end tell
end tell
repeat until exists sheet 1 of sheet 1 of front window
delay 0.2
end repeat
tell sheet 1 of sheet 1 of front window
click button "Security Options..."
end tell
tell window "PDF Security Options"
set selected to true
set focused to true
-- NOTE: for some reason there is a delay of about 12 seconds here, I do not know why
try
tell checkbox "Require password to open document"
click
end tell
keystroke VarPassword
keystroke (ASCII character 9)
keystroke VarPassword
tell its checkbox "Require password to copy text, images and other content"
click
end tell
keystroke FixedPassword
keystroke (ASCII character 9)
keystroke FixedPassword
click button "OK"
end try
end tell
repeat until exists sheet 1 of sheet 1 of front window
delay 0.2
end repeat
keystroke "g" using {command down, shift down}
repeat until exists sheet of sheet 1 of sheet 1 of front window
delay 0.2
end repeat
delay 0.5
keystroke SaveFolder
delay 0.5
click button "Go" of sheet of sheet 1 of sheet 1 of front window
set value of text field 1 of sheet 1 of sheet 1 of front window to FileName
click button "Save" of sheet 1 of sheet 1 of front window
end tell
end tell