我正在写一个小的applescript,它在查看器中检索所有"未读"的消息并循环它们.
我有两个目标需要完成:
我需要获取每条消息的主题并执行正则表达式以查看它是否适合第2步(例如:使用主题{.*}获取电子邮件)
我需要在一个单独的窗口打开每条消息,4秒后,我需要关闭该窗口并继续下一条消息
你知道怎么做吗?
提前致谢.
我正在制作一个涉及从Applescript控制Safari的应用程序.在终端(首选)或Applescript中是否有办法删除Safari的cookie.基本上我想使用终端菜单中的"重置Safari"项目.有没有办法可以做到这一点?
我正在做的是在Cocoa中执行AppleScript。它返回一些数据作为NSAppleEventDescriptor,NSLog()打印如下:
<NSAppleEventDescriptor: 'obj '{ 'form':'name', 'want':'dskp', 'seld':'utxt'("69671872"), 'from':'null'() }>
Run Code Online (Sandbox Code Playgroud)
我想获取这些数据并将其转换为NSDictionary或NSArray或有用的东西,以便我可以从中提取内容(特别是在持有“ 69671872”数字的字段之后)。它似乎是各种各样的数组,但是我对Apple Events的了解非常有限。关于如何执行此操作的任何想法?
这是创建上述数据的源:
NSString *appleScriptSource = [NSString stringWithFormat:@"tell application\"System Events\"\n return desktop 1\n end tell"];
NSDictionary *anError;
NSAppleScript *aScript = [[NSAppleScript alloc] initWithSource:appleScriptSource];
NSAppleEventDescriptor *aDescriptor = [aScript executeAndReturnError:&anError];
NSLog (@"%@", aDescriptor);
[aScript release];
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!:)
我想编写一个AppleScript,它允许我使用给定的库启动iTunes,而不必按住Option键并浏览一个.我已经知道了Doug的图书馆经理,这不是我想要的.AppleScript将用于特定的库.
我想在更新后重新加载预览中的文件(.png,.pdf).如何实现这一目标?
在OS X 10.5和10.6中,它就像切换到预览一样简单 - 它会自动重新加载新文件.或者,您可以使用open -a Preview *.png或类似的东西.在10.7中,自动重新加载不起作用(参见本文).
我的第一次尝试是从命令行运行的applescript脚本:
/usr/bin/osascript -e 'tell application "Preview.app" to activate
tell application "Preview.app" to open "'$PWD/$*'"'
Run Code Online (Sandbox Code Playgroud)
这适用于单个文件,但由于显而易见的原因而无法使用多个文件.我做了一些研究,并尝试使用更复杂的Applecript涉及set和列表,但这会导致权限错误:

这是我使用的python脚本(我的bash脚本技能不符合字符串解析的任务):
#!/usr/bin/env python
import optparse
import os
parser=optparse.OptionParser()
options,args = parser.parse_args()
pwd = os.getcwd()
cmd = '/usr/bin/osascript -e '
scriptcmd = "tell application \"Preview.app\" to activate\n"
flist = [ fn if fn[0]=='/' else pwd+"/"+fn for fn in args]
scriptcmd += "set myList to {\"%s\"}\n" % ( '","'.join(flist) )
scriptcmd += …Run Code Online (Sandbox Code Playgroud) 下面的Applescript是我用过多年的形式.并且基本上是使用Applescript发送电子邮件的众所周知的方法.
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"IP Address", content:"Your IP Address Is: 86.195.132.134"}
tell newMessage
set visible to false
set sender to "mark@sender.com"
make new to recipient at end of to recipients with properties {address:"recipient@mac.com"}
send
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
我今天刚刚注意到的是脚本中设置的"发件人"电子邮件,如果未选中其帐户邮箱,则可能不是Mail.app使用的电子邮件.如果选择了主收件箱,或者如果选择了单个邮箱,则将使用随机邮箱,然后将使用其帐户中的地址.
我认为这是因为在Mail首选项中,在Composing下.有一个设置为" 发送新邮件:"

你不能选择'否'.唯一的选项是"所选邮箱的帐户"或组合框下拉列表中的一个电子邮件地址.
我必须承认,在我去狮子会之前,我不知道这是否发生过.
有没有人知道这个的修复,或者这是一个已知的错误?
谢谢.
我尝试创建一个AppleScript,它读取文本文件并将内容放入列表中.该文件是一个简单的文本文件,其中每一行都如下所示:example-"example"
第一个是文件名,另一个是文件夹名.
这是我现在的代码:
set listOfShows to {}
set theFile to readFile("/Users/anders/Desktop/test.txt")
set Shows to read theFile using delimiter return
repeat with nextLine in Shows
if length of nextLine is greater than 0 then
copy nextLine to the end of listOfShows
end if
end repeat
choose from list listOfShows
on readFile(unixPath)
set foo to (open for access (POSIX file unixPath))
set txt to (read foo for (get eof foo))
close access foo
return txt
end readFile
Run Code Online (Sandbox Code Playgroud)
当我运行输出时,我得到这个:
error "Can not …Run Code Online (Sandbox Code Playgroud) 出于某种原因,当我检查文件是否存在时,它总是返回true:
display dialog (exists (homePath & "Desktop/11-14.csv" as POSIX file as string))
Run Code Online (Sandbox Code Playgroud)
无论是否在我的桌面上有一个名为csv的csv,它都会返回true.我想创建一个通过文件存在工作的if函数,但因为它总是返回true,所以它搞砸了我的if函数.我该怎么做才能解决这个问题?
苹果脚本中是否有命令右键单击文件并调出上下文菜单?
我正在寻找类似的东西
tell application "Finder"
set theDesktopItems to every item of desktop
right click item 1 of theDesktopItems
end tell
Run Code Online (Sandbox Code Playgroud) 我以前使用AppleScript多年,但几天后,我再也无法运行了
我有错误消息
"dyld:未加载库:/usr/lib/libnetsnmp.25.dylib引用自:/ usr/bin/php原因:找不到图像""dyld:未加载库:/usr/lib/libnetsnmp.25.dylib引用来自:/ usr/bin/php原因:未找到图片(1005)"我知道如何解决这个问题
非常感谢
applescript ×10
macos ×4
appleevents ×1
cocoa ×1
dyld ×1
file ×1
itunes ×1
objective-c ×1
osx-lion ×1
preview ×1
safari ×1
terminal ×1
text ×1