我正在使用此代码获取窗口标题:
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
end tell
tell application frontApp
set window_name to name of front window
end tell
Run Code Online (Sandbox Code Playgroud)
但是,在某些情况下,这会失败.显然,当没有打开的窗口时它会失败,但那是好的.但是,在某些情况下,例如Texmaker,它会因错误而失败.它也不适用于预览.
什么是获得窗口标题的方法,即使像Texmaker这样的情况?
我正在尝试编写一个脚本来取消最小化以前最小化停靠的应用程序.问题是,我找不到相关的财产.我试过了miniaturized,collapsed但窗户和过程似乎都没有?
我使用的应用程序(用于测试)是Zipeg,一个免费的打包工具.
我也尝试点击按钮,快乐地最小化应用程序,但是在已经最小化的应用程序上运行时给我一个错误来恢复它,可能是因为没有窗口可见.这个脚本如下.
tell application "System Events"
tell process "Zipeg"
click button 1 of window 1
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
我用来列出属性的脚本如下.
tell application "System Events"
tell process "Zipeg"
get properties
tell window 1
get properties
end tell
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
applescript当Outlook中有新消息时,我正在尝试修改一个触发咆哮通知的内容.原始脚本在这里.
在我的if陈述中,我试图说,如果文件夹是已删除邮件,垃圾邮件或已发送邮件,请不要触发通知.
这是声明:
if folder of theMsg is "Junk E-mail" or "Deleted Items" or "Sent Items" then
set notify to false
else
set notify to true
end if
Run Code Online (Sandbox Code Playgroud)
看来applecript不喜欢我添加的多个/或项目.有没有办法包含多个条件,还是我需要编写嵌套的if/then?
我有一个应用程序,同时打开几个窗口.我想把一个特定的窗口带到前台(我知道它的标题).
目前我正在使用组合键来完成这项任务,但我想尝试一些不同的东西,因为我遇到了这种方法的一些问题.
tell application "System Events"
set frontmost of process "appIT" to true
keystroke "1" using command down
delay 0.2
end tell
Run Code Online (Sandbox Code Playgroud) 我想创建一个使用AppleScript的应用程序来复制系统信息并通过电子邮件发送给自己.我知道要做电子邮件方面,以及如何使电子邮件具有剪贴板中的任何内容.我如何使用AppleScript编码将文本复制到剪贴板?
如果它有帮助,可以通过电子邮件发送给剪贴板中的任何内容:
set a to "uselessdecoy@gmail.com"
tell application "Mail"
tell (make new outgoing message)
set subject to (the clipboard)
set content to "content"
make new to recipient at end of to recipients with properties {address:a}
send
end tell
end tell
Run Code Online (Sandbox Code Playgroud) 我在优胜美地,我想切换隐藏/显示Mac上的所有隐藏文件.
每次,我想这样做,我必须去Terminal.app并运行这些命令:
显示
defaults write com.apple.finder AppleShowAllFiles TRUE
隐藏
defaults write com.apple.finder AppleShowAllFiles FALSE
我想知道是否有一个更好的调整,只需点击一下按钮即可实现这一目标.
我需要创建一个AppleSript,它将指定的文件从一个文件夹复制到新创建的文件夹.
需要在AppleScript编辑器中指定这些文件,如下所示:
start
fileToBeMoved = "Desktop/Test Folder 1/test.doc"
newfoldername = "Test Folder 2"
make newfolder and name it 'newfoldername'
copy 'fileToBeMoved' to 'newfolder'
end
Run Code Online (Sandbox Code Playgroud) 如果我转到系统偏好设置,键盘,键盘快捷键,然后是应用程序快捷方式,我可以定义要在Mac上使用的自定义快捷方式.
有没有办法通过Applescript访问此功能?
我们正在使用Mac OSX 10.9上的Qt 5.2.0.Framework为Mac App Store开发应用程序.
这是一个简单的AppleScript,可以创建Microsoft Excel工作簿并保存到任何位置.
tell application "Microsoft Excel"
set myworkbook to make new workbook
set fname to POSIX file "/Private/var/root/Download/ExcelFile" as text
save workbook as myworkbook filename fname
end tell
Run Code Online (Sandbox Code Playgroud)
上面的脚本保存为Untitled.scpt在/Library/ApplicationScript/.
在应用程序内部,我们使用Cocoa框架来执行AppleScript.
此AppleScript在非沙盒应用程序中工作.它在沙盒应用程序中失败.
我的问题是:如何在沙盒应用程序中使用AppleScript?或者有替代方案吗?
请告诉我解决方案,因为我的项目因此而被推迟.
谢谢


cocoa applescript entitlements mac-app-store appstore-sandbox
桌面上显示的文件来自该文件夹
/用户/用户/桌面
我想知道是否有任何方法可以更改,以便桌面上显示的文件来自不同的文件夹?
这背后的目的是使用谷歌驱动器(https://www.google.com/drive/download/)并在我的云端硬盘帐户中创建一个"桌面"文件夹,允许我从任何地方同步和访问我的桌面,而无需使用太多本地存储,显示桌面上的所有文件
/ Users/USER/Google Drive/Mac Desktop
提前感谢所有帮助!
applescript ×10
macos ×5
clipboard ×1
cocoa ×1
copy ×1
directory ×1
entitlements ×1
file ×1
finder ×1
foreground ×1
keyboard ×1
osx-yosemite ×1
terminal ×1
window ×1