如何在MacOS上使用Python运行Osascript?
如何使用osascript或MacOS上的任何其他方法在系统首选项中添加登录项目, 这个过程对吗? subprocess.call(“ osascript -e将登录项目添加到系统首选项{路径:“/home”; value; value; value; nidend} en end,shell = true')。
How can you add login item in system preferences with python using osascript or any other method on macos,
Is this process right?
subprocess.call("osascript -e add login items to System Preferences {Path: "/home"; value: hidden} at end, shell=True").
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以将
osascript
与 python 一起使用,但是您需要对两者使用适当的命令语法。我不确定您在哪里提出了该脚本,但是可以在应用程序的脚本词典中找到AppleScript项(如果有一个),在这种情况下,登录项目suite suite suite system事件。由于AppleScript仅使用双引号,因此使用
subprocess.call
使用参数的字符串列表可以避免很多报价逃脱,并且会避免以下内容:Yes, you can use
osascript
with Python, but you will need to use the proper command syntaxes for both. I'm not sure where you came up with that script, but AppleScript terms can be found in an application's scripting dictionary (if it has one), in this case the Login Items Suite from System Events.Since AppleScript only uses double quotes, using
subprocess.call
with a list of strings for the arguments can avoid a lot of quote escaping, and would be something like :