如何制作 Mac 终端弹出/警报?苹果文字? [英] How do I make a Mac Terminal pop-up/alert? Applescript?

查看:36
本文介绍了如何制作 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""

推荐答案

使用 osascript.例如:

Use osascript. For example:

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"'

阅读有关 Mac 的更多信息OS X 提示.

这篇关于如何制作 Mac 终端弹出/警报?苹果文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆