替换所有错误,Applescript

时间:2015-05-20 00:24:47

标签: applescript

我试图让这个脚本使用击键点击“全部替换”。

我收到错误:

  

“系统事件出错:无法获取按钮\”全部替换\“。”数   -1728来自“全部替换”按钮

tell application "Mail"
    set theSenderList to {}
    set theMessages to the selected messages of message viewer 0
    repeat with aMessage in theMessages
        set end of theSenderList to {address of to recipient of aMessage, " OR"}
    end repeat
    set AppleScript's text item delimiters to " "
    set the clipboard to (theSenderList as string)
    set AppleScript's text item delimiters to " "
    beep
end tell

set clip to (the clipboard as text)
tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set value of cell "a9" to clip
end tell

tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set value of cell "b9" to current date
end tell

tell application "Numbers"
    activate
end tell
tell application "System Events"
    delay 1.0
    keystroke "f" using command down
    keystroke "@gmail.com"
    keystroke tab
    keystroke ""
    delay 2
    click button "Replace All"
end tell

1 个答案:

答案 0 :(得分:0)

您似乎正在尝试更换" @ gmail.com"在一堆带有空格的电子邮件地址中,从而删除了该地址的那一部分。你可以在普通的AppleScript中轻松地做到这一点:

set targetAddresses to {"fred@gmail.com", "wilma@gmail.com", "barney@gmail.com"}

set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "@gmail.com"
set fixedAddresses to {}
repeat with eachAddress in targetAddresses
    set end of fixedAddresses to text item 1 of eachAddress
end repeat
set AppleScript's text item delimiters to astid
fixedAddresses

-->{"fred", "wilma", "barney"}

这接近你想要达到的目标吗?