我有以下脚本
#!/bin/bash
/usr/bin/osascript << EOT
set myfile to choose file
EOT
no_ext=$(python -c "print '$myfile'.split('.')[0]")
### this works - just need to know how to pass the arg
R CMD Sweave no_ext.Rnw
pdflatex no_ext.tex
open no_ext.pdf
Run Code Online (Sandbox Code Playgroud)
任何人都可以指向"如何正确传递变量myfile"?
为所有建议编辑Thx!
不知道接受什么,所有答案都对我有所帮助,因为我从每个人那里学到了很多东西.
我想知道如何每小时在我的电脑(Mac OS X)上发出一个弹出警报.我认为在Applescript中写这个很简单,但我没有Applescript经验.谢谢
如何使用AppleScript命令将播放列表中的歌曲移动到列表中的其他位置?
我已经有了这首歌和播放列表,而其中一首已经在另一首; 我只需改变立场.
我的目标是对用户选择的曲目进行排序; 理想情况下,我想将逐个首选的轨道移动到第一个选择轨道的位置,并在第一个按顺序之后立即按顺序排序所有其他选定的轨道.
我多次听说AppleScript Studio,但我找不到任何下载链接.
一个教程说我可以启动Xcode并在启动一个新项目时在Application下选择AppleScript,但没有列出任何与AppleScript有关的内容.
如何下载AppleScript Studio?
在Mac OSX Lion中,我正在尝试为特定文件类型设置默认应用程序.使用下面的Apple脚本,我们可以为特定的"file.abc"设置默认应用程序.
tell application "System Events"
set default application of file "/Users/test/Desktop/file.abc" to "/Applications/TextEdit.app"
end tell
Run Code Online (Sandbox Code Playgroud)
但我想为所有文件类型或扩展名为"abc"的文件设置相同的默认应用程序.
我已经尝试了以下方法来完成它.它添加了一个条目<HOME>/Library/Preferences/com.apple.LaunchServices.plist.但是文件不会使用指定的应用程序打开.
defaults write com.apple.LaunchServices LSHandlers -array-add "<dict><key>LSHandlerContentTag</key><string>abc</string><key>LSHandlerContentTagClass</key><string>public.abc</string><key>LSHandlerRoleAll</key><string>com.apple.textedit</string></dict>"
Run Code Online (Sandbox Code Playgroud)
希望有人知道我失去了什么来实现它.
答案发现:
defaults write com.apple.LaunchServices LSHandlers -array-add "<dict><key>LSHandlerContentTag</key><string>ugurugu</string><key>LSHandlerContentTagClass</key><string>public.filename-extension</string><key>LSHandlerRoleAll</key<string>org.videolan.vlc</string></dict>"
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user
Run Code Online (Sandbox Code Playgroud) 如何在safari中打开一个新窗口,然后使用苹果脚本在该窗口中打开包含不同URL的多个选项卡?
有谁知道该文件InfoPlist.strings是为了什么?它在Xcode 3.2中.它是Applescript中的Cocoa应用程序.
这可能是一个全新的问题,但在这里.我正在制作一个纯AppleScript应用程序.它激活另一个应用程序,然后键入.问题是,当它激活应用程序时,它不会将应用程序窗口置于最前面.我试着告诉应用激活:
tell application "app_name.app"
activate
tell application "System Events" to keystroke "test"
end tell
Run Code Online (Sandbox Code Playgroud)
有帮助吗?谢谢!
我使用applescript以root权限启动我的脚本.
osascript -e "do shell script \"myscript.sh\" with administrator privileges"
Run Code Online (Sandbox Code Playgroud)
此文本显示在提示中:
osascript wants to make changes.
Type your password to allow this.
Run Code Online (Sandbox Code Playgroud)
如何将名称"osascript"更改为我的可执行文件名称?有没有办法在此提示中更改图标?
我正在使用OS X JavaScript for Automation(JXA),我希望能够捕获"开放位置"的Apple Event.
根据http://www.macosxautomation.com/applescript/linktrigger/,我设置了一个客户URL处理程序.我该怎么做相同的
on open location this_URL
...
end open location
Run Code Online (Sandbox Code Playgroud)
与JXA?我尝试了以下所有方法,但无法执行任何操作:
app = Application.currentApplication();
app.includeStandardAdditions = true;
function run() {
app.displayDialog(JSON.stringify(arguments));
}
function openLocation() {
app.displayDialog(JSON.stringify(arguments));
}
function openDocuments() {
app.displayDialog(JSON.stringify(arguments));
}
function onOpenLocation() {
app.displayDialog(JSON.stringify(arguments));
}
Run Code Online (Sandbox Code Playgroud)
Apple的JXA文档(https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/Articles/OSX10-10.html#//apple_ref/doc/uid/TP40014508-CH109-SW15)don '讨论如何处理开放位置事件.我的脚本将被打开,因为如果我将其添加到函数之外,我可以显示警告.我只是无法获得一个函数来执行并在URL中传递.
我正在通过使用AppleScript处理程序来解决这个问题,然后调用我的JXA代码,但这肯定不太理想.
我也没有在JXA Cookbook(https://github.com/dtinth/JXA-Cookbook)中看到任何相关内容.
applescript ×10
macos ×7
xcode ×2
automation ×1
filesystems ×1
itunes ×1
objective-c ×1
privileges ×1
prompt ×1
safari ×1
shell ×1