我想在Finder应用程序中刷新特定文件/文件夹的图标.
FNNotifyByPath( (const UInt8 *)folderPath, kFNDirectoryModifiedMessage, kNilOptions );
Run Code Online (Sandbox Code Playgroud)
FNNotifyByPath不适合这个.现在我正在尝试使用appleScript
+(void) refreshIconForItem : (NSString *)itemPath
{
NSString *source=[NSString stringWithFormat:@"tell application \"Finder\" to update \"%@\"",[NSString stringWithUTF8String:itemPath]];
NSAppleScript *update=[[NSAppleScript alloc] initWithSource:source];
NSDictionary *err;
[update executeAndReturnError:&err];
}
Run Code Online (Sandbox Code Playgroud)
但是这个功能也不起作用.
有人可以帮帮我吗?
Javascript中的以下等效代码是什么?该Apple脚本可以转换为Java脚本吗?
tell application "Finder"
activate
set position of Finder window 1 to {607, 276}
close Finder window 1
end tell
Run Code Online (Sandbox Code Playgroud)
谢谢。
我正在使用我编写的脚本自动将动态IP写入.txt文件,但问题是单击退出按钮时无法关闭对话框.
set yn to (display dialog "Your ip has been written to the server, the application will re-run in 10 minutes if you DO NOT close this window." buttons {"Quit", "Run again"} giving up after 600)
if yn is equal to "Quit" then
quit
end if
Run Code Online (Sandbox Code Playgroud) 我希望Applescript能够从txt文件中设置变量,逐行读取或逐个字符地读取.也许像php函数:get_file_contents.有没有类似的东西或者你可以请我提供方式吗?
我知道如何设置文件路径.就像是
set myfile to "/Users/Username/Desktop/test.txt"
set theText to read myfile
Run Code Online (Sandbox Code Playgroud)
在txt文件中,它只是一行中的一个整数,比如
1
2
3
4
5
Run Code Online (Sandbox Code Playgroud)
如果我使用
set theTextList to paragraphs of theText
Run Code Online (Sandbox Code Playgroud)
结果将带有引号"".
我只想将这些整数设置为变量.所以以后我可以使用,比如
set variable to 5 --here I would like to replace the real number 5 to the number I read from the txt file(just one line)
start slideshow
show slide variable
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.
我正在尝试使用applescript ui编程自动化基于osx的Microsoft lync。到目前为止,我还不了解如何通过其值选择lync联系人列表中的项目。UI检查器显示以下层次结构:
AXApplication-AXWindow:AXStandradWindow-AXScrollarea-AXOutline-AXRow:AXOutlineRow-AXStaticText
AXValue:“音频测试服务-Verfügbar-nur语音邮件”
我尝试了这个:
告诉进程“ Microsoft Lync”以选择-????
收到一个主意真是太好了……!
首先,我是Applescript的新手,所以请多多包涵。
我目前在Dropbox文件夹中有一个纯文本文件。该文件设置为填充文本(并且仅填充文本)。我正在尝试创建一个Automator工作流程(或Applescript脚本),该工作流程将从文本文件中读取内容,并将内容写入剪贴板。这样,我可以在iOS设备上复制文本,将其粘贴到Dropbox的纯文本文件中,然后使用mac(和此脚本)将文本粘贴到mac。基本上,使用Dropbox在OS X和iOS之间同步剪贴板。
我想Applescript不能超过几行,但是我还没有找到编写它的正确方法。任何帮助表示赞赏!
我正在尝试获取AppleScript中文件的最后修改日期。我以为我使用以下方法工作:
set thePath to (((path to documents folder) as text) & "speed.txt")
set modDate to modification date of file thePath
Run Code Online (Sandbox Code Playgroud)
这似乎返回了一个有效值,但是当我将其放入on idle一段代码中时,我得到了:
“无法获得...的类<>”错误
我在其他地方看到了使用建议:
set the modDate to (do shell script "mdls -name kMDItemLasUsedDate " & quoted form of the POSIX path of thePath)
Run Code Online (Sandbox Code Playgroud)
但这又回来了null。关于如何获取修改日期的任何想法?
我有一个本地邮件规则,我想按计划申请.要手动应用所有规则,我可以单击"消息"菜单 - >"规则" - >"应用" - >"全部应用".
有没有办法使用Applescript自动执行此操作?我查看了字典中的Outlook,但没有找到任何与规则相关的操作.
或者,有没有办法用Automator做到这一点?
我正在尝试使用AppleScript制作别名.我使用的是Mac OS X 10.9.3(Mavericks).
sato ~ $ ll /Users/sato/src/test.txt
-rw-r--r-- 1 sato staff 18410 Jun 13 10:36 /Users/sato/src/test.txt
sato ~ $ ll dst/
total 0
sato ~ :( $ osascript -e 'tell application "Finder" to make alias file to POSIX file "/Users/sato/src/test.txt" at POSIX file "/Users/sato/dst"'
29:121: execution error: Finder got an error: Application isn’t running. (-600)
sato ~ :( $ osascript -e 'tell application "Finder" to make alias file to POSIX file "/Users/sato/src/test.txt" at POSIX file "/Users/sato/dst/"'
29:122: execution …Run Code Online (Sandbox Code Playgroud) 我是编码的新手所以请耐心等待我.
我用Automator(OSX)创建了一个工作流程,工作正常.我唯一的问题是我希望它在许多输入上运行(即作为批处理).我插入了Loop动作,但我遇到的问题是每次更改初始输入.
我想使用applescript每次自动插入初始输入.
我有一个带URL的TXT文件.使用Apple脚本,我想将URL(或一行文本)复制到剪贴板.在下一次迭代中,我想复制下一个URL(或文本行).
有人可以帮忙吗?
谢谢!!
applescript ×10
automator ×3
macos ×3
finder ×2
cocoa ×1
dropbox ×1
file ×1
javascript ×1
lync-2013 ×1
macos-carbon ×1
objective-c ×1
outlook ×1
outlook-2011 ×1
plaintext ×1
shell ×1
text ×1