Applescript的"从列表中选择"用户交互有一个"取消"按钮 - 我希望这个"取消"告诉脚本立即停止执行.换一种说法:
set wmColor to choose from list {"Black", "Black for all", "White",
"White for all"} with prompt "What color should the watermark be?"
default items "White for all" without multiple selections allowed and
empty selection allowed
if wmColor is false
*tell script to stop executing*
end if
Run Code Online (Sandbox Code Playgroud)
似乎无法找到如何做到这一点 - 有谁知道如何?
我正在尝试在Automator中编写一个Applescript,按住左箭头按钮,同时按住控制,选项和命令.我到目前为止的代码是:
on run {input, parameters}
tell application "System Events"
tell application "Sublime Text 2" to activate
keystroke "left" using {control down, option down, command down}
end tell
return input
end run
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用.有关如何修复此代码的任何建议?谢谢!
就是这样了.如何使用AppleScript写入文本文件?
我试过谷歌搜索,但答案似乎已经岁了几年,我不确定这几天应该是什么样的首选成语.
有没有办法检查屏幕是否被锁定在shell或applescript中?不只是检查屏幕保护程序是否正在运行,而是通过节能设置或按⌃⇧⏏(shift+ control+ eject)锁定屏幕.
先感谢您.
我有许多年前写的AppleScript.我使用此代码编程我的Harmony One通用遥控器上的按钮,以通过谷歌浏览器访问在线视频服务.代码无效.谷歌浏览器无法启动.我通过RemoteBuddy运行代码.代码符合要求,但不起作用.
任何人都对可能出现的问题有什么想法,或者我如何改进脚本以使其工作?
tell application "System Events" to set open_applications to (name of everyprocess)
if (open_applications contains "Google Chrome") is true then
tell application "Google Chrome" to quit
else
tell application "Google Chrome"
activate
open location "http://xfinitytv.comcast.net"
end tell
delay 1
tell application "Google Chrome" to activate
end if
Run Code Online (Sandbox Code Playgroud) 我正在为OSX开发一个项目,用户可以从中选择我需要生成PDF文档的文档集合(来自任何应用程序).标准的"Macintosh打印"对话框有一个PDF按钮,其中包含许多与PDF相关的命令,包括"另存为PDF ...".但是,我需要生成PDF文件而无需用户交互.理想情况下,我希望这适用于任何类型的文档.
这是我到目前为止探讨的选项:
我希望有一些方法可以与活动应用程序进行交互,就像用户执行以下步骤一样:
如果这是最好的方法(是吗?)那么真正的问题是:如何将UI事件发送到外部应用程序(击键,鼠标事件,菜单选择)?
更新:只是澄清一点:我需要转换为PDF的文档是由其他应用程序创建的文档.例如,用户可能会选择Word文档或Numbers电子表格或OmniGraffle绘图或网页.常见的分母是这些文档中的每一个都有一个相关的应用程序,该应用程序知道如何打印它(OSX知道如何将打印输出呈现为PDF文件).
因此,Cocoa Dev Central的样本没有帮助,因为它们是关于从我的应用程序生成PDF .
好吧,这感觉就像一个白痴问题,但我被卡住了 - 我不知道关于AppleScript的第一件事.我有一个.scpt文件,我想双击它,让它运行,但每次我点击它,它打开AppleScript编辑器.这感觉它应该只是文件的一个选项,但我遗漏了一些明显的东西.
请帮助我减少愚蠢,谢谢.
2部分问题:
我只是试图使用终端上的AppleScript来运行程序,所以我尝试了:
$ osascript tell application "iTunes" to activate
Run Code Online (Sandbox Code Playgroud)
并得到错误:
osascript: tell: No such file or directory
Run Code Online (Sandbox Code Playgroud)
提供该计划的完整途径也不起作用.我错过了什么?问题的第二部分是我最终想要使用applescript的内容.我想用它来打开我使用py2app构建的应用程序.Apple可以打开任何mac应用程序或只是已经兼容的某些应用程序.
谢谢
有人可以告诉我如何通过消息应用程序直接向iMessage用户发送消息吗?
tell application "Messages"
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 1
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 2
if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 3
send "Message" to buddy "mail of name" of service x
end tell
Run Code Online (Sandbox Code Playgroud)
我只需要通过iMessage向帐户发送消息,而不是通过Google Talk,AIM,bonjour.谢谢!
我正在尝试从终端运行AppleScript脚本,但我无法通过调用来打印任何内容
osascript myFile.scpt "/path/to/a/file"
Run Code Online (Sandbox Code Playgroud)
我尝试着:
on run fileName
set unique_songs to paragraphs of (read POSIX file fileName)
repeat with nextLine in unique_songs
if length of nextLine is greater than 0 then
set AppleScript's text item delimiters to tab
set song to text item 2 of nextLine
set artist to text item 3 of nextLine
set album to text item 4 of nextLine
set output to ("Song: " & song & " - " & artist & " - " & …Run Code Online (Sandbox Code Playgroud) applescript ×10
macos ×3
automator ×1
imessage ×1
io ×1
messages ×1
objective-c ×1
pdf ×1
send ×1
shell ×1