-1

この簡単な Applescript アプリケーションを作成したところ、エラーが発生しました。コーディングは次のとおりです。

set buyannounce to "AUTOMATIC SERVER EMAIL : BUY"
set transferannounce to "AUTOMATIC SERVER EMAIL : TRANSFER"
set signupannounce to "AUTOMATIC SERVER EMAIL : SIGNUP"
set sellannounce to "AUTOMATIC SERVER EMAIL : SELL"
set nowsignup to "0"
set announce to "AUTOMATIC SERVER EMAIL"


set ¬
    currentSignups ¬
        to the text returned ¬
    of (display dialog ¬
    ¬
        "How many current signups?" default answer "")


tell application "Mail"
set unreadMessages to (get every message of mailbox "INBOX" of account "Yahoo" whose read status is true)
repeat with eachMessage in unreadMessages

    if announce is in (get content of eachMessage) then

        if buyannounce is in (get content of eachMessage) then
            --buy email 
        end if
        if transferannounce is in (get content of eachMessage) then
            --transfer email
        end if
        if signupannounce is in (get content of eachMessage) then
            set nowsignup to nowsignup + 1
            set eachMessageTrimmed to ((characters 33 thru -1 of (get content of eachMessage)) as string)
            display dialog nowsignup
            set filepath to POSIX path of "/Users/obleopold/Dropbox/Accounts.csv"
            try
                set command to "open " & quoted form of filepath
                do shell script command
            end try
            delay 10
            repeat currentSignups times
                tell "System Events" to keystroke return
            end repeat
            repeat nowsignup times



                tell "System Events"
                    keystroke eachMessageTrimmed --here is where I am getting the error
                end tell

                tell "System Events" to keystroke return
                currentSignups = currentSignups + nowsignup
                set nowsignup to "0"

            end repeat
        end if




            if sellannounce is in (get content of eachMessage) then
        --sell email
            end if

        end if
    end repeat
end tell
end
end
end
end
4

2 に答える 2

0

System Events はアプリケーションであるため、tell ブロッ​​クには必要です

tell application "System Events"

それ以外の

tell "System Events"

さらに、tell ブロッ​​クのネストを防ぐには、以下を使用できます。

tell application "System events"
    tell process "Mail"
        keystroke "My Keystroke"
    end tell
end tell

または1行で:

tell application "System Events" to tell process "Mail" to keystroke "My Keystroke"
于 2013-08-24T20:59:24.870 に答える