有没有办法用adobe air生成快捷方式文件?
下午好,
我想创建一个可以在文件系统中创建文件夹和文件夹快捷方式的应用程序。用户将单击一个按钮,它会在桌面上放置一个文件夹,该文件夹具有指向 //server/folder1/folder2 等文件的快捷方式 您可以在 adobe air 中使用代码创建桌面快捷方式吗?你会怎么做?如何创建文件夹?我一直认为这应该很容易,但我一直想念它。
感谢您的帮助,抱歉给您带来麻烦,
贾斯汀
Good afternoon,
I would like create a application that can can create folders and short cuts to folders in the file system. The user will click a button and it will put a folder on there desktop that has short cuts to files like //server/folder1/folder2 Can you create a desktop shortcut with code in adobe air? How would you do that? How do you create a folder? I keep thinking this should be easy but i keep missing it.
Thank you for your help sorry for the trouble,
Justin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您的部署配置文件是扩展桌面,您也许能够使用NativeProcess 以及一些您可以打包的简单脚本与您的应用程序。这种方法需要在每个操作系统的基础上处理功能,这需要一些工作和广泛的测试。然而,我至少想分享一个我验证确实有效的场景。下面是我整理的一个测试用例:
测试用例:Windows 7
即使 Adobe 文档表示它会阻止执行.bat 文件,显然它不会阻止执行 Windows 脚本宿主:wscript.exe。这意味着您可以执行任何 JScript 或 VBScript 文件。这就是您在 Windows 中编写命令来创建快捷方式的方法(因为 Windows 没有命令行命令来创建快捷方式)。
这是一个创建快捷方式命令的简单脚本,我在 giannistakiris.com,(转换为 JScript):
如果您将其打包在应用程序中名为的文件夹中utils,您可以编写一个函数来创建快捷方式,如下所示:
如果想在桌面上创建应用程序存储目录的快捷方式,则以下内容就足够了:
显然,还有很多工作要做这样做是为了处理不同的操作系统环境,但这至少是一个步骤。
If your deployment profile is Extended Desktop, you may be able to use NativeProcess and some simple scripts that you could package with your app. This approach would entail handling the functionality on a per OS basis, which would take some work and extensive testing. However, I wanted to at least share a scenario that I verified does work. Below is a test case that I threw together:
Test Case: Windows 7
Even though the Adobe documentation says that it prevents execution of .bat files, apparently it doesn't prevent one from executing the Windows Scripting Host: wscript.exe. This means you can execute any JScript or VBScript files. And this is what you would use to write a command to create a shortcut in Windows (since Windows doesn't have a commandline command to create shortcuts otherwise).
Here's a simple script to create a shortcut command, which I found on giannistsakiris.com, (converted to JScript):
If you package this in your application in a folder named utils, you could write a function to create a shortcut like so:
If one wanted to create a shortcut to the Application Storage Directory on the Desktop, the following would suffice:
Obviously there's a lot of work to be done to handle different OS environments, but this is at least a step.
据我所知,File 类不允许创建符号链接。但是您可以使用
createDirectory()
创建目录:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#createDirectory%28%29检查这是否有用: http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-concept/
As far as I know, File class does not allow the creation of symbolic links. But you can create directories with
createDirectory()
: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#createDirectory%28%29Check if this can be useful: http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-concept/
Air 本身不允许您创建快捷方式。这是适用于 Windows 的解决方法 [可能适用于 Mac,但我没有机器可以测试]。
使用 Air 创建一个包含以下纯文本的文件
将
path-to-folder-or-file
替换为您的文件夹/文件名将文件另存为
test.url
Windows将此文件识别为快捷方式。
Air doesnt let you create shortcuts natively. Here's a workaround that works with Windows [may work on Mac but I don't have a machine to test].
Using Air, create a file that contains the following plain text
Replace
path-to-folder-or-file
with your folder/file nameSave the file as
test.url
Windows recognizes this file as a shortcut.
可以强制 Adobe Air 在 Mac 上创建符号链接和其他有用的东西。我是这样做的:
您将需要 AIRAliases.js - 修订版:2.5
在 application.xml 中添加:
在 Air 应用程序中 JavaScript:
更改传递给 NativeProcess 的命令和参数的语法,您应该能够在 Windows 上获得真正的快捷方式也。
It is possible to coerce Adobe Air into creating symbolic links, other useful things, on a Mac. Here's how I did it:
You will need AIRAliases.js - Revision: 2.5
In the application.xml add:
In the Air app JavaScript:
Altering the syntax of the command and parameters passed to NativeProcess you should be able to get real shortcuts on Windows too.