首页 > 文档 > launch()使用平台的启动器打开应用程序或文件
2017
07-14

launch()使用平台的启动器打开应用程序或文件

3-4.launch()

Name(名称):launch()//使用平台的启动器打开应用程序或文件。

Examples(例子):

void setup() {

size(200, 200);

}

void draw() {

// draw() must be present for mousePressed() to work必须存在draw()才能使mousePressed()工作

}

void mousePressed() {

println(“Opening Process_4”);

launch(“/Applications/Process_4.app”);

}

Description(描述):Attempts to open an application or file using your platform’s launcher. The filename parameter is a String specifying the file name and location. The location parameter must be a full path name, or the name of an executable in the system’s PATH. In most cases, using a full path is the best option, rather than relying on the system PATH. Be sure to make the file executable before attempting to open it (chmod +x).

尝试使用平台的启动器打开应用程序或文件。 filename参数是指定文件名和位置的String。 location参数必须是完整路径名,或系统路径中可执行文件的名称。在大多数情况下,使用完整路径是最佳选择,而不是依靠系统PATH。尝试打开文件(chmod + x)之前,请确保该文件可执行。

This function (roughly) emulates what happens when you double-click an application or document in the macOS Finder, the Windows Explorer, or your favorite Linux file manager. If you’re trying to run command line functions directly, use the exec() function instead (see below).

此功能(大致)模拟当您在MacOS Finder,Windows资源管理器或您最喜爱的Linux文件管理器中双击应用程序或文档时会发生什么。如果您想直接运行命令行函数,请改用exec()函数(见下文)。

This function behaves differently on each platform. On Windows, the parameters are sent to the Windows shell via “cmd /c”. On Mac OS X, the “open” command is used (type “man open” in Terminal.app for documentation). On Linux, it first tries gnome-open, then kde-open, but if neither are available, it sends the command to the shell and prays that something useful happens.

此功能在每个平台上的行为不同。在Windows上,这些参数通过”cmd / c”发送到Windows shell。在Mac OS X上,使用”open”命令(在Terminal.app中键入”man open”进行文档化)。在Linux上,它首先尝试gnome-open,然后启用kde-open,但是如果两者都不可用,则会将命令发送到shell,并祈祷有用的事情发生。

For users familiar with Java, this is not the same as Runtime.exec(), because the launcher command is prepended. Instead, the exec(String[]) function is a shortcut for Runtime.getRuntime.exec(String[]). The exec() function is documented in the JavaDoc in the PApplet class.

对于熟悉Java的用户,这与Runtime.exec()不同,因为启动器命令是前置的。相反,exec(String [])函数是Runtime.getRuntime.exec(String [])的快捷方式。 exec()函数记录在PApplet类的JavaDoc中

Syntax(语法):launch(args)

Parameters (参数):args——arguments to the launcher, eg. a filename.
发射器的参数,例如 文件名

Returns(返回值):process



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。