objective-c - applescript 未设置图标图像(El Capitan)
问题描述
这个问题是如何更改使用 applescript 创建的别名图标的延续?
提供的解决方案适用于 High Sierra,但不适用于 El Capitan。没有为别名设置图标。是否需要进行任何更改才能使其也适用于 El Capitan?
如果是,有人可以提供代码片段。
谈到applescript,我是一个完全的新手,所以我不知道为什么这不起作用。
这是我的代码
use framework "Foundation"
use scripting additions
set ideContentsPath to ".../IDE/WebOSIDE.app/Contents" -- path of Contents folder which i replace at runtime from my java program
set ideExec to ideContentsPath & "/MacOS/WebOSIDE"
set sourceFile to (POSIX file ideExec)
tell application "Finder"
set newAlias to (make new alias file at desktop to sourceFile) as alias
set iconPath to ideContentsPath & "/Resources/WebOSIDE.icns"
my setIcon(newAlias,iconPath)
set name of newAlias to "My Shortcut"
duplicate newAlias to folder "my Dir" of folder "Applications" of startup disk
end tell
to setIcon(fileRef,iconPath)
set iconImage to current application's NSImage's alloc's initWithContentsOfFile:iconPath
current application's NSWorkspace's sharedWorkspace's setIcon:iconImage forFile:(POSIX path of fileRef) options:0
end setIcon
解决方案
推荐阅读
- python - ValueError: 层 lstm_1 的输入 0 与层不兼容:预期 ndim=3,发现 ndim=2。收到的完整形状:(无,64)
- css - SVG 动画 onclick
- javascript - 如何根据页码从base64字符串pdf中获取页面内容 - 角度或javascript
- c# - 如何从另一个应用程序清除 IIS 上应用程序的缓存?
- eclipse - AgentSet 无法解析为输入 Repast Simphony 模型
- node.js - 有没有办法从包裹中取出 Apollo 型防护装置?
- java - 设置图像背景java swing
- rust - 如何在带有 r_efi crate 的 rust 项目中使用 UEFI locate_protocol
- c++ - C++:使用初始化列表进行缩小转换
- .net - LiveChart Winform Geared 在列系列的笛卡尔图表中崩溃