如何使 Mac 终端弹出/警报?苹果脚本?

编程入门 行业动态 更新时间:2024-10-11 13:19:04
本文介绍了如何使 Mac 终端弹出/警报?苹果脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望能够让我的程序显示警报、通知,以及显示我的自定义文本的任何内容.这是怎么做到的?另外,是否可以用几个按钮来设置一个变量?

I want to be able to have my program display an alert, notice, whatever that displays my custom text. How is this done? Also, is it possible to make one with several buttons that sets a variable?

类似于批处理:echo msgbox""<a.vbs&a.vbs

推荐答案

使用osascript.例如:

osascript -e 'tell app "Finder" to display dialog "Hello World"'

用您想要的任何应用程序替换Finder".请注意,如果该应用程序是后台的,对话框也会出现在后台.要始终显示在前台,请使用系统事件"作为应用程序:

Replacing "Finder" with whatever app you desire. Note if that app is backgrounded, the dialog will appear in the background too. To always show in the foreground, use "System Events" as the app:

osascript -e 'tell app "System Events" to display dialog "Hello World"'

阅读更多关于 MacOS X 提示.

更多推荐

如何使 Mac 终端弹出/警报?苹果脚本?

本文发布于:2023-11-27 21:47:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639715.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:终端   弹出   警报   脚本   苹果

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!