gpt4 book ai didi

c++ - 如何从 C++ 程序执行简单的 Applescript?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:38:46 26 4
gpt4 key购买 nike

我想从 C++ 程序执行 Applescript 命令 tell application "Finder"to open POSIX file */path/to/somefilename*。看起来我可能想使用 OSACompileExecute,但我找不到如何使用它的示例。我一直在寻找如何使用 OSACompile 终端命令的示例。有人可以提供示例或示例链接吗?

最佳答案

好吧,诀窍是不要费心去编译和执行 Applescript,而是简单地使用 osascript 系统命令:

    sprintf(cmd, "osascript -e 'tell app \"Finder\" to open POSIX file \"%s/%s\"'", getcwd(path, MAXPATHLEN), file);
system(cmd);

pathfile 都是 char[] 变量。

我从this excerpt得到线索来自 Applescript:权威指南

关于c++ - 如何从 C++ 程序执行简单的 Applescript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9101450/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com