制作一个AppleScript地址簿

时间:2016-10-06 23:10:17

标签: text applescript

我正在尝试制作一个打开文档的AppleScript,并将文本框中输入的内容添加到文档中,然后将其保存到路径中。当我尝试保存它时,它只是说“因为文件不存在而无法保存x”。

这是我的代码

display dialog "username" default answer ""
set the target_username to the text returned of the result
display dialog "password" default answer "" with hidden answer
set the pass to the text returned of the result
if target_username is "Plasma" and pass is "Sship" then
    display dialog "Welcome! Please select a function!" buttons {"Add address", "View address"}
    if button returned of result is "Add address" then
        set booka to text returned of (display dialog "rers!" default answer "")
        tell application "TextEdit"
            activate
            make new document
            set text of document 1 to booka

            delay 10
            set thePath to "/Users/Cameron/Desktop/"
            set thedoc to document 1
            set thetitle to "food"
            save thedoc in (thePath & thetitle)
        end tell
    else
        display dialog "no"
    end if
else
    display dialog "no"
end if
}

1 个答案:

答案 0 :(得分:0)

下面的脚本可以保存在txt文件中。

set booka to "my string" -- set booka variable just for testing !
tell application "TextEdit"
activate
make new document
set text of document 1 to booka
set thePath to "Users:Cameron:Desktop:food.txt"
tell document 1 to save in file thePath
end tell
相关问题